IVR module basics
The IVR module is a helper module to provide your apps with IVR functionality. Of course, you implement IVR functionality on a lower level via the Call.say, Call.startPlayback, and Call.handleTones methods, but this module gives you more straightforward approach.
To use the IVR module, add the following line to your scenario code:
require(Modules.IVR);
You can use all this module's functions, events, and classes only after this line.
This module supports 4 types of IVR states:
- Prompt with no input:
The nextState property defines the state that IVR transits to after the prompt is played successfully. If it is not specified, the onInputComplete callback is invoked.
- Selection menu. Specify voice prompts and next states to transit for each specific input:
In this example, if a customer presses 1 or 2, IVR proceeds to the state2, and if one presses 0, state1 loops. Pay attention to the last line — you can find more information in the IVRSettings API reference.
- Fixed length input. You can use it if you the need user to enter, for example, an extension number and you know the exact length of desired input.
- Variable length input. You can use it when you do not know how many digits need to be entered. In this case, the data input needs to be finished by pressing a button, for example, "#":
An alternative variant is to check input every time the user presses any digit and see if it is suitable. For example, the input may be considered correct when the user presses the same digits 2 times in a row:
Here is an IVR example that prompts the customer for a 3-digit extension number. On timeout route call to queue, on success call a local user:
Refer to the Building an IVR article for a complete step-by-step guide on how to build an IVR.