Studio Session Handover fails with 400 Bad Request when Cognigy returns empty payload

We’re integrating a NICE Cognigy voicebot with a CXone IVR. The flow is supposed to hand off the session to an agent when the bot can’t resolve the intent.

I’m using the GetRESTProxy action to send the user’s transcript and context to our internal logic service, then using ASSIGN to set the session.handover object. The handover works fine if the bot finds an answer. But when it fails and needs to transfer, the Cognigy webhook returns a minimal JSON payload.

Here is the logic:

GetRESTProxy('POST', 'https://internal-bot-api/v1/handover', jsonPayload);

IF (GetRESTProxy('response.statusCode') == 200) {
 ASSIGN(session.handover.targetQueue, 'support_tier2');
 ASSIGN(session.handover.preservedContext, GetRESTProxy('response.body.context'));
}

The issue is that when Cognigy signals a handover, the response.body.context is often just {} or null. When tries to process the handover with an empty context object, the flow drops with a 400 Bad Request error in the logs. The error message is vague: “Invalid session handover payload structure.”

I’ve tried wrapping the context in a default object:

ASSIGN(session.handover.preservedContext, IF(GetRESTProxy('response.body.context') == null, '{"fallback": true}', GetRESTProxy('response.body.context')));

But seems to reject the stringified JSON or the null value entirely during the handover phase. The REST call succeeds, but the actual session transfer fails.

Has anyone handled empty context payloads in Cognigy handovers? Is there a specific JSON schema required for session.handover.preservedContext that I’m missing?