***

title: registerWithAgent
slug: /reference/typescript/agents/data-map/register-with-agent
description: Register this DataMap as a SWAIG function on an agent.
max-toc-depth: 3
---------------------

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

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

Register this DataMap as a SWAIG function on an agent. Converts the DataMap
to a SWAIG function definition and registers it with the agent's
`registerSwaigFunction` method.

## **Parameters**

<ParamField path="agent" type="object" required={true} toc={true}>
  An object with a `registerSwaigFunction(fn: Record<string, unknown>)` method
  (typically an `AgentBase` instance).
</ParamField>

## **Returns**

[`DataMap`][ref-datamap] -- Self for method chaining.

## **Example**

```typescript {10}
import { AgentBase, DataMap, FunctionResult } from '@signalwire/sdk';

const dm = new DataMap('get_weather');
dm.purpose('Look up current weather');
dm.parameter('city', 'string', 'City name', { required: true });
dm.webhook('GET', 'https://api.weather.com/v1/current?q=${args.city}');
dm.output(new FunctionResult('Weather: ${response.current.condition.text}'));

const agent = new AgentBase({ name: 'weather-agent' });
dm.registerWithAgent(agent);
```