The Livechat Realtime API methods (
livechat:getInitialData,livechat:registerGuest,livechat:getAgentData, andsendMessageLivechat) 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:
Generate a visitor token. It can be any random string, and you send it with every request below.
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.Register the visitor with Register Livechat Visitor (
POST /api/v1/livechat/visitor), using the same token.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_idfrom the response.Send messages with Send New Livechat Message (
POST /api/v1/livechat/message), passing the visitortoken, the roomrid, and the message text inmsg.To receive new messages and room updates as they happen, subscribe to
stream-room-messagesandstream-livechat-roomover the Realtime API. See Subscribe to Livechat Room (Realtime).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.