***

title: toDict
slug: /reference/typescript/agents/function-result/to-dict
description: Serialize a FunctionResult to the SWAIG response format.
max-toc-depth: 3
---------------------

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

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**

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

const result = new FunctionResult('Order confirmed.')
  .updateGlobalData({ order_id: '12345' });

const serialized = result.toDict();
console.log(serialized);
```