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
str | NoneDefaults to None

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

prompt
str | NoneDefaults to None

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

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