playAndCollect
Play audio content as a prompt and simultaneously collect user input via DTMF
digits or speech recognition. Returns a
CollectAction that resolves when
input is collected, the operation times out, or an error occurs.
The CollectAction resolves only on collect events, not on play events. This
means await action.wait() blocks until the user provides input (or the
operation terminates), not when the audio finishes playing.
This method emits calling.call.collect events. See Call Events for payload details.
Parameters
media
Array of media items to play as the prompt. Same format as
play() media items.
collect
Input collection configuration.
collect.digits
DTMF digit collection settings.
collect.digits.max
Maximum number of digits to collect.
collect.digits.digit_timeout
Seconds to wait between digits before completing.
collect.digits.terminators
Characters that terminate digit collection (e.g., "#").
collect.speech
Speech recognition settings.
collect.speech.end_silence_timeout
Seconds of silence to wait before finalizing speech input.
collect.speech.speech_timeout
Maximum seconds to listen for speech.
collect.speech.language
Speech recognition language code (e.g., "en-US").
collect.speech.hints
Words or phrases to boost recognition accuracy.
volume
Volume adjustment in dB for the prompt audio.
controlId
Custom control ID. Auto-generated if not provided.
onCompleted
Callback invoked when collection completes.
Returns
Promise<CollectAction> — An action handle with
stop(), volume(), startInputTimers(), and wait() methods.