Skip to navigation

Start collecting user input on an active call. Supports DTMF digit collection and speech recognition.

control_id is a caller-chosen identifier for this operation, unique per active operation of this kind on the call. The TypeScript SDK types it as optional, but the API requires it — a request that omits it is rejected.

Keep it to manage the collection later.

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

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 under a control ID you choose
const result = await client.calling.collect("call-id-xxx", {
control_id: "pin-collect-1",
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", {
control_id: "speech-collect-1",
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", {
control_id: "combined-collect-1",
digits: { max: 1, terminators: "#" },
speech: { end_silence_timeout: 2.0 },
initial_timeout: 15.0,
});