RELAY

Actions

View as MarkdownOpen in Claude

Action objects are returned from call control methods like play(), record(), and detect(). They provide a common interface for tracking and controlling in-progress operations on a Call.

All action classes extend a shared base that provides is_done, completed, result, control_id, and the wait() method. Specific action types add methods relevant to their operation (e.g., pause() and resume() on PlayAction).

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 on_call(call):
12 await call.answer()
13 play_action = await call.play([{"type": "tts", "text": "Hello!"}])
14
15 # Control the in-progress operation
16 await play_action.pause()
17 await play_action.resume()
18
19 # Wait for completion
20 event = await play_action.wait()
21
22client.run()

Action (Base Interface)

All action classes share these properties and methods.

Properties

control_id
str

Unique identifier for this operation, used to correlate commands and events.

is_done
bool

True if the underlying future has resolved (the operation has reached a terminal state).

completed
bool

True once the action has finished and the terminal event has been processed.

result
Optional[RelayEvent]

The terminal RelayEvent for this action, or None if the action has not yet completed.

Methods

wait

wait(timeout=None) -> RelayEvent

Block until the action completes and return the terminal event.

timeout
Optional[float]

Maximum seconds to wait. None waits indefinitely. Raises asyncio.TimeoutError if exceeded.

Subclasses