RelayCall

detect_answering_machine

View as MarkdownOpen in Claude

Detect a human versus an answering machine. A typed convenience over detect() that builds the {"type": "machine", "params": {...}} configuration for you. All parameters are keyword-only, and only the ones you set are sent.

Parameters

initial_timeout
float | NoneDefaults to None

Seconds to wait for initial voice before deciding.

end_silence_timeout
float | NoneDefaults to None

Seconds of silence that end the greeting.

machine_voice_threshold
float | NoneDefaults to None

Seconds of continuous voice above which the greeting is treated as a machine.

machine_words_threshold
int | NoneDefaults to None

Word count above which the greeting is treated as a machine.

detect_interruptions
bool | NoneDefaults to None

When True, detect the caller interrupting during the machine greeting playback.

detect_message_end
bool | NoneDefaults to None

Whether to keep listening for the end of a machine’s message, so you can leave one after the beep.

timeout
float | NoneDefaults to None

Maximum seconds to run the detector before stopping. Keyword-only.

on_completed
Callable[[RelayEvent], Any] | NoneDefaults to None

Callback invoked when the operation reaches a terminal state. Can be a regular function or async coroutine. Keyword-only.

Returns

DetectAction — An action handle with stop() and wait() methods. It resolves on the first detection result.

Example

from signalwire.relay import RelayClient
client = RelayClient(
project="your-project-id",
token="your-api-token",
contexts=["default"],
)
@client.on_call
async def handle_call(call):
await call.answer()
action = await call.detect_answering_machine(
detect_message_end=True,
timeout=30,
)
event = await action.wait()
print("Detect result:", event.params)
client.run()