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

# setAiAgent

> Route inbound calls to an AI Agent Fabric resource by ID.

[update]: /docs/server-sdks/reference/typescript/rest/phone-numbers/update

Route inbound calls on this phone number to an existing AI Agent Fabric resource
by its ID.

This is a typed wrapper over [`update`][update] that sets `call_handler` to
`ai_agent` and populates `call_ai_agent_id` for you.

## **Parameters**

<ParamField path="resourceId" type="string" required={true} toc={true}>
  ID of the phone number to bind.
</ParamField>

<ParamField path="agentId" type="string" required={true} toc={true}>
  ID of the AI Agent Fabric resource to route calls to.
</ParamField>

<ParamField path="extra" type="Record<string, unknown>" default="{}" toc={true}>
  Additional wire-level fields merged into the PUT body.
</ParamField>

## **Returns**

`Promise<any>` — The updated phone-number resource.

## **Example**

```typescript {9}
import { RestClient } from "@signalwire/sdk";

const client = new RestClient({
  project: "your-project-id",
  token: "your-api-token",
  host: "your-space.signalwire.com"
});

await client.phoneNumbers.setAiAgent("phone-number-id", "ai-agent-id");
```