Routing to a queue based on a variable

Last Updated:

Contact center admins can set up logic in the flow editor to write to a custom variable, then use this variable in the Route To widget to route to a specific queue. This allows you to route to different queues by only using one Route To widget.

This article covers:

Prerequisites for routing to a queue based on a variable

How route to a queue based on a variable

  1. Create a custom variable with the String data type that will be used to define the queue to route to. 
  2. Add and customize the Script widget to write the queue name to the custom variable.
    Notes:
  3. Add a Route To widget to the flow.
  4. Select the Route To widget and customize these settings in the Settings tab:
    • Route to: Select Queue.
    • Queue or Variable: Select the custom variable you created.
  5. Click the Exit tab and make sure to set a widget in the Routing Failed drop-down menu. The flow will route to this widget if it's not able to route based on the custom variable.

Example

Note: This section shows an example configuration and is not meant to be a complete configuration guide.

  1. Create a custom variable with the variable name: queueName
  2. This string variable will contain the queue’s display name.
  3. Create the following flow layout with these settings: 

Script widget

Enter the following script in the Script widget. This will parse the called number and set the appropriate queue name. In this example, we created the custom variable: global_custom.General.queueName

const log = require('./utils/log');
var {_get:var_get , _set:var_set, _setGlobalVariable: global_var_set} = require('./utils/variable');

module.exports = async () => {
  let caller_number = var_get()["Start.From"];
  let callee_number = var_get()["Start.To"]; 
  let queue_name="";


  switch (callee_number) {
    case "+16505552222":
      queue_name = "IT Helpdesk Voice";
      break;
    case "+16505553333":
      queue_name = "Queue2";
      break;
    default:
      queue_name = "Queue1";
  }


  log.info("Call from " + caller_number + " to " + callee_number + " routed to queue " + queue_name);
  global_var_set("global_custom.General.queueName", queue_name); //set value of queue to a global custom variable

  return;  
}

Route To widget

Set the following settings in the Route To widget. This will send the caller to a queue defined by the global variable.

  • Settings tab
    • Route to: Select Variable, then select global_custom.General.queueName in the drop-down menu.

Zoom Community

Join the 100K+ other members in the Zoom Community! Login with your Zoom account credentials and start collaborating.