I’m trying to close a web messaging conversation from my Node.js backend service rather than relying on the client-side close() method. The goal is to handle session timeouts server-side if the user goes idle. I’ve got the conversationId and the webChatSessionId from the incoming webhook payload.
I tried POSTing to /api/v2/conversations/messaging/{conversationId}/close with the standard bearer token, but that just archives the conversation on the platform side. It doesn’t actually terminate the WebSocket connection for the guest. The guest’s UI still shows “Typing…” or keeps the session open until they manually close the tab.
Here’s the request I’m making:
const response = await fetch(`https://${region}.mygenesys.com/api/v2/conversations/messaging/${convId}/close`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
reason: 'server_timeout'
})
});
The API returns a 204 No Content, which implies success. But the client SDK (genesys-cloud-webrtc-sdk or the web messaging widget) doesn’t seem to receive a termination signal. I checked the network tab in the browser and the WebSocket stays in OPEN state.
Is there a specific API endpoint that forces the WebSocket closure? Or do I need to inject a system message that triggers the client SDK to close? I’ve looked through the Messaging API docs and the Web Messaging SDK source, but I don’t see a clear “force close” method that works from the server side. The conversation.end event fires, but the connection hangs.
Any ideas on how to actually drop the connection?