resetDocument

View as MarkdownOpen in Claude

Reset the SWML document to an empty state. Clears all sections and verbs, leaving only an empty main section. Use this to rebuild the document from scratch without creating a new SWMLService instance.

Returns

this — returns the service for fluent chaining.

Example

1import { SWMLService } from '@signalwire/sdk';
2
3const service = new SWMLService({ name: 'my-service' });
4service.addVerb('answer', {});
5service.addVerb('play', { url: 'https://example.com/old.mp3' });
6
7// Start over with a fresh document
8service.resetDocument();
9service.addVerb('answer', {});
10service.addVerb('ai', { prompt: { text: 'You are a helpful assistant' } });
11
12console.log(service.renderDocument());