I’m working on an Android app (Kotlin) that integrates with the Genesys Cloud Web Messaging SDK. Currently, the SDK handles session lifecycle nicely on the client side, but we have a specific use case where we need to force-close a guest’s conversation from our backend service when certain business logic triggers (e.g., timeout or agent unavailability).
The goal is to terminate the session cleanly so the SDK on the device recognizes the closure and stops polling. I’ve looked through the /api/v2/conversations/messaging endpoints, but I’m not seeing a clear “close session” method that works for guest-initiated chats without an agent being explicitly added.
Here’s what I’ve tried so far in my backend service (Java/Spring Boot):
// Attempting to update conversation state
ConversationUpdateRequest updateRequest = new ConversationUpdateRequest();
updateRequest.setState("closed");
updateRequest.setReason("backend_timeout");
try {
conversationApi.updateConversation(conversationId, updateRequest);
System.out.println("Conversation closed successfully");
} catch (ApiException e) {
System.err.println("Error closing conversation: " + e.getMessage());
// Getting 409 Conflict: "Conversation state cannot be changed to closed"
}
I keep hitting a 409 Conflict error with the message Conversation state cannot be changed to closed. The docs imply that only agents can close conversations, or that the session needs to be in a specific state first.
Is there a specific API call or sequence of calls I’m missing to properly terminate a guest session from the backend? Or should I be using the Guest API endpoints (/api/v2/conversations/messaging/guests) instead? If so, what’s the correct payload to send to ensure the Android SDK picks up the closure event via WebSockets?
Any code examples or endpoint specifics would be appreciated. I’m trying to avoid polling for state changes on the client side if possible.