-
Notifications
You must be signed in to change notification settings - Fork 5
Collecting DTMF with interruptible message
This example is very similar to Collecting DTMF. Here, we will allow the user to type the number while the prompt is being played. This behaviour is also known as barge-in.
In order to do that, we use a diffent signature of the addPrompt
method. We use the one where you can specify a DtmfRecognition
:
Interaction interaction = interaction("get-dtmf")
.addPrompt(dtmfRecognition, new SpeechSynthesis("Type a number."))
.build(dtmfRecognition, Duration.seconds(5));
The DtmfRecognition
object is used twice in this statement. It is important to understand why:
- The fact that we specify a
DtmfRecognition
in theaddPrompt
method indicates that the user can perform input while the prompt is playing. - The fact that we specify a
DtmfRecognition
in thebuild
method indicates that the user can also perform input after the prompts are played.
You can download or browse the complete code for this example at GitHub.This is a complete working application that you can build and run for yourself.
You can also clone the Rivr Cookbook repository and checkout this example:
git clone -b barge-in-dtmf-interaction [email protected]:nuecho/rivr-cookbook.git
Then, to build and run it:
cd rivr-cookbook
./gradlew jettyRun
The VoiceXML dialogue should be available at http://localhost:8080/rivr-cookbook/dialogue
To stop the application, press Control-C in the console.