Need some help troubleshooting the correct sequence to terminate a Web Messaging conversation from the backend. I am building a Rust service using tokio and reqwest to manage session lifecycles for high-volume chat bots. The goal is to programmatically end a session when a specific business logic timeout is reached, without waiting for the guest to disconnect.
I have tried sending a DELETE request to the conversation endpoint:
DELETE /api/v2/conversations/webmessaging/{conversationId}
However, this returns a 409 Conflict with the message “Conversation is active.” I understand I need to close the conversation first, but simply setting state to closed via PATCH does not immediately release the WebSocket connection on the guest side in my testing.
Here is the payload I am using for the state update:
{
"state": "closed",
"wrapUpCode": {
"id": "some-wrap-up-id"
}
}
Is there a specific flag or subsequent API call required to force the guest client to drop the connection? Or should I be using the POST /api/v2/conversations/webmessaging/{conversationId}/close endpoint instead? The documentation is slightly ambiguous on the exact HTTP method for forced termination.