executeSwml

View as MarkdownOpen in Claude

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(), recordCall(), sendSms(), etc.). Use executeSwml() only when you need SWML features not available through convenience methods.

Parameters

swmlContent
string | Record<string, unknown>Required

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)
transfer
booleanDefaults to false

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

Returns

FunctionResultthis, for chaining.

Example

1import { FunctionResult } from '@signalwire/sdk';
2
3const result = new FunctionResult()
4 .executeSwml({
5 version: '1.0.0',
6 sections: { main: [{ play: { url: 'https://example.com/audio.mp3' } }] },
7 });