build

View as MarkdownOpen in Claude

Return the SWML document as a plain object. The name matches the Python SDK’s SWMLBuilder.build(). For a JSON string, use render(). For property-style access to the same object, use the document getter.

Returns

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

Example

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