Skip to main content

Types reference

All the types below can be imported directly from runllm, unless noted otherwise. The entrypoint and task decorators live in runllm.decorators. See Entrypoints and tasks.

All types except Client are Pydantic models.

Client​

Client(server_address: str = "https://api.runllm.com", api_key: Optional[str] = None)

Publishes workflows to RunLLM. If api_key isn't set, the client reads it from the RUNLLM_API_KEY environment variable, and raises an exception if neither is set.

publish()​

client.publish(
name: str,
entrypoint: EntrypointWrapper,
config: Optional[Dict[str, Any]] = None,
tasks: Optional[List[TaskWrapper]] = None,
) -> None

Serializes and uploads the workflow. The workflow is fully rolled out within a few minutes of a successful publish.

ArgumentDescription
nameThe workflow name.
entrypointThe @entrypoint-decorated function that starts each run.
configOptional JSON-serializable static config, passed to every entrypoint and task. See Static config.
tasksEvery @task-decorated function the workflow can transition to.

Raises an exception if entrypoint isn't decorated with @entrypoint, if two tasks have the same name, or if the server rejects the request.

Listeners​

SlackListener​

Starts workflow runs from Slack messages in a workspace.

FieldTypeDescription
team_idstrRequired. The Slack workspace ID (starts with T).
channelsList[SlackChannel]Optional. Channels with their own triggers. If omitted, the listener covers every channel the RunLLM bot has access to.
default_triggerTrigger or List[Trigger]The triggers for channels that aren't in channels. Defaults to Mention().

SlackChannel​

FieldTypeDescription
channel_idstrRequired. The Slack channel ID (starts with C).
triggerTrigger or List[Trigger]Optional. The triggers for this channel.

WidgetListener​

Starts workflow runs from the RunLLM chat widget.

FieldTypeDescription
domainstrRequired. The domain the chat widget is embedded on, for example docs.example.com.

ZendeskListener​

Starts workflow runs from Zendesk ticket activity.

FieldTypeDescription
subdomainstrRequired. Your Zendesk subdomain. For https://acme.zendesk.com, use acme.
triggerTrigger or List[Trigger]Required. Usually TicketCreated(), TicketComment(), or both.

Triggers​

TriggerFieldsDescription
MentionnoneSlack only. A message mentions the RunLLM bot.
ChannelMessagenoneSlack only. A new top-level message in the channel.
Emojishortcode: str, exclude_replies: bool = TrueSlack only. An emoji reaction on the last message in the conversation. shortcode excludes the colons.
ConvoMessagenoneA new message in an existing Slack thread or chat widget conversation.
TicketCommentnoneZendesk only. A new comment on a ticket.
TicketCreatednoneZendesk only. A new ticket.

The TicketComment trigger isn't exported from the top-level package. Import it with from runllm.bridge.trigger import TicketComment.

Events​

Event​

Passed to every entrypoint and task.

FieldTypeDescription
conversationConversationThe conversation the event happened in.
userUserMetadataThe user who triggered the event. user.email is currently only populated for Slack, and is None otherwise.
triggerTriggerThe trigger that matched.

Conversation​

FieldTypeDescription
new_messageUserChatMessageThe user message that triggered the event.
surfaceChatSurfaceWhere the conversation lives.
tagsList[str]Tags already applied to the conversation.
session_idintRead-only. Shorthand for surface.session_id.

Surfaces​

ChatSurface is any of SlackThread, ZendeskTicket, or ChatWidget. Every surface has:

FieldTypeDescription
typestr"slack_thread", "zendesk_ticket", or "chat_widget".
session_idintThe RunLLM conversation this surface belongs to.

Check surface.type (or use isinstance) before calling a surface-specific action. For example, send_to_slack_thread() raises an exception if to isn't a SlackThread.

SlackThread​

PropertyTypeDescription
team_idstrThe Slack workspace ID.
channelstrThe Slack channel ID.
config.thread_tsOptional[str]The Slack thread timestamp. None until the thread has been posted to.

ZendeskTicket​

PropertyTypeDescription
idstrThe Zendesk ticket ID.
subdomainstrThe Zendesk subdomain.
statusstrThe ticket status, such as "open". Updated in place by update_zendesk_ticket().

ZendeskTicketStatus​

An enum of Zendesk's built-in ticket statuses: NEW, OPEN, PENDING, ON_HOLD, SOLVED, and CLOSED.

ZendeskCustomField​

A value for a Zendesk custom ticket field, used with update_zendesk_ticket().

FieldTypeDescription
idintThe Zendesk custom field ID. Numeric strings are accepted.
valuestr, List[str], or boolThe value to set.

ChatWidget​

PropertyTypeDescription
config.convo_identifierstrA unique ID for the widget conversation.
config.chat_user_idOptional[str]The end-user ID, if your site passes one to the widget.
config.contextOptional[Dict[str, Any]]Page context from the widget, such as page_title, page_content, and url.

Messages​

UserChatMessage​

A message from a user.

FieldTypeDescription
textstrThe message text.
chat_idOptional[int]The RunLLM ID for this message.
user_identifierOptional[str]The user's ID. The format depends on the surface: a UUID for the chat widget, <channel_id>:<user_id> for Slack, and the Zendesk user ID for Zendesk.
attachmentsOptional[List[Dict[str, Any]]]Files attached to the message.

AssistantChatMessage​

A message generated by the assistant, returned by agent.answer() and agent.chat().

FieldTypeDescription
textstrThe answer text.
chat_idintThe RunLLM ID for this answer.
categoryOptional[AnswerCategory]How well the assistant was able to answer.

AnswerCategory​

ValueMeaning
ANSWEREDThe assistant answered with reasonable confidence.
LOW_CONFIDENCEThe assistant answered, but with low confidence.
UNANSWEREDThe assistant couldn't answer, usually because the documentation doesn't cover the question.
IRRELEVANTThe question is outside the assistant's scope.

ButtonClicked​

Returned by send_to_slack_thread() after a user clicks a button. Import it with from runllm.button import ButtonClicked.

FieldTypeDescription
idstrThe id of the button that was clicked.

Generated API reference​

An API reference generated from the SDK's docstrings is also available here.