We’re instrumenting our CXone flows with New Relic custom events to track specific routing decisions. The issue is that the custom attribute isn’t persisting when I try to set it based on an IF condition in a Studio snippet.
The flow is supposed to check if a specific header exists in the inbound request, then assign a value to a custom attribute routing_context, and finally route based on that.
Here’s the snippet code:
var proxy = GetRESTProxy();
var response = proxy.Get('/api/v2/interaction/participants/' + ParticipantId);
// Check if priority header is present
IF response.headers.priority == 'high'
ASSIGN routing_context = 'priority_queue'
ELSE
ASSIGN routing_context = 'standard_queue'
END IF
// Log to New Relic via webhook (this part works)
var nrPayload = {
'eventType': 'CXoneRouting',
'context': routing_context,
'timestamp': Now()
};
proxy.Post('https://insights-collector.newrelic.com/v1/accounts/12345/events', nrPayload);
The New Relic event is being created, but the context field always comes back as undefined or empty, even when the header is clearly ‘high’. The routing itself works correctly based on the IF logic, so the condition is evaluating true. It seems the ASSIGN action isn’t committing the value to the variable scope before the webhook call.
Is there a specific way to force the variable update in Studio, or am I missing a step to persist the custom attribute before the external call?