RELAYActions

DetectAction

View as MarkdownOpen in Claude

Returned from call.detect(). Tracks an active detection operation (answering machine, fax tone, or digit detection). Terminal states: finished, error.

Unlike other actions, DetectAction also resolves on the first detection result, not just on terminal state events. This means await action.wait() returns as soon as a detection is made.

Inherits all properties and methods from the base Action interface (control_id, is_done, completed, result, wait()).

Properties

No additional properties beyond the base Action interface.

Methods

Example

1from signalwire.relay import RelayClient
2
3client = RelayClient(
4 project="your-project-id",
5 token="your-api-token",
6 host="your-space.signalwire.com",
7 contexts=["default"],
8)
9
10@client.on_call
11async def handle_call(call):
12 await call.answer()
13 action = await call.detect(
14 {"type": "machine", "params": {"initial_timeout": 5.0}}
15 )
16
17 event = await action.wait(timeout=10)
18 detect_result = event.params.get("detect", {})
19 print(f"Detected: {detect_result}")
20
21client.run()