Read user input (numbers) in 3CX Call Flow Designer

Introduction


In this article, we will consider the creation of a voice application that reads a sequence of numbers entered by the user through a dialer, and then confirms the correctness of the input, losing to the subscriber the entered numbers. Agree, this is a fairly common task in the telephone self-service portals.
 
Our application will perform this task using 3CX Call Flow Designer . The application works as follows:

  1. 3CX CFD reports: Enter your user number
  2. User is dialing 1234
  3. 3CX CFD reports: The entered user number is 1234. To confirm, press 1, to re-enter, press 2.

Since the reproduction of numbers may be required in various parts of our application, we will place it in a separate user component. CFD allows you to create such custom components.

Recall that in previous articles we examined the creation of a CFD application for outgoing calls (upon completion of calls you can send a report using the Email Sender component), the work of CFDs with databases (which can also be used to obtain a subscriber’s number), and routing of incoming calls depending on time of day (which can be combined with outgoing calls) and sending an e-mail message (for example, to notify an order by phone).
 
Please note that the 3CX CFD development environment is free. But voice applications will only run on the 3CX edition of Pro and Enterprise . You can download CFDs from here .     
 
The demo project of this voice application is supplied with the 3CX CFD distribution kit and is located in the Documents \ 3CX Call Flow Designer Demos folder . Let's get started.

Project creation


To create a CFD project, go to File → New → Project , specify the project location folder and its name, for example, “PlayDigitsDemo” .



Creating a custom component


The created component will receive a sequence of digits from the user and play them sequentially.

To create a component in the Project Explorer window, right-click on the project name, select New Component and name it PlayDigits .



Then click on the PlayDigits.comp component and in the Properties Window section click the button next to the Variables collection . Add two variables - Digits and Index . Variable Digits - accepts digits, which the component then loses. The Index variable is internal, it allows the component to switch from digit to digit.



To add variables, click the Add button.to add a variable and change its name (Name property) to Digits . The Digits variable must have the following properties: Accessibility: ReadWrite, Initial Value:, Scope: Public. Click the Add button again , add a new variable and change its name to Index . The Index variable should have the following properties: Accessibility: ReadWrite, Initial Value: 0, Scope: Private

Now let's take a look at the component architecture. We will use the Loop component to iterate over a sequence of digits (loop). In the Loop component, add the Prompt Playback component to play the next digit in the sequence. In the same Loop component, add the componentIncrement Variable , which will increase the value of the Index variable . This design will allow you to consistently reproduce all the numbers entered by the user.

Loop creation


  1. Drag the Loop component into the main window of the development environment.
  2. In the Properties window, change the component name to digitsLoop.

    Select the digitsLoop component and in its Condition property, specify the line

    LESS_THAN(callflow$.Index,LEN(callflow$.Digits)).

    This expression repeats the loop as long as the Index variable (callflow $ .Index) is less than the number of LEN digits entered by the user (callflow $ .Digits).

Message Playback


  1. First of all, we need sound files corresponding to each digit. Prepare and copy the 0.wav , 1.wav , etc. files . to 9 in the Audio folder of your project.
  2. Drag the Prompt Playback component into the main field of the application onto the Loop component .
  3. Change the component name to playDigit .
  4. Select this component and in the properties window click on the button near the Prompts collection to open the Prompt Collection Editor sound message editor.
  5. Click the Add button and change the type to Dynamic Audio File Prompt

    In the Audio File Expression field, enter the line

    CONCATENATE(MID(callflow$.Digits,callflow$.Index,1),".wav").

    The expression uses the digit of the current iteration and combines it with the file extension (string) .wav . Thus, the corresponding digit is played to the subscriber.



Variable Number Increment Component


  1. Drag the Increment Variable component onto the Loop component , below the playDigit
    component
    Change the component name to incrementIndex

    For the VariableName property, specify the expression

    callflow$.Index

The execution cycle will look like this:



Our component is ready. Now we will call it from the main application.

Call component to play numbers


After the custom component is ready, use it in our application:

  1. In the Project Explorer window , click Main.flow to open the main application.
  2. Add a User Input component that will request input from the user. Rename it to requestInput and add a pre-prepared message to the user about the need to enter.
  3. In the Valid Input branch from the User Defined Components window, add the created custom PlayDigits
    component
    Rename it to playEnteredDigits

    Select it and specify the following expression in the Digits property

    requestInput.Buffer

The requested digits will be first buffered and then played to the user. The finished application will look something like this:



Compiling and installing the application on the 3CX server


The voice application is ready! Now it should be compiled and downloaded to the 3CX server. For this:

  • Go to Build> Build All , and CFD will create a PlayDigitsDemo.tcxvoiceapp file .

  • Go to the 3CX management interface, under Call Queues . Create a new Call Queue, specify the name and extension of the Queue, and then set the Voice applications option and download the compiled file.
  • Save the changes to Call Queues. The voice application is ready to use.


Conclusion


Our application solves a specific problem, but it is important to note the ability to encapsulate a certain logic of work in a separate user component. This is a very powerful mechanism that offers several advantages:

  • Accelerate application development by reusing existing components.
  • Simplifying the structure of the main application and preventing the application architecture from expanding to a size that will already be difficult to manage.
  • Voice application is understandable and easily changeable.

Using the same principle, we can create custom components that lose time and dates, validate user input, etc.

Also popular now: