What’s the best way to implement branching logic in a CXone Studio Snippet using ASSIGN and IF actions? I am building a script that checks user role permissions. The logic needs to route based on the role_id returned from an API call.
Here is my current structure:
- Call GetRESTProxy to fetch user details.
- Extract
role_idinto variableuserRole. - Use IF to check if
userRoleequalsadmin. - Use ASSIGN to set
routeTargettoadminQueue.
The issue is the syntax for the IF condition. I tried:
IF {{userRole}} == "admin" THEN
ASSIGN {{routeTarget}} = "adminQueue"
ELSE
ASSIGN {{routeTarget}} = "standardQueue"
END IF
This fails validation. How do I correctly format the comparison operator and variable references? Do I need to wrap the variable in quotes? Is the THEN keyword required? Any example JSON for the IF action would help.