collect

View as MarkdownOpen in Claude

Start collecting user input on an active call. Supports DTMF digit collection and speech recognition. Returns a control_id for managing the collection.

Request

idstringRequiredformat: "uuid"
The unique identifying ID of a 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

1import { RestClient } from "@signalwire/sdk";
2
3const client = new RestClient({
4 project: "your-project-id",
5 token: "your-api-token",
6 host: "your-space.signalwire.com"
7});
8
9// Collect DTMF digits
10const result = await client.calling.collect("call-id-xxx", {
11 digits: { max: 4, terminators: "#", digit_timeout: 5.0 },
12 initial_timeout: 10.0,
13});

Collect Speech

1import { RestClient } from "@signalwire/sdk";
2
3const client = new RestClient({
4 project: "your-project-id",
5 token: "your-api-token",
6 host: "your-space.signalwire.com"
7});
8
9const result = await client.calling.collect("call-id-xxx", {
10 speech: {
11 end_silence_timeout: 1.0,
12 language: "en-US",
13 },
14});

Collect Both

1import { RestClient } from "@signalwire/sdk";
2
3const client = new RestClient({
4 project: "your-project-id",
5 token: "your-api-token",
6 host: "your-space.signalwire.com"
7});
8
9const result = await client.calling.collect("call-id-xxx", {
10 digits: { max: 1, terminators: "#" },
11 speech: { end_silence_timeout: 2.0 },
12 initial_timeout: 15.0,
13});