addSection

View as MarkdownOpen in Claude

Add a new empty named section to the SWML document. Sections are named containers for ordered lists of verbs. Every document starts with a main section — use this method to create additional sections (e.g., a transfer flow).

Silently no-ops if a section with the given name already exists. Follow up with addVerbToSection() to populate the section.

Parameters

sectionName
stringRequired

Name of the section to create.

Returns

this — returns the builder for fluent chaining.

Example

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