How to integrate Apollo AI with Twilio calls

The instructions below are for desktops and laptops only.

Sometimes, your customers may prefer talking to an agent instead of chatting with a bot. With tawk.to’s Apollo AI, you can delight your customers with AI-assisted call escalation.


Using a VoIP service, you can get Apollo AI to call your support team when your customers ask to speak to an agent.


In this article, we show you how to do this using Twilio and Apollo AI’s API Integration. You may repurpose the instructions below for other VoIP services, such as Ring Central, Bandwidth or Amazon Connect.

First, set up Twilio

1. Sign up for a Twilio account, or log in if you already have one.

          a. Get your Account SID and Auth Token from the Twilio Console.

2. Create a TwiML App:

          a. On the Twilio Console, go to Develop > Voice > Manage > TwiML apps.

          b. Click Create new TwiML App.

          c. Set the Voice Request URL to point to your server endpoint that will handle the call.

          d. Take note of your TwiML App SID for later.

3. Create an API Key that authorizes you to interact with Twilio APIs:

          a. Go to API keys and tokens.

          b. Click Create API key.

          c. Take note of the key's SID and Secret.
4. Create a Twilio service:

         a. Go to Develop > Functions And Assets > Services.


         b. Click Create service.

         c. Set the following environment variables:

      • TWIML_APPLICATION_SID: Your TwiML App SID.

      • API_KEY_SID: The API Key SID.

      • API_KEY_SECRET: The API Key Secret.

      • CALLER_ID: Your Twilio number (include a + and the country code).

5. Configure the dependencies for your Twilio Service:

          a. Import the necessary NPM modules for your serverless functions:

6. Create a Twilio Function to issue voice tokens:

          a. Go to Develop > Functions and Assets > Functions.

          b. Create a /voice-token function to issue voice tokens for authentication.
7. Set up your server:

          a. Create a server using a framework like Flask (Python) or Express (Node.js) to handle the outbound call logic.Here’s an example in Python (Flask):
8. Test your setup:

         a. Use tools like Ngrok to expose your local server to the internet for testing.

         b. Initiate a call by sending a POST request to your /make_call endpoint with the to parameter set to the recipient's phone number.

Create a swagger.json OpenAPI schema

Here’s an example:
Note: Replace “+12345678” with your phone number(s).

Create the script for the API call

Here’s an example:
Note: Replace “+12345678” with your phone number.

Disable Apollo AI’s escalation settings

1. Log in to tawk.to.


2. On your dashboard, select the property for which you want to set this up. Hover over the property name to ensure you’ve selected the correct one.

3. Click Add-ons on the top menu.

4. Click Settings under AI Assist.

5. Scroll down to Escalation. Disable the When a visitor asks to speak to a human toggle button.

If you don’t see the toggle button, select a shortcut first, and then disable the toggle button.

Complete the integration
1. Go to Integration/API. Click Add Tool under API.

2. Enter the URL of your swagger.json OpenAPI schema in Schema File URL.

3. Enter the URL of Twilio’s API in API base URL.

4. Select the authentication method and click Save.

With these steps, you’ll be able to receive phone calls from Apollo AI via Twilio. Remember to test the integration before you deploy. Identify and resolve any potential issues that may affect your customers’ experience.


If you have feedback about this article, or if you need more help:

Was this article helpful?

11 out of 20 liked this article

Still need help? Message Us