render

View as MarkdownOpen in Claude

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

Returns

string — JSON-serialized SWML document.

Example

1import { SwmlBuilder } from '@signalwire/sdk';
2
3const builder = new SwmlBuilder();
4builder.answer();
5builder.ai({ prompt: { text: 'You are a helpful assistant.' } });
6
7const json = builder.render();
8console.log(json);
9// '{"version":"1.0.0","sections":{"main":[{"answer":{}},{"ai":{...}}]}}'