/
Set Variable Panel

Set Variable Panel

The “Set Variable” panel adds new variables or updates existing ones within your Logic flow. Interaction variables are helpful because they can be used dynamically throughout logic flows to make decisions and track information.

Figure 1: Set Variable panel

Using this panel

Many panels accept variables in their configuration, allowing for dynamic output that changes based on what values are contained in those variables. Use the Set Variable panel to adjust variables as needed for your use case(s). This panel creates individual entries for each variable created or updated.

Variables are used to collect, change, and/or transfer information across panels. Information from one panel may be useful to several other panels, and using a variable allows you to share that information widely throughout your Logic flow. Examples include DTMF input from a caller or response data from an API request.

Variables are especially useful when working with dynamic information. The results of any choices or evaluations in your flow—for example, a caller's choice between menu options—can also be stored in variables and transferred. This allows your Logic to work with information in complex ways, like decision-making, and reduces how much information needs to be entered by hand.

Configuration

  • Set as Flow Initiator: By selecting "Set as Flow Initiator," this panel will serve as the starting point of the IVR flow, before proceeding to subsequent panels within the Logic+ flow.

  • Panel Name: It is recommended that you choose a name and keep it consistent. You will also need to specify the variable name to update. If the variable does not exist, it will be created.

  • Panel Description: It is recommended to provide a clear description of the panel, detailing its purpose and functionality. This is akin to documentation, making it easier for others to understand and identify its intended use when they encounter it.

  • Variable Name: The variable name should be clear and concise to enhance understanding of its purpose. For example, I have set the ANI as callerID for an easy-to-understand reference later in the flow. When referencing a variable set outside this panel, one can use the callerID example as $(callerID) or refer to it as $(yourVariableNameHere).

  • Exit Path: The Default path is taken upon panel execution.

Value Type

There are two different types of “Value Type” that you can choose from to update the variable.

Simple

  • The Simple value type updates the specified variable to a new string value.

Figure 2: Configuring the Simple value

Expression

  • You can also use an Expression value type to manipulate the values of existing fields.

    • Available Function(s)

      • Subtract: Takes two numbers and subtracts the second number from the first. Example: 10 - 3 = 7.

      • Add: Adds two numbers together. Example: 5 + 2 = 7.

      • Multiply: Multiplies two numbers. Example: 4 * 3 = 12.

      • Divide: Divides the first number by the second. Example: 12 / 4 = 3.

      • Append: Adds (appends) an element to the end of a list or array. Example: [1, 2, 3] + 4 = [1, 2, 3, 4].

      • JSON Path: Allows querying and extracting specific values from a JSON object using a path expression. Example: $.store.book[0].title would get the title of the first book in a store.

      • Round: Rounds a number to the nearest whole number or to a specified number of decimal places. Example: 3.7 becomes 4, or 3.14159 rounded to two decimals is 3.14.

      • Absolute Value: Returns the positive value of a number, regardless of whether it's negative. Example: |-5| = 5.

      • Slice: Extracts a portion (or slice) of a list or string. Example: slicing the first 3 characters from "hello" gives "hel".

      • Random Number: Generates a random number within a specified range.

      • Length: Returns the number of elements in an array, or the number of characters in a string. Example: the length of "hello" is 5.

      • Replace: Replaces occurrences of a substring within a string with another substring. Example: replacing "dog" with "cat" in "doghouse" gives "cathouse".

      • Regex Replace: Uses regular expressions to find patterns in a string and replace them with something else. Example: replacing all digits in a string with "X".

There is a 1,000-character limit on the value of variables set in Logic+.

To return data to Classic Logic, dotCX, and action bots, you can use the Set Variable Panel and a variable naming convention of 'SharpenCX_ClassicLogic_<varName>'. The Classic Logic flow will have access to a call variable named <varName>.

Related Article: Available Predefined Variables

Related content

Set Variable
More like this
Available Predefined Variables
Available Predefined Variables
Read with this
Logic+ Subroutine
More like this
SharpenDB SELECT
Read with this