3CX Voice Application Designer (VAD) is a tool that allows 3CX users to easily create voice applications. Using the predefined functional blocks, you can easily design the call flow graphically, without requiring any programming skills. This article will illustrate how to create a voice application which reads out a sequence of numbers that have been pressed by the caller.
Many times, we are faced with the need to read out a sequence of numbers. For example, we need to request a number using DTMF and ask the user to confirm the number that has been inserted by reading the number back to him. We will use this example to illustrate how to create an application using VAD to do this:
- VAD: Please, enter your customer code.
- The user enters 1234 using the key pad.
- VAD: The customer code entered is 1234. To confirm press 1, to re-enter press 2.
Since the reproduction of digits may be something that is required in different parts of the application, that functionality should be encapsulated in a custom component. VAD can create custom components that can then be reused in different parts of the application.
In this article, we’ll show how to create a custom component to reproduce digits, and how to use that custom component in another part of the application – in this case in the main call flow. To do this, we need to follow these steps: Step 1: Create a custom component, which loops through the digits and plays them back to the user. Step 2: Add the component to the main call flow. Step 3: Build the new voice application and deploy it to 3CX Phone System. Let’s get started!
Step 1: Creating the Custom Component
The component that we need to create must be able to receive the sequence of digits as input, and play them one by one. Proceed as follows:
- From 3CX Voice Application Designer, create a new project.
- From Project Explorer, right click on the name of the project, and select New Component.
- Change the name of the new component to “PlayDigits”.
- Double Click on the new custom component “PlayDigits.comp”.
- From the Properties window, open the “Variables” Collection by clicking the button on the right of the “Variables” item.
- Add two variables called “Digits” and “Index”. The Digits variable will be accepting the digits form the user, so this component knows what digits need to be reproduced. The Index variable is internal and allows the component to iterate through the digits. Proceed as follows”
- Click the “Add” button to add a new variable.
- Change the Name property of the new variable to “Digits”.
- The Digits variable should have the following properties:
- Accessibility: ReadWrite
- Initial Value: <blank>
- Scope: Public
- Click the “Add” button to add another variable.
- Change the Name property of the new variable to “Index”.
- The Index variable should have the following properties:
- Accessibility: ReadWrite
- Initial Value: 0
- Scope: Private
- When done, press “OK” to save the changes.
Now that we have created the custom component, we need to design the component. For this, we need a component of type “Loop” to iterate the sequence of numbers. In the “Loop” component, we will add a component of type “Prompt Playback” to play the number in the iteration. Within the same loop, we also need another component of type “Increment Variable” to increase the Index variable we created earlier. This will allow the loop to iterate through all the numbers inputted by the user. Let’s see how this is done in more detail:
Create the Loop
- From “Components”, drag a “Loop” component to the “Call Flow”.
- From the “Properties” window, change the name of the Loop component to “digitsLoop”.
- Keeping the “digitsLoop” component selected, change the Condition property to: LESS_THAN(callflow$.Index,LEN(callflow$.Digits)).
- This condition property will cause the loop to continue iterating as long as Index (callflow$.Index) is less than the length of the sequence of numbers LEN(callflow$.Digits).
Create the Prompt Playback
- Before you create the PromptPlayback component, you need to copy prompts which will be used to the Audio folder of the project with the corresponding name. Thus for example the prompt “0” should be called 0.wav, “1” should be called 1.wav. this should be done for all numbers between 0 and 9.
- Back to the project, from “Components”, drag a “Prompt Playback” component to the “Loop”.
- Change the name property of the “Prompt Playback” component to “playDigit”.
- Keeping the “playDigit” component selected, open the “Prompts Collection” from the properties window.
- Click on the arrow next to the “Add” button, and select to add a “DynamicAudioFilePrompt”.
- Change the “AudioFileName” of the new “Dynamic Audio File Prompt” member, to: CONCATENATE(MID(callflow$.Digits,callflow$.Index,1),’.wav’).
- This will cause the “Prompt Playback” component to retrieve the wav file for the digit that needs to be read out.
- Click “OK” when done.
Create the Increment Variable Component
- From “Components”, drag an “Increment Variable” component underneath the “playDigit” component.
- Change the name of the “Increment Variable” to “incrementIndex”.
- Change the “VariableName” property to “callflow$.index”.
The following screenshot shows the end result: We have the component ready. Now we just need to invoke it from the main flow.
Step 2: Invoking the Component to Reproduce Digits
Now that we have the component that allows us to play a sequence of numbers, we can use it into our application. Proceed as follows:
- Open the main call flow by double clicking on the item “Main.flow” in the “Project Explorer”.
- Add a component of type “User Input” to request some digits from the user.
- In the “Valid Input” branch, add a “PlayDigits” component from the User Defined Components – this is an instance of the component that we have just created.
- Change the name of the “PlayDigits” component to “playEnteredDigits”.
- Keeping the “playEnteredDigits” component selected, change the Digits property to: “requestInput.Buffer”.
This indicates that that the digits to be played are to be retrieved from the digits buffer, which are the digits pressed by the user. You should see something like the following:
Step 3: Build and Deploy to 3CX Phone System
Now that the project is ready, you can build it from the Build menu. There are three different build options:
- Debug Build: builds only the debug configuration. When you deploy this build, you can debug real calls to the callflow of the application.
- Release Build: builds only the release configuration. Use this build for production environment, because it is more performant than the debug build.
- Build All: builds both debug and release configurations.
After building the project with success, you can deploy it to 3CX Phone System. To do this, go to the menu option “Build” > “Deploy” and the deployment dialog will appear. Here you can select the configuration to deploy (debug or release) and perform the deployment by clicking the “Deploy” button. If you’re deploying the project to a different machine (remote deployment), i.e. 3CX Phone System is installed in another PC, then you will need to change the 3CX Phone System configuration files to allow remote access to the configuration service. The user manual explains how to do this in detail.
In addition to the specific problem solved by this example, we should also note how certain common behaviors into an application can be encapsulated within a user-defined component. This is a very powerful concept that gives us several benefits:
- It allows the development of applications faster by having reusable blocks.
- Simplifies the design of the main callflow, and avoids that the drawing grows to a point where it becomes unmanageable.
- Makes the application easier to understand and maintain.
By extending this concept we can create reusable components that allow, for example, playing dates, playing hours, perform the validation of user input in a generic way, and so on.