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

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