> For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

# build

> Build and return the SWML document as an object (Python-compat alias for getDocument).

[ref-getdocument]: /docs/server-sdks/reference/typescript/agents/swml-builder/get-document

[ref-render]: /docs/server-sdks/reference/typescript/agents/swml-builder/render

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

## **Returns**

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

## **Example**

```typescript {6}
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));
```