addVerbToSection

View as MarkdownOpen in Claude

Add a SWML verb to a specific named section of the document. If the section does not exist, it is created automatically before the verb is appended. Throws a validation error if schema validation is enabled and the verb config is invalid.

Use addSection() first to create an empty section if you prefer explicit creation, or use this method directly and let it auto-create. For the default main section, use addVerb() instead.

Parameters

sectionName
stringRequired

Name of the section to add the verb to (e.g., "main", "transfer_flow").

verbName
stringRequired

The SWML verb name.

config
unknownRequired

Configuration for the verb. Typically a Record<string, unknown> object; certain verbs like sleep accept a bare number.

Returns

this — returns the service for fluent chaining.

Example

1import { SWMLService } from '@signalwire/sdk';
2
3const service = new SWMLService({ name: 'transfer-flow' });
4
5// Build the main section
6service.addVerb('answer', {});
7service.addVerb('ai', { prompt: { text: 'You are a helpful assistant' } });
8
9// Build a separate transfer section
10service.addVerbToSection('transfer', 'connect', {
11 to: '+15551234567',
12 from: '+15559876543',
13});
14
15console.log(service.renderDocument());