Syncing to Internal Platforms
It is important to have your team work on the surfaces they are most comfortable with. If you have a RunLLM widget deployed on your docsite, but the support team lives in Slack, it can be helpful to sync the conversation from the widget to a slack thread.
tip
It is common to do some tagging or categorizing before deciding to sync the conversation.
from runllm import Agent, Client, Event, WidgetListener
from runllm.decorators import entrypoint
@entrypoint(
listeners=[
WidgetListener(domain="mydocs.dev"),
WidgetListener(domain="mydocs_v2.dev"),
]
)
def sync_to_internal_wf(agent: Agent, event: Event):
convo = event.conversation
# Tip: Answers provided surfaces such as the widget or the admin console
# should be streamed back to minimize time-to-first-token delay.
answer = agent.stream_answer(convo)
# Ensures every widget chat session is pinned to a single Slack thread.
slack_thread = agent.create_or_get_slack_thread(
convo.session_id,
team_id=INTERNAL_SLACK_TEAM_ID,
channel_id=INTERNAL_SLACK_CHANNEL_ID,
)
# Every exchange will be prefixed by the role sending the message.
agent.send_to_slack_thread(
event.conversation.new_message,
to=slack_thread,
prefix="*User:* ",
enable_feedback=False,
)
agent.send_to_slack_thread(
answer,
to=slack_thread,
prefix="*Assistant:* ",
enable_feedback=False,
)