RELAYCall

ai_hold

View as MarkdownOpen in Claude

Put an active AI agent session on hold. The AI stops processing conversation while the call remains active. The caller may hear hold music or silence depending on the configuration.

Use ai_unhold() to resume the AI session.

Parameters

timeout
Optional[str]

Maximum hold duration. The AI session automatically resumes after this timeout.

prompt
Optional[str]

A prompt for the AI to speak before going on hold (e.g., “Please hold while I check on that.”).

Returns

dict — Server response confirming the AI hold.

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
14 # Start an AI agent
15 action = await call.ai(
16 prompt={"text": "You are a support agent."},
17 )
18
19 # After some event, put the AI on hold
20 await call.ai_hold(
21 prompt="One moment please while I look that up.",
22 timeout="30",
23 )
24
25 # Do some processing, then resume with ai_unhold()
26
27client.run()