RelayActions

CollectAction

View as MarkdownOpen in Claude

Returned from call.play_and_collect(). Tracks a combined play-and-collect operation where a prompt is played and user input (digits or speech) is collected. Terminal states: finished, error, no_input, no_match.

CollectAction only resolves on collect events. Play events sharing the same control_id are ignored, so await action.wait() returns only when input collection completes.

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.play_and_collect(
media=[{"type": "tts", "params": {"text": "Press 1 for sales, 2 for support."}}],
collect={"digits": {"max": 1, "digit_timeout": 5.0}},
)
event = await action.wait()
result = event.params.get("result", {})
digit = result.get("digits", "")
print(f"User pressed: {digit}")
client.run()