Dynamically Reference a Routing Code

You can use expressions to dynamically select short codes (or other routing codes) inside a service.

In particular, this enables you to use one service to handle message flows coming from multiple routing codes.

For example, you may want to have one service that is used across different geographical regions (e.g. the US and the UK) and therefore uses separate geographical numbers. If your users need to respond to the service (for example to text back their address or a confirmation) then you will need to dynamically reference the routing codes so that the service will continue.

To dynamically reference a routing code, you must create a "constant" variable for the routing code. You can then reference the variable as an expression in the Wait for Response handler.

Constant variables can use either the service or servicecoll scope. To create one of these variables:

  1. In the service editor screen for a service, select either Service Variables or Service Collection Variables. This will open the edit page for variables.
  2. In the edit interface, select the Constants tab.
  3. Enter a Key for the variable, select Routing code from the Type drop down menu, and then choose the routing code you wish to reference.

Example scenario

ACME has a service in two regions; the US (short code 222111) and the UK (short code 58870).

Two service constants are created using the above steps:

  • ${service.routingcodes.222111} linked to the short code 222111
  • ${service.routingcodes.58870} linked to the short code 58870

In the Wait for Response handler, the handler is set to wait for responses from the expression:

${service.routingcodes[session.initialKeyword.routingCode.name]}

The service will wait for the end user to respond from the same short code that they initially connected through.