In this guide we will show you how to collect digits inputted by a user on their phone’s keypad for a period of time. Please ensure you have followed our earlier guide on how to make an outbound call with Bandwidth.
You can gather a user’s input to create an interactive voice response (IVR) system.
<Gather> verb is used to collect digits inputted by the user.
The gather is terminated when one of these conditions is met:
- The user presses any one of the
- The user has pressed at least one key and more than
interDigitTimeoutseconds have elapsed
- Any nested audio has ended and
firstDigitTimeoutseconds have elapsed without the user pressing any digits
- The user presses
- If the
gatherUrlattribute is specified, the Gather event is sent to the
gatherUrlupon completion of the gather. BXML returned by that callback are then executed. If
gatherUrlis specified, verbs following the
<Gather>will be ignored.
/digitsCallback should return:
The above number prompts the caller to input a number, after which the gather ends and a
<SpeakSentence> says the pressed number back to the caller.
To further enhance your IVR system, additional verbs can be nested inside of a
<Gather> tag. These include playing media and text to speech. In this new example, the sentence "Please press a digit" will be said at the start of the call and after each press, instead of only at the beginning of the call.
Now that you have learnt how to build an IVR tree, check out some of the available actions in the following guides: