record_call

View as MarkdownOpen in Claude

Start recording the call in the background. The conversation continues while recording is active.

Raises ValueError if format is not "wav" or "mp3", or if direction is not "speak", "listen", or "both".

For continuous call recording, omit initial_timeout and end_silence_timeout. Those parameters are for voicemail-style recordings that automatically stop on silence. Use stop_record_call() to end continuous recordings.

Parameters

control_id
Optional[str]Defaults to None

Identifier for this recording. Pass the same ID to stop_record_call() to stop this specific recording.

stereo
boolDefaults to False

Record in stereo (True) or mono (False).

format
strDefaults to wav

Recording file format.

  • "wav" — uncompressed WAV audio
  • "mp3" — compressed MP3 audio
direction
strDefaults to both

Audio direction to record.

  • "speak" — what the agent says
  • "listen" — what the caller says
  • "both" — both sides of the conversation
terminators
Optional[str]Defaults to None

DTMF digits that stop recording when pressed (e.g., "#").

beep
boolDefaults to False

Play a beep tone before recording starts.

input_sensitivity
floatDefaults to 44.0

Input sensitivity level for the recording.

initial_timeout
Optional[float]Defaults to None

Seconds to wait for speech to begin before auto-stopping. Used for voicemail-style recordings.

end_silence_timeout
Optional[float]Defaults to None

Seconds of silence after speech to wait before auto-stopping. Used for voicemail-style recordings.

max_length
Optional[float]Defaults to None

Maximum recording duration in seconds.

status_url
Optional[str]Defaults to None

URL to receive recording status webhook events.

Returns

FunctionResult — self, for chaining.

Examples

Continuous Recording

1from signalwire import AgentBase
2from signalwire import FunctionResult
3
4agent = AgentBase(name="my-agent", route="/agent")
5agent.set_prompt_text("You are a helpful assistant.")
6
7@agent.tool(name="start_recording", description="Start recording the call")
8def start_recording(args, raw_data):
9 return (
10 FunctionResult("Recording started.")
11 .record_call(
12 control_id="main_recording",
13 stereo=True,
14 format="mp3"
15 )
16 )
17
18agent.serve()

Voicemail Recording

1from signalwire import AgentBase
2from signalwire import FunctionResult
3
4agent = AgentBase(name="my-agent", route="/agent")
5agent.set_prompt_text("You are a helpful assistant.")
6
7@agent.tool(name="record_voicemail", description="Record a voicemail message")
8def record_voicemail(args, raw_data):
9 return (
10 FunctionResult("Please leave your message after the beep.")
11 .record_call(
12 control_id="voicemail",
13 beep=True,
14 max_length=120.0,
15 end_silence_timeout=3.0
16 )
17 )
18
19agent.serve()