Rate this page:

Basic work with variables

A variable is a store of information. Using variables allows you to call up the necessary information at different stages of your scenario.

Voximplant Kit supports pre-configured variables {{phone}} and {{UTC}}. The {{phone}} variable is filled when an outgoing call is started; it contains the phone number you are calling from your scenario. The {{UTC}} variable stores the customer's timezone. There is also a number of standard variables, which are filled depending on the call data (caller's and callee's phone numbers, call completion codes, links to call recordings, etc).

In your scenarios, you can use existing variables and create new ones.

Creating variables

Copy URL

You can create new variables in various scenario blocks, for example, in the Data modification block. Enter the name of a new variable in the Create or select variable field and give it a value. Be sure to use curly braces at the beginning and end of the name. Please note that the curly braces are added automatically if you enter a variable and press Enter.

Using variables
Important

Name variables in accordance with the Javascript basic rules. A variable name cannot begin with a number and can only contain $ and _ characters. A variable name can only contain Latin letters and numbers. Variable names are case-sensitive; {{Phone}} and {{phone}} are two different variables.

Note

You can use numeric and text values, as well as functions of helpers.

If you need to use the same value in several scenarios at once, you do not need to create several variables. You can add a global variable instead and assign it a fixed value. For more information on how to create global variables, go here.

Global variable

Examples of using variables

Copy URL

Let us review how you can use the {{phone}} variable in the following cases:

  • When transmitting data in an HTTP request to your CRM system to receive customer's phone number and use it in a call;

  • When transferring call data to an agent in the Extension or Call to queue blocks.

Let us look at the example with an HTTP request in detail.

Assume that your CRM system can return information about a customer in response to a request with a phone number. You make a request to your CRM system and send it the phone number you are calling.

HTTP-request

Let us assume you want to receive the customer's name so you can use it in your scenario. Enter the request parameters, click the Add response button in the HTTP request block, and select the Using HTTP response data option. Enter the test number in the phone field. It is important that the number exists in your system so that API returns a correct response. You receive a response from your CRM server and write the customer’s name into a variable by selecting the checkbox next to the name.

Response

The system writes the customer's name into the {{client_name}} variable.

Customer name in a variable

You can later use this variable in your scenario, for example, in TTS blocks for a personalized appeal to your customer.

Using variable

In the example, you use the {{phone}} variable to retrieve customer data from your CRM. The received data, in its turn, is also recorded in a variable and is available in your scenario.

You can use the {{phone}} variable in the Extension or Call to queue block to transfer call data to an agent. If your agent works in a CRM or other system, with the help of the variable you can get a user ID and, for example, create a link that your agent will see in the Workspace.

Overwriting variable values

Copy URL

You can overwrite data in created variables if needed. In your scenario, add the Data modification block for each new value of a variable.

Let us use the Meeting confirmation scenario template to learn how to overwrite variables.

Meeting confirmation

The scenario uses the {{call_status}} variable, which can take different values depending on the call result: call accepted or dropped, subscriber unavailable, etc. To overwrite variable values, you need to use a separate Data modification block for each of them.

Different variable values

Depending on a {{call_status}} value, the scenario goes accordingly: if the call is successful, the scenario moves on and the customer receives the meeting confirmation; if voicemail is detected or the subscriber is unavailable, the scenario ends.

Variable values in the scenario

The {{call_status}} variable helps you filter call history report calls by variable values. When you download a report using the Export button, the system adds all variables used in the scenario to the report file. This helps you work with your call history more accurately.

Information

Above is just one of the examples of using variables. You can use your own data for filtering. A common use case is to use variables for tracking scenario stages from start to finish. You can see similar examples in scenario templates. To record the final call result, you can use the {{CALL.result_code}} variable. It is also included in a call history report.