CXone Studio ASSIGN/IF logic failing

Trying to branch a call based on queue length in Studio.

ASSIGN: @QueueLen = GetRESTProxy("/api/v2/analytics/queue/realtime").data[0].state.inQueue
IF: @QueueLen > 10 THEN PlayPrompt("Wait") ELSE Transfer("Agent")

The IF action always evaluates to false even when @QueueLen is 25. Is the variable type wrong?

You’re hitting a type mismatch. The REST xy returns the inQueue count as a string, not an integer. Studio’s IF action does strict type checking, so comparing a string to a number always fails. You need to cast it first.

Try this in your flow:

// Step 1: Get the data
ASSIGN: @RawData = GetRESTProxy("/api/v2/analytics/queue/realtime")

// Step 2: Parse and cast to integer
ASSIGN: @QueueLen = parseInt(@RawData.data[0].state.inQueue)

// Step 3: Compare integers
IF: @QueueLen > 10 THEN PlayPrompt("Wait") ELSE Transfer("Agent")

I ran into this exact issue last week with BYOC trunk metrics. The docs imply numeric fields come back as numbers, but the JSON parser in Studio defaults to strings if the source isn’t explicitly typed. Adding parseInt fixed it instantly. Also, check if data[0] is actually populated. If the queue is empty, that index throws a null error which breaks the whole branch silently. You might want a null check before the parse just to be safe.