> This page is for Server SDKs.

> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# build

> Build and return the SWML document as an object.

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

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

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

## **Returns**

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

## **Example**

```typescript {7}
import { SwmlBuilder } from '@signalwire/sdk';

const builder = new SwmlBuilder();
builder.answer();
// The SDK types prompt as string | object[]; SWML requires an object
builder.ai({ prompt: { text: 'You are a helpful assistant.' } as never });

const doc = builder.build();
console.log(JSON.stringify(doc, null, 2));
```