Just noticed that the standard conversation termination flow in my Node.js gateway does not allow me to set a wrap-up code programmatically when I use DELETE /api/v2/conversations/webmessaging/{conversationId}. The endpoint simply closes the session without accepting a payload for disposition. I need to inject a specific code (e.g., “QA_Review”) into the interaction record before the wrap-up timer starts or immediately upon closure.
My GraphQL schema exposes a terminateConversation(id: ID!, wrapUpCode: String) mutation. I want this to be atomic. Currently, I am fetching the conversation, deleting it, and then attempting to update the interaction, but the timing is racy. The interaction state often transitions to “closed” before my subsequent PATCH request lands, resulting in a 409 Conflict or the update being silently ignored by the analytics engine.
Here is my current resolver logic using the Platform SDK:
const { ConversationApi } = require('@genesys/cloud/convapi');
const convApi = new ConversationApi();
async function terminateWithWrapUp(convId, code) {
// 1. End the conversation
await convApi.deleteConversationWebmessaging(convId);
// 2. Attempt to set wrap-up
// This fails because the conversation is already gone
const interactionId = await getInteractionIdFromCache(convId);
await convApi.putInteractionDisposition(interactionId, {
code: code
});
}
I have reviewed the API docs for PATCH /api/v2/conversations/webmessaging/{conversationId}. It accepts a state of closed but does not seem to support a wrapUpCode field in the body for the termination request itself.
- I tried chaining a
PATCHto the interaction endpoint immediately after theDELETE. The interaction ID is retrieved from a local Redis cache. The race condition causes the wrap-up to fail silently or return a 409. - I attempted to use the
POST /api/v2/conversations/webmessaging/{conversationId}/wrapupendpoint, but this requires an active agent session context which my backend service does not have. It returns a 401 Unauthorized because I am using a machine-to-machine OAuth token without an associated user context.
Is there a supported API pattern to set the disposition code at the exact moment of programmatic termination for a machine-initiated conversation? Or should I be using a different endpoint entirely to bridge this gap in the GraphQL gateway?