Prompts & Expressions

Introduction

When configuring different components, you may notice that some functionality is shared between them. For example, the “Prompt Playback”, “Menu”, “User Input” and “Record” among other components, use a collection of prompts to define the audio files to play to the caller. When configuring any of these components, you can use the common “Prompt Collection Editor” to define the prompts.

In the same way, when a component property has to be set using an expression, you can easily create this expression using the “Expression Editor”.

Prompt Types

Many CFD components use prompts to perform the desired operation, with each prompt type specified as:

  • Audio file: The prompt is stored as a WAV file, and the filename is selected from a file list, or you can browse looking for it from the file system.
  • Dynamic Audio file: The prompt is stored as a WAV file, but the file name is dynamically created using an expression.
  • Recorded Audio: The prompt is stored as a RecordComponent.AudioId variable, containing the audio previously recorded from the caller.
  • Number Prompt: The prompt takes the number from an expression, and plays it according to the current PBX language rules, and the format specified:
  • Full Number: for example: 2221111 played as "two million two hundred twenty one thousand one hundred eleven".
  • Grouped by Two: for example: 2221111 played as "two twenty two eleven eleven".
  • One by One: for example: 2221111 played as “two two two one one one one”.
  • Text to Speech Audio: The prompt is generated in real time using the selected TTS engine (Amazon Polly or Google Cloud), saved as a WAV file, and finally the WAV file is played. The file created is automatically deleted when the call ends. More information on using text to speech services can be found in the respective guides for Amazon and Google. You can change the selected TTS engine from the menu Tools > Online Services.

⚠ Important: When using a Dynamic Audio file prompt, the expression that creates the file name must return a string containing the file path relative to the project audio folder, or the absolute path to the file. If the audio file is located in your project Audio folder, then you just need to refer to it by its name, no special path information is required. The project Audio folders are:

  • Windows: “C:\ProgramData\3CX\Instance1\Data\Ivr\Prompts\Callflows\project\”
  • Linux: “/var/lib/3cxpbx/Instance1/Data/Ivr/Prompts/Callflows/project/”

where “project” is the name of the project, in lowercase.

The Prompt Collection Editor

The Prompt Collection Editor lets you edit the prompts to be played by a component for a specific purpose.

The Prompt Collection Editor

Here you can add any of the 5 different prompt types, and depending on the selected type you need to configure each prompt using an expression or selecting the WAV file from a list or from the file system. You can also change the order of the files, moving them up or down.

When selecting a WAV file for an Audio File Prompt, this can be played from the CFD, so there is no need to switch to a WAV player tool to listen to the WAV file that will be included as part of the project.

The Project Audio Folder

Open Project Audio Folder action in 3CX CFD context menu

You can open the project audio folder by right-clicking any component that uses prompts and select the “Open Audio Folder” option. From there you can delete unused WAV files, play them using the Windows tools for WAV file playback, etc.

The Expression Editor

Click to open Expression Editor in 3CX CFD Transfer component

Many component properties must be set using an expression. When configuring components from their configuration dialog, use the “fx” button on the right of the field to open the expression editor and create an expression:

Expression Editor in 3CX CFD

  1. “Expression” - drag-and-drop here Inbuilt Functions, Variables or Constant Values to construct your expression. Click on “🢓” icon to access the expression item option menu to add arguments, change types or delete.
  2. “Expression Elements” - select Inbuilt Functions, Variables or Constant Values to add to your expression.
  3. “Inbuilt Functions” - click to expand the relevant category and select the Inbuilt Function to add:
  • Boolean
  • AND: Performs a logical AND between 2 and up to 20 parameters, returning a Boolean value as a result.
  • OR: Performs a logical OR between 2 and up to 20 parameters, returning a Boolean value as a result.
  • NOT: Receives a single Boolean parameter and returns another Boolean that is the negation of the provided parameter.
  • EQUAL: Receives 2 parameters of any type, and returns a Boolean indicating if they are equal.
  • NOT EQUAL: Receives 2 parameters of any type, and returns a Boolean indicating if they are not equal.
  • CONTAINS: Receives 2 strings, and returns true if the first string contains the second, or false otherwise.
  • GREAT THAN: Receives 2 parameters of any type, and returns a Boolean indicating if the first is greater than the second.
  • GREAT THAN OR EQUAL: Receives 2 parameters of any type, and returns a Boolean indicating if the first is greater than or equal to the second.
  • LESS THAN: Receives 2 parameters of any type, and returns a Boolean indicating if the first is less than the second.
  • LESS THAN OR EQUAL: Receives 2 parameters of any type, and returns a Boolean indicating if the first is less than or equal to the second.
  • TO BOOLEAN: Converts the value received to a boolean.
  • String
  • CONCATENATE: Concatenates every string parameter and returns the resulting string. Can have from 2 to 20 parameters.
  • TRIM: Receives a string and returns the same string removing leading and trailing not visible characters (spaces, new lines, etc.)
  • LEFT: Receives 2 parameters. The first is a string to cut. The second is the number of characters to cut. Returns a string that is the first N characters of the original string.
  • MID: Receives 3 parameters: the first is a string to cut, the second is the zero-based cut start position and the third is the number of characters to cut. Returns the specified substring of the original string.
  • RIGHT: Receives 2 parameters: the first is the string to cut, the second is the number (N) of characters to cut. Returns a string that is the last N characters of the original string.
  • UPPER: Receives a single string parameter and returns this string in uppercase.
  • LOWER: Receives a single string parameter and returns this string in lowercase.
  • REPLACE: Receives 3 parameters. The first is a string where the replacement must be made. The second is the text to find and replace. The third is the replacement text. Returns a string with the replacements specified.
  • REPLACE REG EXP: Receives 3 parameters: the first is a string where the replacement must be made, the second is the regular expression to find the text to replace, the third is the replacement text. Returns a string with the replacements specified.
  • TO STRING: Converts the value received to a string.
  • Date Time
  • NOW: Receives no parameters, and returns the current date and time as a DateTime object.
  • Number
  • LEN: Receives a single string parameter and returns its length as a number.
  • SUM: Sums 2 and up to 20 numeric 32-bit integer parameters and returns the result.
  • SUM LONG: Sums 2 and up to 20 numeric 64-bit integer parameters and returns the result.
  • NEGATIVE: Returns the negative number of a single numeric 32-bit integer parameter.
  • NEGATIVE LONG: Returns the negative number of a single numeric 64-bit integer parameter.
  • MULTIPLY: Multiplies 2 and up to 20 numeric 32-bit integer parameters and returns the result.
  • MULTIPLY LONG: Multiplies 2 and up to 20 numeric 64-bit integer parameters and returns the result.
  • DIVIDE: Receives 2 32-bit integer parameters, and returns “first / second”.
  • DIVIDE LONG: Receives 2 64-bit integer parameters, and returns “first / second”.
  • ABS: Returns the absolute positive number of a single 32-bit integer parameter.
  • ABS LONG: Returns the absolute positive number of a single 64-bit integer parameter.
  • GET TABLE ROW COUNT: Returns the number of rows of a table received as the result of a database query.
  • GET LIST ITEM COUNT: Returns the number of items of the list received. The list is the result returned by the component “3CX Get Queue Extensions”.
  • TO INTEGER: Converts the value received to a 32-bit integer.
  • TO LONG: Converts the value received to a 64-bit integer.
  • Object
  • GET TABLE CELL VALUE: Receives 3 parameters: the first is the variable containing the table as the result of a database query, the second is the zero-based row identifier, the third is the zero-based column identifier. Returns the value of the cell from the specified table, at the specified row and column.
  • GET LIST ITEM: Receives 2 parameters. The first is the variable containing the list, i.e. the result returned by the 3CX component “Get Queue Extensions”. The second is the zero-based item index. Returns the value of the item from the specified list, at the specified index position.

Click on “OK” to create your expression.

See Αlso

Last Updated

This document was last updated on 14th October 2021

https://www.3cx.com/docs/manual/cfd-prompts-expressions/