REST ClientCalling

collect

View as MarkdownOpen in Claude

Start collecting user input on an active call. Supports DTMF digit collection and speech recognition. Pass a control_id to name the collection so you can manage it later with collect_stop() or collect_start_input_timers(). The response never carries control_id back — omit it and you have no way to control this collection afterward.

Request

idstringRequiredformat: "uuid"
The unique identifying ID of an existing call.
paramsobjectRequired
An object of parameters that will be utilized by the active command.

Response

Call LegobjectRequired
Returned when the call is a standard PSTN, SIP, or WebRTC call.
OR
Fabric Subscriber Device LegobjectRequired

Returned when the call is a Fabric subscriber device leg. The status field is always null for this type.

Examples

Collect DTMF Digits

from signalwire.rest import RestClient
client = RestClient(
project="your-project-id",
token="your-api-token",
host="your-space.signalwire.com",
)
# Collect DTMF digits -- name it so it can be stopped or its timers managed later
client.calling.collect(
call_id="call-id-xxx",
control_id="collect-1",
digits={"max": 4, "terminators": "#", "digit_timeout": 5.0},
initial_timeout=10.0,
)

Collect Speech

from signalwire.rest import RestClient
client = RestClient(
project="your-project-id",
token="your-api-token",
host="your-space.signalwire.com",
)
result = client.calling.collect(
call_id="call-id-xxx",
speech={
"end_silence_timeout": 1.0,
"language": "en-US",
},
)

Collect Both

from signalwire.rest import RestClient
client = RestClient(
project="your-project-id",
token="your-api-token",
host="your-space.signalwire.com",
)
result = client.calling.collect(
call_id="call-id-xxx",
digits={"max": 1, "terminators": "#"},
speech={"end_silence_timeout": 2.0},
initial_timeout=15.0,
)