chat
Send a message and return the agent’s reply. One call is one full turn, including any tool calls the agent makes along the way, so expect seconds rather than milliseconds.
Parameters
conversationId
The conversation to send on.
message
The message to send.
options
Turn options.
options.role
user or system. A system message steers the agent without appearing as
something the user said.
options.configUrl
Creates the conversation if it does not exist yet. Saves a call, at the cost
of never receiving initialMessage, so the agent does not speak first.
options.userMetadata
Arbitrary data about the user, echoed back on this conversation’s webhooks.
Sent as user_meta_data.
options.timeout
Applies only when this call creates the conversation.
options.reinit
Applies only when this call creates the conversation.
Returns
Promise<ChatResponse> — carries text, conversationId, and userEvent.
userEvent is null unless the turn produced one. Its contents are whatever
your tool passed to swmlUserEvent(), so the shape is yours.
Throws
ChatInProgressError when a turn is already running on this conversation. That
is the contract rather than a transient failure, so wait for the first turn to
return instead of retrying.