For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
GuidesReference
GuidesReference
    • Core
      • Overview
    • Agents
      • Overview
      • AgentBase
      • AgentServer
      • Configuration
      • ContextBuilder
      • DataMap
      • FunctionResult
      • Helper Functions & Utilities
      • LiveWire
      • PomBuilder
      • Prefabs
      • SkillBase
      • SkillManager
      • SkillRegistry
      • Skills
      • SwaigFunction
      • SwmlBuilder
      • SWMLService
    • RELAY
      • Overview
      • Actions
      • Call
        • ai
        • aiHold
        • aiMessage
        • aiUnhold
        • amazonBedrock
        • answer
        • bindDigit
        • clearDigitBindings
        • collect
        • connect
        • denoise
        • denoiseStop
        • detect
        • disconnect
        • echo
        • hangup
        • hold
        • joinConference
        • joinRoom
        • leaveConference
        • leaveRoom
        • liveTranscribe
        • liveTranslate
        • on
        • pass
        • pay
        • play
        • playAndCollect
        • queueEnter
        • queueLeave
        • receiveFax
        • record
        • refer
        • sendDigits
        • sendFax
        • stream
        • tap
        • transfer
        • unhold
        • userEvent
        • waitFor
        • waitForEnded
      • Constants
      • Events
      • Message
      • RelayClient
      • RelayError
    • REST Client
      • Overview
      • Addresses
      • Calling
      • ChatResource
      • Compat
      • Datasphere
      • Fabric
      • ImportedNumbersResource
      • Logs
      • LookupResource
      • MFA
      • Number Groups
      • Phone Numbers
      • Project
      • PubSubResource
      • Queues
      • Recordings
      • Registry
      • RestClient
      • RestError
      • Short Codes
      • SIP Profile
      • Verified Callers
      • Video
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • Parameters
  • Returns
  • Example
RELAYCall

collect

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

connect

Next
Built with

Collect DTMF digit or speech input without playing a prompt. Use this when you want to listen for input silently or after a prompt has already been played separately. For collecting input with a prompt, use playAndCollect().

This method emits calling.call.collect events. See Call Events for payload details.

Parameters

digits
Record<string, unknown> | undefined

DTMF digit collection settings.

digits.max
number

Maximum number of digits to collect.

digits.digit_timeout
number

Seconds to wait between digits before completing.

digits.terminators
string

Characters that terminate digit collection (e.g., "#").

speech
Record<string, unknown> | undefined

Speech recognition settings.

speech.end_silence_timeout
number

Seconds of silence to wait before finalizing speech input.

speech.speech_timeout
number

Maximum seconds to listen for speech.

speech.language
string

Speech recognition language code (e.g., "en-US").

speech.hints
string[]

Words or phrases to boost recognition accuracy.

initialTimeout
number | undefined

Seconds to wait for the first input before ending with no_input.

partialResults
boolean | undefined

Enable partial speech recognition results.

continuous
boolean | undefined

Keep collecting after each result instead of stopping.

sendStartOfInput
boolean | undefined

Send an event when input is first detected.

startInputTimers
boolean | undefined

Start input timers immediately. If false, call action.startInputTimers() to start them manually.

controlId
string | undefined

Custom control ID. Auto-generated if not provided.

onCompleted
(event: RelayEvent) => void | Promise<void>

Callback invoked when collection completes.

Returns

Promise<StandaloneCollectAction> — An action handle with stop(), startInputTimers(), and wait() methods.

Example

1import { RelayClient } from '@signalwire/sdk';
2
3const client = new RelayClient({
4 project: process.env.SIGNALWIRE_PROJECT_ID!,
5 token: process.env.SIGNALWIRE_API_TOKEN!,
6 contexts: ['default']
7});
8
9client.onCall(async (call) => {
10 await call.answer();
11
12 // Collect digits silently (e.g., extension entry)
13 const action = await call.collect({
14 digits: { max: 4, digit_timeout: 3, terminators: '#' },
15 initialTimeout: 10,
16 });
17 const event = await action.wait();
18
19 const result = event.params.result as Record<string, unknown> ?? {};
20 const extension = (result.digits ?? '') as string;
21 console.log(`Extension entered: ${extension}`);
22});
23
24await client.run();