WebSocket Session Initialization
Prerequisites
- Register the client app and generate a Client ID and Secret Key on the Platform.
Step 1 — Generate a JWT
Generate the JWT on the server using the client app credentials and user identity. Pass it to the client app.Step 2 — Exchange JWT for an Access Token
Endpoint:Step 3 — Get the WebSocket URL
Endpoint:This URL is short-lived and expires in 30 seconds. Connect before it expires.
accessToken as a Bearer token in the Authorization header.
Sample cURL:
RTM Channel Events
RTM Client Events
Event:/bot.message — Sent when a user posts a message.
customData object. This capability is available for both Web SDK and direct WebSocket integrations. For more information, see How to pass customData to bot from SDK?
Return Custom Data in Bot Responses
Bot responses can also include custom JSON data in addition to the message content. Use the Advanced JavaScript Editor to add custom JSON to text, standard template, or custom template responses. Client applications can consume this data through available Web SDK or WebSocket events and process it separately from the user-visible message.
RTM Server Events
Event:ack — Acknowledgment sent when a client event is received.
bot_response — Sent when a client message is processed.
user_message — Sent to the client when the user sends a message from another simultaneous session.
Bot Status Events
Event:/bot_active — Triggered when a WebSocket connection is established with the bot.
/botKitUnreachable — Sent to the WebSDK when BotKit is unreachable. Default message: "Sorry, there was an error in continuing the conversation. Please retry." Developers can customize this message.
Form Events
Event:/form_delivered — Triggered when a form is delivered to a user.
Event: /form_submitted — Triggered when a user submits a form.
Event: /form_failure — Triggered when a form fails for any reason.
All form events share the same payload structure:
Session Events
Event:/session_start — Triggered when a session starts.
Triggers on:
- On-Connect event (open, refresh, or disable chat window).
- A message sent after 15 minutes of inactivity.
- A message sent after the idle timeout configured in Manage Sessions.
/session_end — Triggered when a session ends.
Triggers on:
- On-Connect event (close, refresh, or disable chat window).
- Session timeout after 15 minutes.
Agent Transfer Events
Event:/agent_session_start — Triggered when chat is handed off to an agent.
Event: /agent_session_end — Triggered when the agent conversation ends.
Both share the same payload:
User Input Event
Event:/waiting_for_user_input — Triggered when the VA waits for user input (from an Entity, Confirmation, or Standard Response node).
Get Conversation History
Endpoint:
Pass
accessToken as Authorization: bearer <token>.
Sample cURL: