***

title: register_swaig_function
slug: /reference/python/agents/agent-base/register-swaig-function
description: Register a raw SWAIG function dictionary, typically from a DataMap.
max-toc-depth: 3
---------------------

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

[datamap]: /docs/server-sdks/reference/python/agents/data-map

[define-tool]: /docs/server-sdks/reference/python/agents/agent-base/define-tool

[ref-agentbase]: /docs/server-sdks/reference/python/agents/agent-base

Register a raw SWAIG function definition dictionary. This is the primary way to
register server-side functions created by
[`DataMap`][datamap], which generates complete
SWAIG function definitions including URL mappings, expressions, and output templates.

Unlike [`define_tool()`][define-tool],
this method does not take a Python handler -- the function executes on the SignalWire
server (for DataMap functions) or at an external webhook URL.

## **Parameters**

<ParamField path="function_dict" type="dict[str, Any]" required={true} toc={true}>
  Complete SWAIG function definition dictionary. Must follow the SWAIG function
  schema, typically generated by `DataMap.to_swaig_function()`.
</ParamField>

## **Returns**

[`AgentBase`][ref-agentbase] -- Returns self for method chaining.

## **Example**

```python {17}
from signalwire import AgentBase, FunctionResult
from signalwire.core.data_map import DataMap

agent = AgentBase(name="weather-agent", route="/weather")
agent.set_prompt_text("You are a helpful assistant.")

# Create a DataMap that calls a weather API server-side
weather_tool = (
    DataMap("get_weather")
    .description("Get the current weather")
    .parameter("city", param_type="string", description="City name", required=True)
    .webhook("GET", "https://api.weather.example.com/current?city=${args.city}")
    .output(FunctionResult("The weather in ${args.city} is ${response.temp}F."))
)

# Register the DataMap as a SWAIG function
agent.register_swaig_function(weather_tool.to_swaig_function())
agent.serve()
```