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

# to_swaig

> Convert the function to a SWAIG-compatible dictionary for SWML.

Convert this function to a SWAIG-compatible dictionary for inclusion in a SWML
document. Called internally during SWML rendering.

## **Parameters**

**`base_url`** `str` — required

Base URL for the webhook endpoint.

---

**`token`** `str`

Auth token to include in the webhook URL.

---

**`call_id`** `str`

Call ID for session tracking.

---

**`include_auth`** `bool` — default: true

Whether to include auth credentials in the webhook URL.

---

## **Returns**

`dict[str, Any]` -- Dictionary with `"function"`, `"description"`, `"parameters"`,
`"web_hook_url"`, and optional `"fillers"` keys.

## **Example**

```python {17}
from signalwire import SWAIGFunction
from signalwire import FunctionResult

func = SWAIGFunction(
    name="check_order",
    handler=lambda args, raw_data: FunctionResult("ok"),
    description="Check order status",
    parameters={
        "type": "object",
        "properties": {
            "order_id": {"type": "string", "description": "Order ID"}
        },
        "required": ["order_id"]
    }
)

swaig_dict = func.to_swaig(
    base_url="https://myapp.example.com",
    token="abc123",
    call_id="call-12345"
)

print(swaig_dict)
# {
#     "function": "check_order",
#     "description": "Check order status",
#     "parameters": {...},
#     "web_hook_url": "https://myapp.example.com/swaig?token=abc123&call_id=call-12345"
# }
```