> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usesimple.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Twilio Flex

> Connect Simple AI to Twilio Flex via SIP or TaskRouter-driven transfer

Simple AI connects to Twilio Flex either over a SIP trunk or by transferring calls from a TwiML flow. Flex keeps TaskRouter queues, worker state, and reporting; Simple AI handles the conversations routed to it and hands them back for live agent escalation.

## What You Can Do

* **Inbound routing** — your Studio or TwiML flow answers the call, then transfers it to Simple AI.
* **Outbound campaigns** — your dialer or campaign logic hands connected calls to Simple AI.
* **Direct outbound** — Simple AI places calls through your Twilio SIP trunk with your existing caller ID.
* **Live agent escalation** — Simple AI transfers back into Flex so TaskRouter can queue the call to a worker.
* **Context on transfer** — over SIP, metadata rides along in `X-` prefixed SIP headers; from a TwiML flow, context is passed as task attributes.

## How It Connects

```
Customer → Twilio (Studio / TwiML) → Simple AI
                  ← escalation back ←
```

1. Twilio receives the call and runs your Studio or TwiML flow.
2. The flow transfers the call to Simple AI — via the SIP trunk or a dial to the AI destination.
3. Simple AI runs the conversation and transfers back when escalation is needed.
4. TaskRouter creates a task for the returned call and routes it to a worker with the transferred context.

## Setup

1. Choose SIP trunking or a TwiML transfer, and share the details with your account team.
2. For SIP, create a Twilio Elastic SIP Trunk pointing at Simple AI's SIP endpoint, and allowlist our signaling and media IPs.
3. Add the handoff to the flows that should use the AI, and a return destination for escalation.
4. Test inbound, outbound, and escalation, verifying caller ID, audio, DTMF, and agent-side context.

Your account team configures the Simple AI side. Contact [support@usesimple.ai](mailto:support@usesimple.ai) to get started.

## Related

* [CCaaS Integrations](/integrations/ccaas/overview)
* [SIP Integration](/sip-integration)
