record_call

View as Markdown

Record call in the background. Unlike the record method, the record_call method will start the recording and continue executing the SWML script while allowing the recording to happen in the background. To stop call recordings started with record_call, use the stop_call_record method.

Properties

record_call
objectRequired

An object that accepts the following properties.

record_call.control_id
stringDefaults to Auto-generated, saved to record_control_id variable

Identifier for this recording, to use with stop_record_call

record_call.stereo
booleanDefaults to false

Whether to record in stereo mode

record_call.format
stringDefaults to wav

Format ("wav", "mp3", or "mp4")

record_call.direction
stringDefaults to both

Direction of the audio to record: "speak" for what party says, "listen" for what party hears, "both" for what the party hears and says

record_call.terminators
string

String of digits that will stop the recording when pressed. Default is empty (no terminators).

record_call.beep
booleanDefaults to false

Whether to play a beep before recording

record_call.input_sensitivity
numberDefaults to 44.0

How sensitive the recording voice activity detector is to background noise? A larger value is more sensitive. Allowed values from 0.0 to 100.0.

record_call.initial_timeout
numberDefaults to 0

How long, in seconds, to wait for speech to start?

record_call.end_silence_timeout
numberDefaults to 0

How much silence, in seconds, will end the recording?

record_call.max_length
number

Maximum length of the recording in seconds.

record_call.status_url
string

HTTP or HTTPS URL to deliver record status events. Learn more about status callbacks.

Variables

Set by the method:

  • record_call_url: (out) the URL of the newly started recording.
  • record_call_result: (out) success | failed.
  • record_control_id: (out) control ID of this recording.

StatusCallbacks

A POST request will be sent to status_url with a JSON payload like the following:

event_type
string

The type of event. Always calling.call.record for this method.

event_channel
string

The channel for the event, includes the SWML session ID.

timestamp
number

Unix timestamp (float) when the event was generated.

project_id
string

The project ID associated with the call.

space_id
string

The Space ID associated with the call.

params
object

An object containing recording-specific parameters.

params.call_id
string

The call ID.

params.node_id
string

The node handling the call.

params.control_id
string

The control ID for this record operation.

params.state
string

The current recording state. Valid values: recording, paused, finished, no_input, error.

params.record
object

Recording result details (present when state is finished).

record.url
string

URL to download the recording.

record.duration
number

Recording duration in seconds.

record.size
number

Recording file size in bytes.

record.format
string

Recording format. Valid values: wav, mp3.

Raw JSON example

1{
2 "event_type": "calling.call.record",
3 "event_channel": "swml:xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
4 "timestamp": 1640000000.123,
5 "project_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
6 "space_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
7 "params": {
8 "call_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
9 "node_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
10 "control_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
11 "state": "finished",
12 "record": {
13 "url": "https://your-space.signalwire.com/api/v1/recordings/rec-uuid/download",
14 "duration": 15.5,
15 "size": 248320,
16 "format": "wav"
17 }
18 }
19}

Examples

Start an MP3 recording of the call

1version: 1.0.0
2sections:
3 main:
4 - record_call:
5 format: mp3

Record and play back

Record both sides of the conversation:

1version: 1.0.0
2sections:
3 main:
4 - record_call:
5 beep: true
6 terminators: '#'
7 - play:
8 urls:
9 - 'say:Leave your message now'
10 - 'silence:10'
11 - stop_record_call: {}
12 - play:
13 urls:
14 - 'say:Playing back'
15 - '${record_call_url}'

Record only the speaker’s side

1version: 1.0.0
2sections:
3 main:
4 - record_call:
5 beep: true
6 direction: speak
7 - play:
8 urls:
9 - 'say:Leave your message now'
10 - 'silence:10'
11 - stop_record_call: {}
12 - play:
13 urls:
14 - 'say:Playing back'
15 - '${record_call_url}'