addPreAnswerVerb

View as MarkdownOpen in Claude

Add a verb to run before the call is answered (phase 1). Pre-answer verbs execute while the call is still ringing.

Only certain verbs are safe before answering. The platform may ignore or reject verbs that require an active media session. Verbs with auto_answer capability (like play and connect) must include "auto_answer": false in their config to prevent automatic answering.

Safe pre-answer verbs: transfer, execute, return, label, goto, request, switch, cond, if, eval, set, unset, hangup, send_sms, sleep, stop_record_call, stop_denoise, stop_tap.

Parameters

verbName
stringRequired

SWML verb name (e.g., "play", "sleep", "request").

config
Record<string, unknown>Required

Verb configuration object. See the SWML reference for verb-specific parameters.

Returns

AgentBase — Returns this for method chaining.

Example

1import { AgentBase } from '@signalwire/sdk';
2
3const agent = new AgentBase({ name: 'support', route: '/support' });
4agent.setPromptText('You are a helpful assistant.');
5agent.addPreAnswerVerb('play', {
6 urls: ['ring:us'],
7 auto_answer: false,
8});
9await agent.serve();