Skip to navigation

addVerbToSection

View as MarkdownOpen in Claude

Append a verb to a named section of the SWML document. If the section does not exist, it is created automatically. The verb config is validated against the bundled schema when validation is enabled, exactly as in addVerb().

Unknown verbs and keys throw

Validation is strict. An unknown verb name, an unknown or misspelled key inside the verb config, or a value of the wrong type throws a SchemaValidationError instead of being dropped silently. Earlier SDK versions appended to non-main sections without validating. Set SWML_SKIP_SCHEMA_VALIDATION=true to disable validation.

Parameters

sectionName
stringRequired

The target section name.

verbName
stringRequired

The SWML verb name (e.g., "answer", "play", "hangup").

config
unknownRequired

The verb’s configuration payload.

Returns

void

Example

import { SwmlBuilder } from '@signalwire/sdk';
const builder = new SwmlBuilder();
builder.addVerb('answer', {});
builder.addVerbToSection('goodbye', 'play', {
url: 'https://example.com/goodbye.mp3',
});
builder.addVerbToSection('goodbye', 'hangup', {});
console.log(builder.render());