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

# executeSwml

> Execute a raw SWML document as an action.

[connect]: /docs/server-sdks/reference/typescript/agents/function-result/connect

[record-call]: /docs/server-sdks/reference/typescript/agents/function-result/record-call

[send-sms]: /docs/server-sdks/reference/typescript/agents/function-result/send-sms

[functionresult]: /docs/server-sdks/reference/typescript/agents/function-result

Execute a raw SWML document as an action. This is the escape hatch for advanced
use cases that are not covered by the named convenience methods.

Most use cases are covered by the specific action methods
([`connect()`][connect],
[`recordCall()`][record-call],
[`sendSms()`][send-sms], etc.).
Use `executeSwml()` only when you need SWML features not available through
convenience methods.

## **Parameters**

**`swmlContent`** `string | Record<string, unknown> | { toDict(): Record<string, unknown> }` — required

SWML content in one of three formats:

* `string` -- raw SWML JSON text (parsed via `JSON.parse`; invalid JSON is wrapped as `{ raw_swml: content }`)
* `Record<string, unknown>` -- SWML data structure (shallow-copied into the action)
* An object exposing a `toDict()` method (e.g., a `SwmlBuilder` instance) -- the returned dictionary is used as the SWML payload

---

**`transfer`** `boolean` — default: false

When `true`, the call exits the agent after the SWML executes. When `false`,
the SWML executes inline and the agent continues.

---

## **Returns**

[`FunctionResult`][functionresult] -- `this`, for chaining.

## **Example**

```typescript {4}
import { FunctionResult } from '@signalwire/sdk';

const result = new FunctionResult()
  .executeSwml({
    version: '1.0.0',
    sections: { main: [{ play: { url: 'https://example.com/audio.mp3' } }] },
  });
```