Gather

Gather

The gather command collects DTMF or speech input.

{
  "verb": "gather",
  "actionHook": "http://example.com/collect",
  "input": ["digits", "speech"],
  "bargein": true,
  "dtmfBargein": true,
  "finishOnKey": "#",
  "numDigits": 5,
  "timeout": 8,
  "recognizer": {
    "vendor": "Google",
    "language": "en-US",
    "hints": ["sales", "support"],
    "hintsBoost": 10
  },
  "say": {
    "text": "To speak to Sales, press 1 or say Sales. To speak to customer support, press 2 or say Support.",
    "synthesizer": {
      "vendor": "Google",
      "language": "en-US"
    }
  }
}

You can use the following attributes with the gather command:

Option Description Required
actionHook Webhook POST to invoke with the collected digits or speech. The payload will include a 'speech' or 'dtmf' property along with the standard attributes. See below for more detail. Yes
actionHookDelayAction Object, see here for details. No
bargein Allow speech barge-in; i.e., kill audio playback if the caller begins speaking. No
dtmfBargein Allow DTMF barge-in; i.e., kill audio playback if the caller enters DTMF. No
finishOnKey DTMF key that signals the end of input. No
input Array, specifying allowed types of input: ['digits'], ['speech'], or ['digits', 'speech']. Default: ['digits']. No
interDigitTimeout Amount of time to wait between digits after minDigits have been entered. No
listenDuringPrompt If false, do not listen for user speech until say or play has completed. Defaults to true. No
minBargeinWordCount If bargein is true, only kill speech when this many words are spoken. Defaults to 1. No
minDigits Minimum number of DTMF digits expected to gather. Defaults to 1. No
maxDigits Maximum number of DTMF digits expected to gather. No
numDigits Exact number of DTMF digits expected to gather. No
partialResultHook Webhook to send interim transcription results to. Partial transcriptions are only generated if this property is set. No
play Nested play command that can be used to prompt the user. No
fillerNoise Play audio to the caller while the remote application is processing gather transcriptions. See Using filler noise for more details. No
fillerNoise.enable Boolean, whether to enable or disable filler noise. Yes
fillerNoise.url HTTP(s) audio to play as filler noise. Yes
fillerNoise.startDelaySecs Integer value specifying the number of seconds to wait for a response from the remote application before playing filler noise (default: play immediately after sending results). No
recognizer Recognizer options. See recognizer for details. No

In the case of speech input, the actionHook payload will include a speech object with the response from Google Speech:

"speech": {
    "stability": 0,
    "is_final": true,
    "alternatives": [{
        "confidence": 0.858155,
        "transcript": "sales please"
    }]
}

In the case of digits input, the payload will simply include a digits property indicating the DTMF keys pressed:

"digits": "0276"

Note: An HTTP POST will be used for both the actionHook and the partialResultHook since the body may need to contain nested JSON objects for speech details.

Note: The partialResultHook web callback should not return content; any returned content will be discarded.

Ready To Get Started?