Livechat Realtime API

Prev Next

The Livechat Realtime API methods (livechat:getInitialData, livechat:registerGuest, livechat:getAgentData, and sendMessageLivechat) are no longer available. Use the REST endpoints below instead. Only the room subscription in the last steps uses the Realtime API.

To have a Livechat conversation as a visitor, follow these steps:

  1. Generate a visitor token. It can be any random string, and you send it with every request below.

  2. Get the Livechat configuration with Get Livechat Configurations (GET /api/v1/livechat/config?token=<visitor-token>). The response tells you whether Livechat is enabled and online, and includes the widget settings, departments, and triggers.

  3. Register the visitor with Register Livechat Visitor (POST /api/v1/livechat/visitor), using the same token.

  4. Get the conversation room with GET /api/v1/livechat/room?token=<visitor-token>. It returns the visitor's open room, or creates a new one. Keep the room _id from the response.

  5. Send messages with Send New Livechat Message (POST /api/v1/livechat/message), passing the visitor token, the room rid, and the message text in msg.

  6. To receive new messages and room updates as they happen, subscribe to stream-room-messages and stream-livechat-room over the Realtime API. See Subscribe to Livechat Room (Realtime).

  7. Get the information of the agent serving the conversation with Get Agent Information (GET /api/v1/livechat/agent.info/{rid}/{token}).

To load earlier messages of the conversation, use Get Livechat Message History.