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

# Twilio Flex overview

> Run Twilio Flex as your contact center while OpenCX resolves what it can, escalates what it can''t, and writes every handoff back into the Flex task your reps already own.

OpenCX works alongside your reps inside Twilio Flex. The AI resolves what it can, escalates what it can't, and when a task reaches a human it arrives in <Tooltip tip="Twilio Flex's routing engine. Decides which worker picks up which task based on workflow filters, queues, and worker skills.">TaskRouter</Tooltip> with the full summary, sentiment, and reason already attached — no context rebuild, no separate inbox.

<Tip>
  Setup starts at [**Settings →
  Integrations**](https://platform.open.cx/settings/integrations) in your OpenCX
  dashboard.
</Tip>

## What you get

<AccordionGroup>
  <Accordion title="AI deflects before a rep ever sees the task" icon="robot">
    OpenCX accepts the <Tooltip tip="A TaskRouter offer of a task to a worker. Accepting it routes messages through OpenCX; rejecting it releases the task back to the workflow for a human to pick up.">reservation</Tooltip> on behalf of an automatically provisioned AI worker and replies instantly in the same Flex conversation your reps use. If the AI resolves, the task never surfaces to a human queue. Each AI worker handles up to 50 concurrent chats (a Twilio per-worker cap) — add more workers to the pool from the integration settings to scale beyond it.
  </Accordion>

  <Accordion title="Tasks arrive with summary, sentiment, and reason" icon="ticket">
    When the AI escalates, OpenCX rejects its reservation and updates the Flex
    task attributes with `handedOff: true`, a one-paragraph summary, the reason
    for handoff, the detected sentiment, and the conversation language. Your
    workflow filter on `handedOff == true` routes it to the right human queue.
  </Accordion>

  <Accordion title="One conversation from first message to close" icon="reply">
    AI replies post into the same Flex{" "}

    <Tooltip tip="The Twilio messaging service that backs every Flex channel. All Flex chat, SMS, WhatsApp, and voice transcripts live here — your rep and the AI write into the same thread.">
      Conversations service
    </Tooltip>

    {" "}

    thread your rep will inherit. No copy-pasting, no duplicated identity — the
    rep picks up the handoff note and keeps going.
  </Accordion>

  <Accordion title="Flex task attributes usable in Autopilot" icon="sliders">
    Every attribute your Flex workflow sets on a task — order ID, user ID, city,
    zone — is flattened onto the OpenCX session as `flex_*` fields.{" "}

    <Tooltip tip="OpenCX's topic-driven automation. Reads conversation state and custom data to decide actions, replies, and handoff policy." cta="Learn more" href="/handoff/topics">
      Autopilot
    </Tooltip>

    {" "}

    actions can read them straight out of `custom_data`.
  </Accordion>

  <Accordion title="Consistent logging across every task" icon="fingerprint">
    OpenCX persists the Flex task SID, reservation SID, and conversation SID on every session, so any task in Flex traces back to the exact AI reasoning in the OpenCX Inbox.
  </Accordion>
</AccordionGroup>

## Supported channels

Twilio Flex funnels every inbound channel through one Conversations + TaskRouter pipeline. Pick the channel you're wiring in first — each page covers the implementation details on top of the shared Flex setup.

<CardGroup cols={2}>
  <Card title="Web Chat" icon="comments" href="/integrations/twilio-flex/channels/web-chat">
    AI Chat Widget conversations routed to reps as Flex live chats.
  </Card>

  <Card title="Voice" icon="phone" href="/integrations/twilio-flex/channels/voice">
    AI Phone calls routed as Flex voice tasks with transcript attached.
  </Card>

  <Card title="SMS" icon="comment-sms" href="/integrations/twilio-flex/channels/sms">
    AI SMS conversations routed as Flex messaging tasks.
  </Card>

  <Card title="WhatsApp" icon="whatsapp" href="/integrations/twilio-flex/channels/whatsapp">
    AI WhatsApp conversations routed as Flex messaging tasks.
  </Card>
</CardGroup>

## Observability

Every conversation OpenCX hands to Flex is traceable in both directions. Reps read the AI's work on the Flex task; admins trace a Flex task back to the exact OpenCX session.

<AccordionGroup>
  <Accordion title="Task and conversation IDs on every session" icon="fingerprint">
    OpenCX stores the Flex `task SID`, `reservation SID`, and `conversation SID` on the session. Search the [Inbox](https://platform.open.cx/inbox) by any of them to open the session that produced the task.
  </Accordion>

  <Accordion title="Handoff summary and sentiment on task attributes" icon="pen">
    On handoff, OpenCX writes `handedOff`, `handoffReason`, `handoffSummary`,
    `handoffSentiment`, `handoffLanguage`, and `handoffTimestamp` into the Flex
    task's attributes. Your workflow filter reads them; your rep sees them in the
    task panel.
  </Accordion>

  <Accordion title="`flex_*` fields on OpenCX `custom_data`" icon="database">
    Every attribute your Flex workflow sets on a task is flattened onto `session.custom_data` as `flex_<attribute_name>` — e.g. `flex_order_id`, `flex_user_id`, `flex_customer_name`. Usable in [Autopilot](/handoff/topics) actions without extra configuration.
  </Accordion>

  <Accordion title="Handoff note visible to the rep in Flex" icon="note-sticky">
    At handoff, OpenCX posts a system note into the Flex conversation containing the summary, sentiment, and reason. Your rep sees it inline above their first reply — no tab switching.
  </Accordion>
</AccordionGroup>

## Setup path

<Steps>
  <Step title="Connect credentials">
    Paste your Account SID, Auth Token, Workspace SID, and AI Queue SID. Copy
    the webhook URL OpenCX generates.
  </Step>

  <Step title="Register the webhook on both Twilio surfaces">
    TaskRouter **and** the Conversations service. Skipping one is the most
    common onboarding failure — see [Connect Twilio
    Flex](/integrations/twilio-flex/connect).
  </Step>

  <Step title="Add the workflow filters">
    Route AI-skilled tasks to the OpenCX AI worker; route `handedOff == true`
    tasks to your human queue.
  </Step>

  <Step title="Understand the handoff contract">
    Read [Handoff and task attributes](/integrations/twilio-flex/handoff) so you
    know exactly what OpenCX writes and what your workflow is expected to do.
  </Step>
</Steps>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Connect Twilio Flex" icon="plug" href="/integrations/twilio-flex/connect">
    Credentials, dual webhook registration, workflow filters.
  </Card>

  <Card title="Handoff and task attributes" icon="user-group" href="/integrations/twilio-flex/handoff">
    The AI worker, task-attribute contract, closing Flex tasks.
  </Card>

  <Card title="Channels" icon="grid-2" href="/integrations/twilio-flex/channels/web-chat">
    Per-channel implementation details on top of the shared setup.
  </Card>

  <Card title="Troubleshooting" icon="wrench" href="/integrations/twilio-flex/troubleshooting">
    Missing webhook, wrong queue, events routed to the wrong org.
  </Card>
</CardGroup>
