WebSocket Guest API - Message State Sync Issue on Custom UI!

Hey everyone! :waving_hand:

Something super weird is happening with our custom chat widget!

We’ve got about 800 agents in our org, so we’re dealing with a ton of traffic.

The WebSocket connection is staying open, but the message states are acting up!

Basically, when a user sends a message, the “sent” confirmation is received via the socket.

But!

Then the UI just freezes for a second.

The message doesn’t mark as “delivered” even though the agent sees it immediately.

It’s almost like the event isn’t firing or is being dropped!

We’re using the latest web_messaging_sdk.

I tried to pull the history manually to see if the state is correct on the backend.

The call to GET /api/v2/webmessaging/messages shows everything as delivered.

// Checking the response from the API
{
 "entities": [
 {
 "id": "msg-12345",
 "text": "Hello!",
 "state": "delivered",
 "timestamp": "2023-10-27T10:00:00Z"
 }
 ]
}

The SDK is just not reflecting this in the real-time stream!

The socket logs are clean.

No 400s or 500s are being thrown.

A few different browsers were tested and the same thing happens.

The session is authenticated and everything is configured perfectly!

Wait, I noticed it only happens when the conversation is transferred from a bot to an agent.

The state sync seems to break right at the handover point!

First, what are the data retention policies for these chat transcripts in your org? If you’re archiving these for quality audits, a sync lag in the UI can sometimes mask a deeper issue with how the interaction is being committed to the database.

The freeze usually happens because the UI is blocking the main thread while waiting for a state transition that hasn’t cleared the backend. You’re likely hitting a race condition between the WebSocket event and the API’s internal state update. Instead of relying solely on the socket for the “sent” state, use a polling fallback or a specific check against the conversation resource.

Error Code Cause Fix
429 Rate limit on state sync Implement exponential backoff
404 Interaction not yet indexed Add a 500ms delay before GET
500 Backend timeout Check for oversized custom attributes

Be careful if you’re linking these interactions to quality evaluations later. If you change the evaluation form version to track these UI glitches, you’ll break the historical reporting for any old forms.

Try a GET request to verify the state:

// Use v2 API to verify actual message state
const response = await platformClient.conversations.getConversation(conversationId);
const latestMessage = response.participants[0].messages.slice(-1)[0];
if (latestMessage.state === 'delivered') {
 updateUIState('confirmed');
}
1 Like

i think is like the screen pop problem in SFDC. maybe the Apex trigger is slow and block the socket? try check if interactionId is correct in the data action.

{
 "action": "/api/v2/conversations/chats",
 "params": {
 "state": "connected"
 }
}

sometimes it just give some error and freeze.

2 Likes