Gather
The Gather verb is used to collect digits for some period of time.
Text Content
There is no text content available to be set for the <Gather> verb.
Attributes
| Attribute | Description |
|---|---|
| gatherUrl | (optional) URL to send Gather event to and request new BXML. May be a relative URL. |
| gatherMethod | (optional) The HTTP method to use for the request to gatherUrl. GET or POST. Default value is POST. |
| gatherFallbackUrl | (optional) A fallback url which, if provided, will be used to retry the Gather event callback delivery in case gatherUrl fails to respond. |
| gatherFallbackMethod | (optional) The HTTP method to use to deliver the Gather event callback to gatherFallbackUrl. GET or POST. Default value is POST. |
| username | (optional) The username to send in the HTTP request to gatherUrl. |
| password | (optional) The password to send in the HTTP request to gatherUrl. |
| fallbackUsername | (optional) The username to send in the HTTP request to gatherFallbackUrl. |
| fallbackPassword | (optional) The password to send in the HTTP request to gatherFallbackUrl. |
| tag | (optional) A custom string that will be sent with this and all future callbacks unless overwritten by a future tag attribute or <Tag> verb, or cleared.May be cleared by setting tag=""Max length 256 characters. |
| terminatingDigits | (optional) When any of these digits are pressed, it will terminate the Gather. Default value is "", which disables this feature. |
| maxDigits | (optional) Max number of digits to collect. Default value is 50. Range: decimal values between 1 - 50. |
| interDigitTimeout | (optional) Time (in seconds) allowed between digit presses before automatically terminating the Gather. Default value is 5. Range: decimal values between 1 - 60. |
| firstDigitTimeout | (optional) Time (in seconds) to pause after any audio from nested <SpeakSentence> or <PlayAudio> verb is played (in seconds) before terminating the Gather. Default value is 5. Range: decimal values between 0 - 60. |
| repeatCount | (optional) The number of times the audio prompt should be played if no digits are pressed. For example, if this value is 3, the nested audio clip will be played a maximum of three times. The delay between repetitions will be equal to firstDigitTimeout. Default value is 1. repeatCount * number of verbs must not be greater than 20. |
| input | (optional) Specifies the input mode for the Gather verb. Accepted values are dtmf, speech, or dtmf_speech. Default value is dtmf. |
| hints | (optional) Possible and effective only if input value is speech or dtmf_speech. Words or phrases that help improve speech recognition. Useful for phrases with many words. Supported class tokens or keywords vary according to your provider and version. Default: None. |
| language | (optional) Possible and effective only if input value is speech or dtmf_speech. Language code for speech recognition. Supported languages depend on your chosen Supported Languages: - af-ZA: Afrikaans (South Africa) - am-ET: Amharic (Ethiopia) - ar-AE: Arabic (United Arab Emirates) - ar-BH: Arabic (Bahrain) - ar-DZ: Arabic (Algeria) - ar-EG: Arabic (Egypt) - ar-IL: Arabic (Israel) - ar-IQ: Arabic (Iraq) - ar-JO: Arabic (Jordan) - ar-KW: Arabic (Kuwait) - ar-LB: Arabic (Lebanon) - ar-MA: Arabic (Morocco) - ar-MR: Arabic (Mauritania) - ar-OM: Arabic (Oman) - ar-PS: Arabic (State of Palestine) - ar-QA: Arabic (Qatar) - ar-SA: Arabic (Saudi Arabia) - ar-TN: Arabic (Tunisia) - ar-YE: Arabic (Yemen) - as-IN: Assamese (India) - ast-ES: Asturian (Spain) - az-AZ: Azerbaijani (Azerbaijan) - az-AZ: Azerbaijani (Azerbaijani) - be-BY: Belarusian (Belarus) - bg-BG: Bulgarian (Bulgaria) - bn-BD: Bengali (Bangladesh) - bn-IN: Bengali (India) - bs-BA: Bosnian (Bosnia and Herzegovina) - bs-BA: Bosnian (Bosnia and Herzgovina) - ca-ES: Catalan (Spain) - ceb-PH: Cebuano (Philippines) - ckb-IQ: Central Kurdish (Iraq) - cmn-Hans-CN: Chinese, Mandarin (Simplified, China) - cmn-Hans-CN: Chinese (Simplified, China) - cmn-Hans-HK: Chinese, Mandarin (Simplified, Hong Kong) - cmn-Hant-TW: Chinese, Mandarin (Traditional, Taiwan) - cs-CZ: Czech (Czech Republic) - cy-GB: Welsh (United Kingdom) - da-DK: Danish (Denmark) - de-AT: German (Austria) - de-CH: German (Switzerland) - de-CH: German (Switzerland) - Note: supported only in Gather 2.0 - de-DE: German (Germany) - el-GR: Greek (Greece) - en-AU: English (Australia) - en-CA: English (Canada) - en-GB: English (United Kingdom) - en-GH: English (Ghana) - en-HK: English (Hong Kong) - en-IE: English (Ireland) - en-IN: English (India) - en-KE: English (Kenya) - en-NG: English (Nigeria) - en-NZ: English (New Zealand) - en-PH: English (Philippines) - en-PK: English (Pakistan) - en-SG: English (Singapore) - en-TZ: English (Tanzania) - en-US: English (United States) - en-ZA: English (South Africa) - es-419: Spanish (Latin American) - es-AR: Spanish (Argentina) - es-BO: Spanish (Bolivia) - es-CL: Spanish (Chile) - es-CO: Spanish (Colombia) - es-CR: Spanish (Costa Rica) - es-DO: Spanish (Dominican Republic) - es-EC: Spanish (Ecuador) - es-ES: Spanish (Spain) - es-GT: Spanish (Guatemala) - es-HN: Spanish (Honduras) - es-MX: Spanish (Mexico) - es-NI: Spanish (Nicaragua) - es-PA: Spanish (Panama) - es-PE: Spanish (Peru) - es-PR: Spanish (Puerto Rico) - es-PY: Spanish (Paraguay) - es-SV: Spanish (El Salvador) - es-US: Spanish (United States) - es-UY: Spanish (Uruguay) - es-VE: Spanish (Venezuela) - et-EE: Estonian (Estonia) - eu-ES: Basque (Spain) - fa-IR: Persian (Iran) - ff-SN: Fulah (Senegal) - fi-FI: Finnish (Finland) - fil-PH: Filipino (Philippines) - fr-BE: French (Belgium) - fr-CA: French (Canada) - fr-CH: French (Switzerland) - fr-FR: French (France) - ga-IE: Irish (Ireland) - gl-ES: Galician (Spain) - gu-IN: Gujarati (India) - ha-NG: Hausa (Nigeria) - hi-IN: Hindi (India) - hr-HR: Croatian (Croatia) - hu-HU: Hungarian (Hungary) - hy-AM: Armenian (Armenia) - id-ID: Indonesian (Indonesia) - ig-NG: Igbo (Nigeria) - is-IS: Icelandic (Iceland) - it-CH: Italian (Switzerland) - it-IT: Italian (Italy) - iw-IL: Hebrew (Israel) - Note: not supported in Google's v2 STT global APIs - iw-IL: Hebrew (Israel) - ja-JP: Japanese (Japan) - jv-ID: Javanese (Indonesia) - ka-GE: Georgian (Georgia) - kam-KE: Kamba (Kenya) - kea-CV: Kabuverdianu (Cape Verde) - kk-KZ: Kazakh (Kazakhistan) - kk-KZ: Kazakh (Kazakhstan) - km-KH: Khmer (Cambodia) - km-KH: Khmer (Cambodian) - kn-IN: Kannada (India) - ko-KR: Korean (South Korea) - ky-KG: Kyrgyz (Cyrillic) - lb-LU: Luxembourgish (Luxembourg) - lg-UG: Ganda (Uganda) - ln-CD: Lingala (Congo-Kinshasa) - lo-LA: Lao (Laos) - lt-LT: Lithuanian (Lithuania) - luo-KE: Luo (Kenya) - lv-LV: Latvian (Latvia) - mi-NZ: Maori (New Zealand) - mk-MK: Macedonian (North Macedonia) - ml-IN: Malayalam (India) - mn-MN: Mongolian (Mongolia) - mr-IN: Marathi (India) - ms-MY: Malay (Malaysia) - mt-MT: Maltese (Malta) - my-MM: Burmese (Myanmar) - nb-NO: Norwegian Bokmål (Norway) - ne-NP: Nepali (Nepal) - nl-BE: Dutch (Belgium) - nl-NL: Dutch (Netherlands) - no-NO: Norwegian Bokmål (Norway) - nso-ZA: Sepedi (South Africa) - ny-MW: Nyanja (Malawi) - oc-FR: Occitan (France) - om-ET: Oromo (Ethiopia) - or-IN: Oriya (India) - pa-Guru-IN: Punjabi (Gurmukhi India) - pa-guru-IN: Punjabi (Gurmukhi India) - pl-PL: Polish (Poland) - ps-AF: Pashto - pt-BR: Portuguese (Brazil) - pt-PT: Portuguese (Portugal) - ro-RO: Romanian (Romania) - ru-RU: Russian (Russia) - rup-BG: Aromanian (Bulgaria) - rw-RW: Kinyarwanda (Rwanda) - sd-IN: Sindhi (India) - si-LK: Sinhala (Sri Lanka) - sk-SK: Slovak (Slovakia) - sl-SI: Slovenian (Slovenia) - sn-ZW: Shona (Zimbabwe) - so-SO: Somali - sq-AL: Albanian (Albania) - sr-RS: Serbian (Serbia) - ss-Latn-ZA: Swati (Latin, South Africa) - st-ZA: Southern Sotho (South Africa) - su-ID: Sundanese (Indonesia) - sv-SE: Swedish (Sweden) - sw: Swahili - sw-KE: Swahili (Kenya) - sw-TZ: Swahili (Tanzania) - ta-IN: Tamil (India) - ta-LK: Tamil (Sri Lanka) - ta-MY: Tamil (Malaysia) - ta-SG: Tamil (Singapore) - te-IN: Telugu (India) - tg-TJ: Tajik (Tajikistan) - th-TH: Thai (Thailand) - tn-Latn-ZA: Tswana (Latin, South Africa) - tr-TR: Turkish (Turkey) - ts-ZA: Tsonga (South Africa) - uk-UA: Ukrainian (Ukraine) - umb-AO: Umbundu (Angola) - ur-IN: Urdu (India) - ur-PK: Urdu (Pakistan) - uz-UZ: Uzbek (Uzbekistan) - ve-ZA: Venda (South Africa) - vi-VN: Vietnamese (Vietnam) - wo-SN: Wolof (Senegal) - xh-ZA: Xhosa (South Africa) - yo-NG: Yoruba (Nigeria) - yue-Hant-HK: Chinese, Cantonese (Traditional, Hong Kong) - yue-Hant-HK: Chinese, Cantonese (Traditional Hong Kong) - zu-ZA: Zulu (South Africa) |
| partialResultCallback | (optional) Possible and effective only if input value is speech or dtmf_speech. URL to send Partial Result event to. May be a relative URL. |
| partialResultCallbackMethod | (optional) Possible and effective only if input value is speech or dtmf_speech. The HTTP method to use for the request to partialResultCallback. GET or POST. Default value is POST. |
| profanityFilter | (optional) Possible and effective only if input value is speech or dtmf_speech. Enables or disables filtering of profane words. Accepted values: true, false. Default value is true. |
| speechModel | (optional) Possible and effective only if input value is speech or dtmf_speech. Specifies the speech recognition model to use. Options include:Generic: default, numbers_and_commands, phone_call, experimental_conversations, experimental_utterancesGoogle STT V2: googlev2_long, googlev2_short, googlev2_telephony, googlev2_telephony_short |
| speechTimeout | (optional) Possible and effective only if input value is speech or dtmf_speech. Time (in seconds) to wait for speech input before timing out. Accepted values: any positive integer. Default value is 5. |
The gather is terminated when one of these conditions is met:
- The user presses a terminating digit (if specified)
- 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
maxDigitsdigits - The final transcription result is received if
inputis set tospeechordtmf_speech
If the gatherUrl attribute is specified, the Gather event is sent to the gatherUrl upon
completion of the gather. BXML returned by that callback are then executed. If gatherUrl is specified, verbs following the <Gather> will be ignored.
If no gatherUrl attribute is specified, the gathered digits/text are discarded and execution of verbs following the <Gather> continues.
Nestable Verbs
The following verbs may be nested inside of a <Gather> tag. If using a repeat count of one, up to 20 verbs can be nested. Refer to repeatCount attribute if using a value greater than 1.
| Verb | Description |
|---|---|
| SpeakSentence | (optional/) Using the SpeakSentence inside the Gather verb will speak the text until a digit is received. |
| PlayAudio | (optional/) Using the PlayAudio inside the Gather verb will play the media until a digit is received. |
Webhooks Received
| Callback | Can reply with more BXML |
|---|---|
| Gather | Yes |
Examples
Simple gather
- XML
- Java
- C#
- Ruby
- NodeJS
- Python
- PHP
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather gatherUrl="https://gather.url/nextBXML" firstDigitTimeout="10" terminatingDigits="#">
<SpeakSentence voice="kate">Please press a digit.</SpeakSentence>
</Gather>
</Response>
SpeakSentence speakSentence = new SpeakSentence("Please press a digit.").builder()
.locale(TtsLocale.EN_UK)
.gender(TtsGender.FEMALE)
.build();
Gather gather = new Gather().builder()
.gatherUrl("https://gather.url/nextBxml")
.terminatingDigits("#")
.firstDigitTimeout(10d)
.children(List.of(speakSentence))
.build();
Response response = new Response()
.with(gather);
System.out.println(response.toBXML());
SpeakSentence speakSentence = new SpeakSentence
{
Sentence = "Please press a digit.",
Voice = "kate"
};
Gather gather = new Gather
{
GatherUrl = "https://gather.url/nextBXML",
TerminatingDigits = "#",
FirstDigitTimeout = 10,
SpeakSentence = speakSentence
};
Response response = new Response();
response.Add(gather);
Console.WriteLine(response.ToBXML());
speak_sentence = Bandwidth::Bxml::SpeakSentence.new('Please press a digit.', { voice: 'kate' })
gather = Bandwidth::Bxml::Gather.new([speak_sentence], {
gather_url: 'https://gather.url/nextBXML',
terminating_digits: '#',
first_digit_timeout: 10
})
response = Bandwidth::Bxml::Response.new([gather])
p response.to_bxml
const speakSentence = new Bxml.SpeakSentence('Please press a digit.', {
voice: 'kate'
});
const gather = new Bxml.Gather(
{
gatherUrl: 'https://gather.url/nextBXML',
terminatingDigits: '#',
firstDigitTimeout: 10
},
[speakSentence]
);
const response = new Bxml.Response(gather);
console.log(response.toBxml());
speak_sentence = SpeakSentence(
text="Please press a digit.",
voice="kate"
)
gather = Gather(
gather_url="https://gather.url/nextBXML",
terminating_digits="#",
first_digit_timeout=10
audio_verbs=[speak_sentence]
)
response = Response()
response.add_verb(gather)
print(response.to_bxml())
$speakSentence = new BandwidthLib\Voice\Bxml\SpeakSentence("Please press a digit.");
$speakSentence->voice("kate");
$gather = new BandwidthLib\Voice\Bxml\Gather();
$gather->gatherUrl("https://gather.url/nextBXML");
$gather->terminatingDigits("#");
$gather->firstDigitTimeout(10);
$gather->speakSentence($speakSentence);
$response = new BandwidthLib\Voice\Bxml\Response();
$response->addVerb($gather);
echo $response->toBxml();
Gather with Repeated Audio Prompt
- XML
- Java
- C#
- Ruby
- NodeJS
- Python
- PHP
<Response>
<Gather gatherUrl="https://gather.url/nextBXML" repeatCount="5" maxDigits="1">
<SpeakSentence>I am going to keep asking you to press a digit.</SpeakSentence>
</Gather>
</Response>
SpeakSentence speakSentence = new SpeakSentence("I am going to keep asking you to press a digit.");
Gather gather = new Gather().builder()
.gatherUrl("https://gather.url/nextBxml")
.repeatCount(5)
.maxDigits(1)
.children(List.of(speakSentence))
.build();
Response response = new Response()
.with(gather);
System.out.println(response.toBXML());
SpeakSentence speakSentence = new SpeakSentence
{
Sentence = "I am going to keep asking you to press a digit."
};
Gather gather = new Gather
{
GatherUrl = "https://gather.url/nextBXML",
RepeatCount = 5,
MaxDigits = 1,
SpeakSentence = speakSentence
};
Response response = new Response();
response.Add(gather);
Console.WriteLine(response.ToBXML());
speak_sentence = Bandwidth::Bxml::SpeakSentence.new('I am going to keep asking you to press a digit.')
gather = Bandwidth::Bxml::Gather.new([speak_sentence], {
gather_url: 'https://gather.url/nextBXML',
repeat_count: 5,
max_digits: 1
})
response = Bandwidth::Bxml::Response.new([gather])
p response.to_bxml
const speakSentence = new Bxml.SpeakSentence(
'I am going to keep asking you to press a digit.'
);
const gather = new Bxml.Gather(
{
gatherUrl: 'https://gather.url/nextBXML',
repeatCount: 5,
maxDigits: 1
},
[speakSentence]
);
const response = new Bxml.Response(gather);
console.log(response.toBxml());
speak_sentence = SpeakSentence(
text="I am going to keep asking you to press a digit."
)
gather = Gather(
gather_url="https://gather.url/nextBXML",
repeat_count=5,
max_digits=1,
audio_verbs=[speak_sentence]
)
response = Response()
response.add_verb(gather)
print(response.to_bxml())
$speakSentence = new BandwidthLib\Voice\Bxml\SpeakSentence("I am going to keep asking you to press a digit.");
$gather = new BandwidthLib\Voice\Bxml\Gather();
$gather->gatherUrl("https://gather.url/nextBXML");
$gather->repeatCount(5);
$gather->maxDigits(1);
$gather->speakSentence($speakSentence);
$response = new BandwidthLib\Voice\Bxml\Response();
$response->addVerb($gather);
echo $response->toBxml();
Gather with Multiple Nested Verbs
- XML
- Java
- C#
- Ruby
- NodeJS
- Python
- PHP
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather gatherUrl="https://gather.url/nextBXML">
<SpeakSentence>First Sentence.</SpeakSentence>
<PlayAudio>https://audio.url/audio1.wav</PlayAudio>
<PlayAudio>https://audio.url/audio2.mp3</PlayAudio>
<SpeakSentence>Second Sentence.</SpeakSentence>
</Gather>
</Response>
SpeakSentence speakSentence = new SpeakSentence("First sentence.");
SpeakSentence speakSentence2 = new SpeakSentence("Second sentence.");
PlayAudio playAudio = new PlayAudio().builder()
.audioUri("https://audio.url/audio1.wav")
.build();
PlayAudio playAudio2 = new PlayAudio().builder()
.audioUri("https://audio.url/audio2.mp3")
.build();
Gather gather = new Gather().builder()
.gatherUrl("https://gather.url/nextBxml")
.children(List.of(speakSentence, playAudio, speakSentence2, playAudio2))
.build();
Response response = new Response()
.with(gather);
System.out.println(response.toBXML());
Gather gather = new Gather
{
GatherUrl = "https://gather.url/nextBXML",
AudioProducers = new List<IAudioProducer>(){
new SpeakSentence
{
Sentence = "First Sentence."
},
new PlayAudio
{
Url = "https://audio.url/audio1.wav"
},
new PlayAudio
{
Url = "https://audio.url/audio2.mp3"
},
new SpeakSentence
{
Sentence = "Second Sentence."
}
}
};
Response response = new Response();
response.Add(gather);
Console.WriteLine(response.ToBXML());
speak_sentence_1 = Bandwidth::Bxml::SpeakSentence.new('First Sentence.')
play_audio_1 = Bandwidth::Bxml::PlayAudio.new('https://audio.url/audio1.wav')
play_audio_2 = Bandwidth::Bxml::PlayAudio.new('https://audio.url/audio2.mp3')
speak_sentence_2 = Bandwidth::Bxml::SpeakSentence.new('Second Sentence.')
gather = Bandwidth::Bxml::Gather.new([speak_sentence_1, play_audio_1, play_audio_2, speak_sentence_2], {
gather_url: 'https://gather.url/nextBXML'
})
response = Bandwidth::Bxml::Response.new([gather])
p response.to_bxml
const speakSentence1 = new Bxml.SpeakSentence('First Sentence.');
const playAudio1 = new Bxml.PlayAudio('https://audio.url/audio1.wav');
const playAudio2 = new Bxml.PlayAudio('https://audio.url/audio2.mp3');
const speakSentence2 = new Bxml.SpeakSentence('Second Sentence.');
const gather = new Bxml.Gather(
{
gatherUrl: 'https://gather.url/nextBXML'
},
[speakSentence1, playAudio1, playAudio2, speakSentence2]
);
const response = new Bxml.Response(gather);
console.log(response.toBxml());
speak_sentence_1 = SpeakSentence(
text="First Sentence."
)
play_audio_1 = PlayAudio(
audio_uri="https://audio.url/audio1.wav"
)
play_audio_2 = PlayAudio(
audio_uri="https://audio.url/audio2.mp3"
)
speak_sentence_2 = SpeakSentence(
text="Second Sentence."
)
gather = Gather(
gather_url="https://gather.url/nextBXML",
audio_verbs=[speak_sentence_1, play_audio_1, play_audio_2, speak_sentence_2]
)
response = Response()
response.add_verb(gather)
print(response.to_bxml())
$speakSentence1 = new BandwidthLib\Voice\Bxml\SpeakSentence("First Sentence.");
$playAudio1 = new BandwidthLib\Voice\Bxml\PlayAudio("https://audio.url/audio1.wav");
$playAudio2 = new BandwidthLib\Voice\Bxml\PlayAudio("https://audio.url/audio2.mp3");
$speakSentence2 = new BandwidthLib\Voice\Bxml\SpeakSentence("Second Sentence.");
$gather = new BandwidthLib\Voice\Bxml\Gather();
$gather->gatherUrl("https://gather.url/nextBXML");
$gather->speakSentence($speakSentence1);
$gather->playAudio($playAudio1);
$gather->playAudio($playAudio2);
$gather->speakSentence($speakSentence2);
$response = new BandwidthLib\Voice\Bxml\Response();
$response->addVerb($gather);
echo $response->toBxml();