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

dialobjectRequired
OR
updateobjectRequired
OR
calling.endobjectRequired
OR
calling.disconnectobjectRequired
OR
calling.ai_holdobjectRequired
OR
calling.ai_unholdobjectRequired
OR
calling.ai_messageobjectRequired
OR
calling.ai.stopobjectRequired
OR
calling.playobjectRequired
OR
calling.play.pauseobjectRequired
OR
calling.play.resumeobjectRequired
OR
calling.play.stopobjectRequired
OR
calling.play.volumeobjectRequired
OR
calling.recordobjectRequired
OR
calling.record.pauseobjectRequired
OR
calling.record.resumeobjectRequired
OR
calling.record.stopobjectRequired
OR
calling.collectobjectRequired
OR
calling.collect.stopobjectRequired
OR
calling.collect.start_input_timersobjectRequired
OR
calling.detectobjectRequired
OR
calling.detect.stopobjectRequired
OR
calling.tapobjectRequired
OR
calling.tap.stopobjectRequired
OR
calling.streamobjectRequired
OR
calling.stream.stopobjectRequired
OR
calling.denoiseobjectRequired
OR
calling.denoise.stopobjectRequired
OR
calling.transcribeobjectRequired
OR
calling.transcribe.stopobjectRequired
OR
calling.live_transcribeobjectRequired
OR
calling.live_translateobjectRequired
OR
calling.transferobjectRequired
OR
calling.send_fax.stopobjectRequired
OR
calling.receive_fax.stopobjectRequired
OR
calling.referobjectRequired
OR
calling.user_eventobjectRequired

Response

Call LegobjectRequired
OR
Fabric Subscriber Device LegobjectRequired

Response Example

Response
1{
2 "id": "0e9c80d7-a149-4917-892d-420043709f45",
3 "from": "+12069708643",
4 "to": "+15550198765",
5 "direction": "outbound-api",
6 "source": "realtime_api",
7 "charge": 0,
8 "created_at": "2024-05-06T12:20:00Z",
9 "charge_details": [
10 {
11 "description": "Outbound Voice",
12 "charge": 0.004
13 }
14 ],
15 "status": "queued",
16 "type": "relay_pstn_call"
17}

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});