Branching Logic in CXone Studio Snippets

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:

  1. Call GetRESTProxy to fetch user details.
  2. Extract role_id into variable userRole.
  3. Use IF to check if userRole equals admin.
  4. Use ASSIGN to set routeTarget to adminQueue.

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.