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

1import { SwmlBuilder } from '@signalwire/sdk';
2
3const builder = new SwmlBuilder();
4builder.answer();
5builder.addSection('fallback');
6builder.addVerbToSection('fallback', 'play', {
7 url: 'https://example.com/sorry.mp3',
8});
9builder.addVerbToSection('fallback', 'hangup', {});
10
11console.log(builder.renderDocument());