We’re trying to automate the assignment of wrap-up codes after an interaction ends. The goal is to push the code from our backend once the agent clicks ‘Complete’ in Genesys Cloud.
I’m hitting /api/v2/interactions/{id}/actions with a PATCH request. The payload looks like this:
{
"actionType": "WRAPUP",
"wrapupCode": "12345678-1234-1234-1234-123456789012"
}
The API returns a 409 CONFLICT. The response body says the interaction is already in a terminal state or the action is invalid. I’ve checked the interaction status via GET, and it shows COMPLETED.
Is it possible to set the wrap-up code after the interaction has already transitioned to completed? Or do we need to hook into the WebSocket event stream and fire this before the agent finishes?
We’ve got a hybrid setup here in Sydney, so timing is tight. The docs mention wrap-up codes are part of the interaction update, but they don’t explicitly say if it’s allowed post-completion.
Any ideas on the correct sequence? We’re using the standard OAuth client credentials flow for auth.
{
"actionType": "WRAPUP",
"wrapupCode": "12345678-1234-1234-1234-123456789012",
"wrapupDuration": 0
}
The 409 usually means the interaction state doesn’t match what the API expects for a wrap-up action. You can’t just slap the code on there. The interaction needs to be in a specific state, usually COMPLETED or WRAPPED, depending on how your routing is set up.
Also, check the wrapupDuration. If you omit it, some SDK versions or older API endpoints get grumpy. Setting it to 0 (zero seconds) is the safest bet if the agent didn’t spend time in wrap-up.
If you’re using the Node SDK, it looks like this:
const InteractionApi = require('@genesyscloud/genesyscloud').InteractionApi;
const interaction = new InteractionApi();
const action = {
actionType: 'WRAPUP',
wrapupCode: '12345678-1234-1234-1234-123456789012',
wrapupDuration: 0
};
try {
const result = await interaction.updateInteractionActions({
interactionId: 'your-interaction-id',
body: action
});
console.log('Wrap-up set:', result);
} catch (error) {
console.error('Failed to set wrap-up:', error);
}
Make sure the interactionId is actually the full interaction ID, not just the conversation ID. They’re different things. If the interaction is still ACTIVE or QUEUED, this will fail. You might need to listen for the interaction:completed event in your client app to know when it’s safe to push this.