Using the Loop Component to Navigate Upwards

Introduction

We are often asked how to use the Loop component to repeat the options in a menu, or navigate to an upper level menu. Creating such a Call Flow with the 3CX Call Flow Designer is quite simple, although some considerations should be kept in mind.

💡 Tip: The project for this example application is available via the CFD Demos GitHub page, and is installed along with the 3CX Call Flow Designer in your Windows user documents folder, i.e. “C:\Users\YourUsername\Documents\3CX Call Flow Designer Demos”.

For this demonstration, we will create an application with 2-level menus, represented in the following tree:

Sample call flow tree

Step 1: Create the Project

First, we need to create a new project. Open the CFD and go to “File” > “New” > “Callflow Project”, select the folder where you want to save it, and enter a name for the project, e.g. LoopMenuDemo.

Step 2: Add the Menu component for the Main Menu

Let’s add a Menu component and configure the options we need:

  1. Drag a “Menu” component from the toolbox, and drop it into the design surface of the “Main” callflow. Then select the component added, go to the “Properties Window” and rename it to “MainMenu”.

Example of the main menu

  1. Double-click on the “Menu” component to configure these properties:
  • “Initial Prompts” - configure with a WAV file inviting the user to select an option, e.g. “This is the Main Menu. To play a message press 1, to repeat this menu press 2, to go to a sub menu press 3”. As part of the prompt, we’re explaining that we’re on the main menu, so it’s clear where we are while testing.
  • “Subsequent Prompts” - set a WAV file that gives more detailed information on what the user needs to enter, as this message is only played when the user entered invalid or no digits. E.g. “This is the Main Menu. Please enter a valid option. To play a message press 1, to repeat this menu press 2, to go to a sub menu press 3”.
  • “Timeout Prompts” - set a WAV file that explains that no digit was detected, e.g. “Sorry, we didn’t receive any digit”.
  • “Invalid Digit Prompts” - use a WAV file that explains that the digit entered is invalid, e.g. “Sorry, the selected option is not valid”.
  • Configure the remaining options as in the above example.
  1. Press “OK” to save the changes.

Step 3: Add the Loop component around the menu

In a CFD callflow, components are executed from top to bottom. The only exception is the Loop component, which executes all the components inside the loop while a condition is met. Then, the logic we need to apply here is the following:

The loop component

  1. Define a boolean variable, name it “ContinueLoopingMainMenu”, and set the initial value to true.

Main loop condition

  1. Set the Loop Condition to this variable, so the first time it is evaluated, the condition is met, and the components inside the Loop are executed.

Main loop variable name

  1. Change the boolean variable to false.
  2. Use the Menu component to offer some options.

Main loop call flow sample

  1. When the user selects the option to repeat the menu, set the boolean variable to true again.

In this way, when the option to repeat the menu is selected, the variable will be set to true, and when the Loop evaluates the condition again, it will continue iterating.

Step 4: Repeat the procedure for the sub menu

For the sub menu we will follow a very similar procedure:

Sub menu example

  1. Define a boolean variable, name it “ContinueLoopingSubMenu”, and set the initial value to true. Also, use the Assign a Variable component to set this value to true, so we’re sure that the variable is true before entering the loop, even after sub menu iterations.

Sub menu variable assigned

  1. Add a second Loop component inside the Option 3 branch, and set the Loop Condition to this variable, so the first time it is evaluated, the condition is met, and the components inside the Loop are executed.
  2. Change the boolean variable to false.
  3. Add a second Menu component for the Sub Menu, with 3 options enabled, and configure the prompts for it.
  4. When the user selects the option to repeat the sub menu, set the boolean variable “ContinueLoopingSubMenu” to true again.
  5. When the user selects the option to go back to the main menu, set the boolean variable “ContinueLoopingMainMenu” to true.

This is how the callflow should like like after doing the changes mentioned above:

Call flow example with menu and sub menu

Step 5: Build and Deploy to 3CX Phone System

The project is ready to build and upload to our 3CX Phone System server, with these steps:

  1. Select “Build” > “Build All” and the CFD generates the file “LoopMenuDemo.zip”.
  2. Go to the “3CX Management Console” > “Advanced” > “Call Flow Apps” > “Add/Update”, and upload the ZIP file generated by the CFD in the previous step.
  3. The Call Flow app is ready to use. Make a call to the application, select the options and navigate through these 2 nested menus.

See Also

Last Updated
This document was last updated on 29th April 2021
https://www.3cx.com/docs/cfd-navigate-upwards/