toDict

View as MarkdownOpen in Claude

Serialize to the JSON structure expected by SWAIG. Called automatically when the result is returned from a tool function — you rarely need to call this directly.

The output contains response (if set), action (if any actions were added), and post_process (only when true and actions are present). If neither response nor action is present, defaults to {"response": "Action completed."}.

Parameters

None.

Returns

Record<string, unknown> — SWAIG-formatted response object.

Example

1import { FunctionResult } from '@signalwire/sdk';
2
3const result = new FunctionResult('Order confirmed.')
4 .updateGlobalData({ order_id: '12345' });
5
6const serialized = result.toDict();
7console.log(serialized);