Websocket Heartbeats for PureCloud Guest Chat

We are building a customer-facing chat using the Guest Chat API. Once we have established a websocket and are subscribed to messages websocket.addEventListener(message, fn()... , we get a Websocket Heartbeat as documented here.

We notice the heartbeat message event doesn't contain any information about the chat its connected to, i.e. no conversationId.

{
  "topicName": "channel.metadata",
  "eventBody": {
    "message": "WebSocket Heartbeat"
  }
}

We are testing to add in that information ourself when we add the event listener, but it feels like this information should be here - ? (Just as this kind of information is present in the other message events we receive in the webchat websocket.)

This should be read in the context that a guest might start multiple chats within their browser session, so we need to be able to correlate the heartbeat with the right chat session.

Hey Joel.
Interesting issue here. It's kind of complicated in that the conversation really isn't strictly in the context of the heartbeat - the heartbeat is related to the websocket only. It's true that in the current system there will be a one-to-one situation with websockets and conversations, but that's just today. What I mean to say is that there exists a websocket transport (which obviously includes a heartbeat mechanism to detect problems) that can transport whatever the entities on either end of the transport wish. If the transport were used for something other than the conversation it wouldn't be necessary to heartbeat those multiple things.
Probably what you want, if you're going to maintain multiple chats in the same browser, is a local mapping of websocket-id-to-chat-conversation-id if you want to process the heartbeats.

2 Likes

Alright. Thanks for clarifying!

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.