<Gather>
Collect DTMF digits or speech from the caller.
Collects input from the caller and posts it to action. The nested <Say>/<Speak>, <Play> and <Pause> prompts play first; digits pressed during them are collected too. With DTMF (the default) input ends when numDigits digits are in, when the finishOnKey key is pressed, or timeout seconds after the prompts end (or after the first digit pressed during them) - timeout is the whole wait, not a gap between digits. The collected digits then go to action and the TinyML it returns replaces the rest of this document. If nothing was pressed and actionOnEmptyResult is not true, SIPRTC goes on with the verbs after <Gather> (and hangs up if there are none). With input=“speech”, SIPRTC runs speech recognition after the prompts and posts the result to action. Answers the call first if it is not answered yet. In conference waitUrl documents <Gather> is accepted but does not work (see the reference notes).
Examples
Section titled “Examples”<Response> <Gather action="https://example.com/menu" numDigits="1" timeout="6"> <Say>Press 1 for sales, 2 for support.</Say> </Gather> <Say>We did not receive any input. Goodbye.</Say></Response><Response> <Gather input="speech" language="en-GB" hints="billing,support" action="https://example.com/speech"> <Say>How can I help you today?</Say> </Gather></Response>Attributes
Section titled “Attributes”| Attribute | Values | Default | Description |
|---|---|---|---|
action |
An absolute http:// or https:// URL | — | URL that receives the input; the TinyML it returns continues the call. If omitted, the call’s current document URL is requested again. |
method |
GET, POST |
POST |
HTTP method for action. |
input |
dtmf, speech |
dtmf |
dtmf collects key presses; speech runs speech recognition instead. Only one kind per <Gather>: any value other than speech (including “dtmf speech”) collects DTMF. |
numDigits |
positive integer | 1 |
DTMF: stop after this many digits. Note the default is 1, so set it for anything longer than a single-key menu. |
finishOnKey |
string, matching [0-9*#]? |
# |
DTMF: the single key that ends input early. An empty value keeps #; input cannot be made to ignore every key. |
timeout |
positive integer | 5 |
DTMF: seconds to wait for input after the prompts end. |
actionOnEmptyResult |
true or false, in any letter case | false |
DTMF: when true, a timeout with no digits still requests action (with an empty Digits); when false, SIPRTC goes on with the verbs after <Gather>. |
language |
en-US, en-GB, en-AU, en-IN, en-IE, en-NZ, en-ZA, en-AB, en-WL, hi-IN, ar-AE, ar-BH, ar-DZ, ar-EG, ar-IL, ar-IQ, ar-JO, ar-KW, ar-LB, ar-LY, ar-MA, ar-OM, ar-PS, ar-QA, ar-SA, ar-SY, ar-TN, ar-YE |
en-US |
Speech: recognition language. |
hints |
string | — | Speech: comma-separated words or phrases to bias recognition towards (Azure engine). |
speechTimeout |
positive integer | platform default |
Speech: milliseconds to wait for the caller to start speaking (initial silence timeout, Azure engine). |
voiceMaxDuration |
positive integer | — | Speech: same setting as speechTimeout (milliseconds); if both are given the later one wins. |
startTimeout |
string | — | Accepted and ignored. Accepted; currently has no effect. |
midTimeout |
string | — | Accepted and ignored. Accepted; currently has no effect. |
endTimeout |
string | — | Accepted and ignored. Accepted; currently has no effect. |
voiceMode |
string | — | Accepted and ignored. Accepted; currently has no effect. |
Nested elements
Section titled “Nested elements”| Element | Description |
|---|---|
<Say> |
Prompt spoken while waiting for input. |
<Speak> |
Alias of <Say>. |
<Play> |
Audio prompt played while waiting for input. |
<Pause> |
Silence between prompts. |
Callback parameters
Section titled “Callback parameters”Sent to action:
| Parameter | Description |
|---|---|
Digits |
DTMF input: the keys pressed, including the finishOnKey key when it ended the input. Empty when nothing was pressed (only sent with actionOnEmptyResult=“true”). |
DtmfInputType |
DTMF input: always dtmf. |
SpeechResult |
Speech input: the recognised text. |
SpeechConfidence |
Speech input: recognition confidence, 0.00-1.00. |
- DTMF requests also carry the standard call parameters (CallSid, AccountSid, From, To, Direction, CallStatus, …). Speech requests carry CallSid, AccountSid, From and To.