Skip to navigation

Append a verb to the main section of the SWML document. Validates the verb config against the bundled schema when validation is enabled.

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. Set SWML_SKIP_SCHEMA_VALIDATION=true to disable validation.

Parameters

verbName
stringRequired

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

config
unknownRequired

The verb’s configuration payload. Most verbs accept an object of parameters. The sleep verb accepts a number (duration in milliseconds).

Returns

void — Throws a SchemaValidationError if the verb fails schema validation (when validation is enabled).

Example

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