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

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(
{"type": "machine", "params": {"initial_timeout": 5.0}}
)
event = await action.wait(timeout=10)
detect_result = event.params.get("detect", {})
print(f"Detected: {detect_result}")
client.run()