The <GetDigits> element collects digits that a caller enters into their phone keypad. When the caller is done entering data, Plivo submits that data to the provided ‘action’ URL in an HTTP GET or POST request.

If no input is received before timeout, <GetDigits> falls through to the next element.

You may optionally nest <Speak>, <Play> and <Wait>elements within a <GetDigits> element while waiting for input. This allows you to read menu options to the caller while letting them enter a menu selection at any time. After the first digit is received the audio will stop playing.

Element Attributes

The <GetDigits> element supports the following attributes that modify its behavior:

Attribute Name Allowed Values Default Value
action absolute URL none
method GET, POST POST
timeout positive integer 5 seconds
finishOnKey any digit, #, * #
numDigits integer >= 1 99
retries integer >= 1 1
playBeep true, false false
validDigits any digit, #, * 1234567890*#
invalidDigitsSound Any local .mp3 file none

Plivo will pass the following parameters to the ‘action’ URL once the input has been captured:

Parameter Description
Digits The digits the caller pressed, excluding the finishOnKey digit if used.

Examples

Example 1: Action/method and nested <Speak> or <Play> element

After the caller enters digits on the keypad, Plivo sends them in a request to the ‘action’ URL. We also add a nested <Speak> element. This means that input can be gathered at any time during <Speak>.

1
2
3
4
5
6
7
8
9
10
<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <GetDigits action="http://www.foo.com/process_gather.php" method="GET">
        <Speak>
            Please enter your 6-digit account number, 
            followed by the hash key
        </Speak>
    </GetDigits>
    <Speak>Input not received. Bye bye!</Speak>
</Response>
  • If the caller enters a digit during the speaking of the text, the <Speak> element will stop speaking and wait for digits, ‘#’ sign, or a timeout.
  • If <GetDigits> tag times out without input, the <Speak> element will complete and the <GetDigits> element will exit without submitting. Plivo will then process the next element in the document, which in this case is a <Speak> element which informs the caller that no input was received.
  • If the caller enters 123456 and then hits # or allows five seconds to pass, Plivo will submit the digits as a GET request to http://ww.foo.com/process_gather.php?Digits=123456.

Comments are closed.