# Answer phone calls with your AI agent using Twilio > Connect your Twilio account and assign phone numbers so your QwryAI agent answers inbound calls The Twilio integration connects your Twilio account to a QwryAI agent, so the agent answers inbound calls to your Twilio phone numbers. It's for businesses that want callers to get the same answers, Actions and instructions as their chat agent, in a voice they choose. For example, a store can let its agent answer "Do you ship to Canada?" on the phone at any hour. > [card] What you can do: | /docs/user-guides/integrations/twilio#how-to-connect-twilio | Have your agent pick up the phone with the same knowledge, Actions and instructions as your chat agent, in a voice you choose. > [!NOTE] > > Don't use Twilio? Connect an existing number from your own PBX, SIP provider or GSM gateway with a [SIP trunk](/docs/user-guides/integrations/sip-trunk). ## Before you start * A Twilio account with at least one phone number bought in it. * Your Twilio **Account SID** and **Auth Token**, from the Twilio Console dashboard. * A QwryAI agent with the voice you want callers to hear. Set the voice, language and greeting on the agent's [Voice](/docs/user-guides/chatbot/voice) page. * A plan that includes voice: Starter, Growth or Enterprise. ## How to connect Twilio **1. Connect your Twilio account** 1. Open your agent and select **Integrations** in the sidebar. 2. On the **Twilio** card, *Enable inbound phone calls for your AI Agent via Twilio*, select **Connect**. 3. Under **Twilio Integration**, enter your **Account SID** and **Auth Token** from the Twilio Console. The Account SID starts with `AC` followed by 32 characters; the Auth Token is 32 characters. 4. Select **Connect Twilio**. ![The Twilio card on the Integrations page with the pointer on Connect.](annotated/01-integrations-card.webp "Integrations › Twilio › Connect.") ![The Twilio page with the Twilio Integration card, the Account SID and Auth Token fields and the Connect Twilio button.](annotated/02-connect-form.webp "Enter the Account SID and Auth Token.") QwryAI checks the format first and shows what to fix, then checks the credentials with Twilio: *Invalid Account SID or Auth Token.* means Twilio didn't accept them. Once connected, the Account SID shows in a read-only field. ![The Twilio Integration form showing Invalid Account SID format. Must start with "AC" followed by 32 hex characters. and Invalid Auth Token format. Must be 32 hex characters.](annotated/03-validation.webp "Format errors show under each field.") > [!NOTE] > > QwryAI encrypts your Twilio credentials and never shows the Auth Token again. Each agent has its own Twilio connection, so different agents can use the same or different Twilio accounts. **2. Import phone numbers** 1. On the same page, under **Phone numbers**, select **Import from Twilio**. 2. The dialog lists the phone numbers in your Twilio account: *Select the phone numbers to import. You can give each one a friendly name.* 3. Tick the numbers to import and, if you like, give each a friendly name such as "Sales line". 4. Select **Import selected**. ![Selecting Import from Twilio, ticking two numbers, naming one Sales line and selecting Import selected.](walkthroughs/twilio-import.gif) QwryAI creates a SIP trunk named **QwryAI** in your Twilio account and attaches each imported number to it. Imported numbers don't take calls until you assign them in the next step. > [!NOTE] > > Each number can belong to one agent at a time. Numbers that are already imported appear greyed out in the dialog. **3. Assign the numbers to the agent** 1. Open **Channels**, then **Phone**, and go to the **Connections** tab. 2. Under **Assign phone numbers**, select **Assign a new number**. 3. Choose **Twilio number** and select **Continue**. If Twilio isn't connected yet, the option shows **Integrate with Twilio**, which opens the Twilio page. 4. Tick the imported numbers this agent answers and select **Assign selected**. ![The Assign a new number dialog with the Twilio number option, its Integrate with Twilio link, and the SIP trunk option.](annotated/04-assign-choose.webp "Choose Twilio number.") Assigned numbers show the phone number, the friendly name, a **Twilio** badge and **Active** with the switch on. > [!TIP] > > Call one of your numbers and check that your agent answers with the greeting from its voice settings. ## How calls work Once a number is assigned to an agent: * **Inbound calls** to that number go to the agent. * The agent speaks with the **voice settings** on its [Voice](/docs/user-guides/chatbot/voice) page and greets the caller with its first message. * The conversation follows the agent's instructions, data sources and Actions, just like a chat. * Each call is saved as a conversation in the **Inbox**. * If the caller asks for a person, the [Transfer to phone number](/docs/user-guides/chatbot/actions/transfer-to-phone) Action can hand the call over. QwryAI turns on call transfer on the Twilio trunk for you. * To get each call's summary in your own system, add a URL under **Call summary webhook** on the Phone channel's **Connections** tab. ### Example call A call to an agent for a store called Acme: > **Agent:** Hi, thanks for calling Acme. How can I help? > > **Caller:** Hi, do you ship to Canada? > > **Agent:** Yes, we ship to Canada. Standard delivery takes 5 to 7 business days. Anything else I can help with? The greeting comes from the agent's voice settings, and the answer from its data sources. ## Credits and costs A phone call has two bills: * **QwryAI:** each call uses **6 credits per minute**, plus the voice model's credits for each reply. Every started minute counts as a full minute. QwryAI charges nothing for the number or the trunk. See [Voice](/docs/user-guides/chatbot/voice). * **Twilio:** Twilio bills you directly for the number and the call minutes. A call only starts if your workspace has enough credits for its first minute. ## Call limits | Plan | Concurrent voice sessions | Max call duration | | - | - | - | | Starter | 5 | 15 minutes | | Growth | 20 | 15 minutes | | Enterprise | Unlimited | 15 minutes | You can set lower limits for one agent under **Limits** on the [Voice](/docs/user-guides/chatbot/voice) page: **Max no. of concurrent voice sessions**, **Max call duration** and **Allowed no. of daily calls**. ## Managing phone numbers ### Pause a number On the Phone channel's **Connections** tab, turn off the number's switch. QwryAI shows *Phone number unassigned*, and the number shows **Paused**. It stops taking calls but stays imported; turn the switch back on at any time. ### Delete a number from the Phone channel On the **Connections** tab, open the number's menu and select **Delete**, then confirm. The number is detached from your Twilio trunk and removed from the agent; it stays in your Twilio account and can be imported again. ### Remove a number on the Twilio page 1. Go to **Integrations** and select **Manage** on the Twilio card. 2. Under **Phone numbers**, open the number's menu and select **Remove**. 3. Confirm in **Delete phone number?**: it detaches the number from your Twilio trunk, and can't be undone. ### Disconnect Twilio 1. Go to **Integrations** and select **Manage** on the Twilio card. 2. Select **Disconnect** at the bottom, then confirm in **Disconnect Twilio?**. > [!WARNING] > > Disconnecting removes all imported phone numbers and deletes the SIP trunk from your Twilio account. Your numbers stay in your Twilio account, but you have to connect and import them again to use them with QwryAI. ## Limitations * **One agent per number.** A number can be imported to one agent at a time. * **A voice plan is required.** Starter, Growth or Enterprise. * **Inbound calls only.** The agent answers calls; it doesn't place them. * **Disconnecting is destructive.** It removes every imported number and deletes the trunk from your Twilio account. ## Troubleshooting > [accordion] Calls ring but the agent never answers > > Check, in order: > > 1. The number is assigned on the Phone channel's **Connections** tab and its switch is on. > 2. Your plan includes voice. > 3. Your workspace has enough credits for the first minute. > 4. No concurrent or daily call limit has been reached, on the plan or under **Limits** on the [Voice](/docs/user-guides/chatbot/voice) page. > [accordion] A number is missing or greyed out in the import dialog > > A greyed-out number is already imported, to this agent or another one. Remove it there first. If a number is missing, check that it's in the Twilio account whose Account SID you connected. > [accordion] My Studio flow or webhook stopped getting calls > > The number is attached to the QwryAI trunk, so Twilio sends its calls to your agent. Remove the number on the Twilio page to give it back to your Studio flow or webhook. ## Frequently asked questions > [accordion] Which plan do I need for Twilio phone calls? > > A plan with voice: Starter, Growth or Enterprise. See [Call limits](#call-limits). > [accordion] How much does a phone call cost? > > 6 credits per minute, plus the voice model's credits for each reply. Every started minute counts as a full minute. Twilio bills you separately for the number and the minutes. > [accordion] Can I use the same Twilio account for several agents? > > Yes. Each agent has its own Twilio connection. Each number can be imported to one agent at a time. > [accordion] Why doesn't my imported number take calls? > > Imported numbers take calls only once they're assigned. Open **Channels › Phone › Connections**, select **Assign a new number**, and assign it. > [accordion] How long can a call last? > > Up to your plan's 15 minutes. You can set a shorter **Max call duration** on the [Voice](/docs/user-guides/chatbot/voice) page. > [accordion] Can the agent transfer a call to a person? > > Yes, with the [Transfer to phone number](/docs/user-guides/chatbot/actions/transfer-to-phone) Action. QwryAI turns on call transfer on the Twilio trunk when you import numbers. ## Next steps > [card] SIP trunk | /docs/user-guides/integrations/sip-trunk | Connect a number you already have from a PBX, SIP provider or GSM gateway. > [card] Transfer to phone number | /docs/user-guides/chatbot/actions/transfer-to-phone | Let the agent hand a live call to a person.