build

View as MarkdownOpen in Claude

Return the SWML document as a plain object. Python-compat alias for getDocument(); the two are functionally identical. Use build() when porting from the Python SDK. For a JSON string, use render() or renderDocument().

Returns

Record<string, unknown> — the SWML document with version and sections keys.

Example

1import { SwmlBuilder } from '@signalwire/sdk';
2
3const builder = new SwmlBuilder();
4builder.answer();
5builder.ai({ prompt: { text: 'You are a helpful assistant.' } });
6
7const doc = builder.build();
8console.log(JSON.stringify(doc, null, 2));