aiHold

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 aiUnhold() to resume the AI session.

Parameters

timeout
string | undefined

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

prompt
string | undefined

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

Returns

Promise<Record<string, unknown>> — Server response confirming the AI hold.

Example

1import { RelayClient } from '@signalwire/sdk';
2
3const client = new RelayClient({
4 project: process.env.SIGNALWIRE_PROJECT_ID!,
5 token: process.env.SIGNALWIRE_TOKEN!,
6 contexts: ['default']
7});
8
9client.onCall(async (call) => {
10 await call.answer();
11
12 // Start an AI agent
13 const action = await call.ai({
14 prompt: { text: 'You are a support agent.' },
15 });
16
17 // After some event, put the AI on hold
18 await call.aiHold({
19 prompt: 'One moment please while I look that up.',
20 timeout: '30',
21 });
22
23 // Do some processing, then resume with aiUnhold()
24});
25
26await client.run();