I’m trying to build a simple routing rule in CXone Studio using the new snippet capabilities, but the branching logic keeps falling through to the default case. I’m pulling data from an external API via GetRESTProxy and storing the response in a variable called apiResponse. The goal is to check if the status field equals ‘active’ and branch accordingly.
Here’s the snippet I’ve written:
ASSIGN apiResponse = GetRESTProxy('myEndpoint', 'GET', {}, {})
IF apiResponse.data.status == 'active'
ASSIGN routingDecision = 'premium_queue'
ELSE
ASSIGN routingDecision = 'standard_queue'
ENDIF
The weird part is that when I run this in the simulator, the IF condition always evaluates to false, even though the debug log shows apiResponse.data.status is clearly ‘active’. I’ve tried changing the comparison to apiResponse.data.status === 'active' and even wrapping it in quotes like '${apiResponse.data.status}', but nothing works.
I’m assuming there’s something about how CXone handles JSON objects returned from GetRESTProxy that I’m missing. Is the data being treated as a string instead of an object? I’ve also tried using the ParseJSON function on the response before the IF statement, but that throws a syntax error in the editor.
We’re on the latest CXone release, and this is for a campaign that needs to go live by Friday. Any ideas on how to properly reference nested JSON fields in an IF condition within a Studio snippet? I’m stuck.