gather@v4

Gather digits (DTMF) from the caller, optionally prompted by a text-to-speech (tts) or an audio file of your library (audioFile).

Versiongather@v4
Runs ininbound-call and your own branches

Parameters

NameTypeRequiredDefaultDescription
endOnKeystring"#"DTMF key that ends the gather
accepts ${{ }}
maxDigitsinteger0Maximum number of digits to collect: 0..30
accepts ${{ }}
timeoutnumber10Timeout in seconds: 1..60
accepts ${{ }}
stopOnTalkobjectStop action when talk is detected
accepts ${{ }}
stopOnTalk.enabledbooleanyesfalseaccepts ${{ }}
stopOnTalk.minWordsinteger21..30 · accepts ${{ }}
ttsobjectText-to-speech prompt: text (1 to 1024 characters), with an optional voice or language (exclusive). Without them, the defaults of the branch or of the scenario apply. text-to-speech prompt: text, and voice or language
audioFileobjectAn audio file of your library, by its SID (REST API v2 identifier). audio file of your library: sid

Every parameter that accepts ${{ }} can be computed from an expression.

How it works

Same as gather@v3, with the same parameters as play@v3: the prompt is tts (text-to-speech) or audioFile (audio file of your library). Set at most one of them: without any, the gather is silent. The first key pressed stops the prompt, the digits are still collected. The timeout also applies to the prompt: use a timeout longer than your audio file.

If you specify a maxDigits parameter, the gather will stop after the caller has pressed the specified number of digits. Otherwise, the gather will stop after the timeout, or when the caller presses the <endOnKey> key (default: #).

Examples

Short example with a text-to-speech prompt

- action: gather@v4
  params:
    maxDigits: 1
    tts:
      text: Hello! Press 1 to accept the call, press 2 to hangup
  result: $digits

Short example with an audio file prompt

The SID is the audio file identifier of the REST API v2 (8 lowercase characters) see: https://docs.callr.com/reference/audiofilesget

- action: gather@v4
  params:
    maxDigits: 1
    audioFile:
      sid: 'fdsanjkf' # quote it: an all-digit SID would be read as a number
  result: $digits

Full example with defaults

- action: gather@v4
  params:
    maxDigits: 0 # (0..30) 0 = disabled
    endOnKey: '#' # (string) key to stop the gather
    timeout: 10 # seconds (1..60)
    tts: # or audioFile: { sid: 'fdsanjkf' }, or none: silent
      text: Please enter your code # (1..1024 characters)
      # voice: en-US-AvaMultilingual # or language: en-US (default: the scenario defaults)
    stopOnTalk:
      enabled: false
      minWords: 2
  result: $digits

Result

Set result: $myVariable to keep it. Result of gather@v2, gather@v3 and gather@v4

FieldTypeDescription
okbooleantrue when digits were entered (or when the caller's speech stopped the prompt)
timeoutbooleantrue when the caller did not finish in time. input holds the digits entered so far
errorstringOnly present on error: hangup when the caller hung up, canceled, or the error message
inputstringDigits entered, never including the endOnKey
stoppedOnKeystringThe endOnKey pressed by the caller, empty otherwise
stoppedOnTalkbooleantrue when the caller's speech stopped the gathering (stopOnTalk)
recognizedstringText said by the caller when stoppedOnTalk is true, empty otherwise
{
  "ok": true,
  "timeout": false,
  "input": "1234",
  "stoppedOnKey": "#",
  "stoppedOnTalk": false,
  "recognized": ""
}

Older versions

Older versions keep working in existing scenarios. Use the version above in new scenarios.

  • gather@v3: Gather digits (DTMF) from the caller, prompted by an audio file (sid) or a text-to-speech (prompt)
  • gather@v2: Gather digits (DTMF) from the caller
  • gather@v1: Use gather@v2 instead gather@v1 is deprecated, use gather@v4

Did this page help you?