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 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

Examples

Collect DTMF Digits

import { RestClient } from "@signalwire/sdk";
const client = new RestClient({
project: "your-project-id",
token: "your-api-token",
host: "your-space.signalwire.com"
});
// Collect DTMF digits
const result = await client.calling.collect("call-id-xxx", {
digits: { max: 4, terminators: "#", digit_timeout: 5.0 },
initial_timeout: 10.0,
});

Collect Speech

import { RestClient } from "@signalwire/sdk";
const client = new RestClient({
project: "your-project-id",
token: "your-api-token",
host: "your-space.signalwire.com"
});
const result = await client.calling.collect("call-id-xxx", {
speech: {
end_silence_timeout: 1.0,
language: "en-US",
},
});

Collect Both

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