renderSwml

View as MarkdownOpen in Claude

Render the complete SWML document by assembling all 5 phases: pre-answer, answer, post-answer, AI, and post-AI verbs. This is called automatically by the Hono route handler on each incoming request, but can also be called manually for testing or debugging.

Parameters

callId
string

Optional call ID to use for session tokens. Auto-generated if omitted.

Returns

string — The rendered SWML document as a JSON string.

Example

1import { AgentBase } from '@signalwire/sdk';
2
3const agent = new AgentBase({ name: 'support', route: '/support' });
4agent.setPromptText('You are a helpful assistant.');
5agent.addHints(['SignalWire', 'SWML']);
6
7const swml = agent.renderSwml();
8console.log(JSON.parse(swml));