***

title: executeSwml
slug: /reference/typescript/agents/function-result/execute-swml
description: Execute a raw SWML document as an action.
max-toc-depth: 3
---------------------

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

[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.

<Note>
  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.
</Note>

## **Parameters**

<ParamField path="swmlContent" type="string | Record<string, unknown>" required={true} toc={true}>
  SWML content in one of two formats:

  * `string` -- raw SWML JSON text (parsed via `JSON.parse`; invalid JSON is wrapped as `{ raw_swml: content }`)
  * `Record<string, unknown>` -- SWML data structure (spread into the action)
</ParamField>

<ParamField path="transfer" type="boolean" default="false" toc={true}>
  When `true`, the call exits the agent after the SWML executes. When `false`,
  the SWML executes inline and the agent continues.
</ParamField>

## **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' } }] },
  });
```