addSection

View as MarkdownOpen in Claude

Add a new empty section to the SWML document. Sections are named containers for ordered lists of verbs. Every document starts with a main section.

Silently no-ops if a section with the given name already exists (unlike the Python SDK which returns False on duplicate). Follow up with addVerbToSection() to populate the section.

Parameters

sectionName
stringRequired

Name of the section to create.

Returns

this — returns the service for fluent chaining.

Example

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