Receive Telephone Calls (Twilio)

The Sandbox chat is great for online websites that need a digital employee to handle customer inquiries, among many other use cases. However, you may find that a better-suited option for your use case is having your digital employee handle telephone calls. In this case, you'd need to integrate Twilio. Twilio Integration supports both incoming and outgoing phone calls. In other words, you can use this integration to call your agent, or an agent can use it to call you.

Goal: Integrate Twilio and allow for calling a digital employee agent.

If you don't want to create a new agent, use your existing agent from the Embedded Instructions tutorial and simply create a new Flow and add a new Sandbox connector (Idn = connector_call). Alternatively, let's start fresh and create a new agent. Follow the steps outlined in the "Hello World," which are:

  • Create an Agent
  • Create a Sandbox Connector
  • Create a Flow
  • Add a User
  • Create a Skill
  • Add Code to the Skill Script
  • Copy the Skill Script from Embedded Instructions.

Set Up a Twilio Account

Navigate to the Twilio website and click Sign up. Once you have an account, log in and navigate to My first Twilio account at the top-left corner. Under "Account Info" you will see your "Account SID" and "Auth Token."


Ensure your Twilio account is funded with at least the minimum amount.

Add Twilio Integration Settings

You need to add Twilio integration settings for the platform to communicate with your Twilio account.

  1. Navigate to the Integrations page from the left-side panel on the platform.
  2. Click the gear icon on the “Twilio Integration” item.
  3. Copy your "Account SID" and "Auth Token" from Twilio into the available fields.
  1. Click Save.

Create a Twilio Connector

A Twilio connector needs to be created, which will be used to create an Event Subscription.

  1. Click the plus icon on the “Twilio Integration” item.
  2. Select a "Phone Number."
  3. Fill in the connector "Title" and "Idn." It is advisable to use the format tw_[phone number] for the "Title" and "Idn" to easily see the number being used for a particular connector. For example, tw_6592272513.
  4. Select the "Agent" you want to answer the phone.
  5. Choose the "Language" of your agent. In this case, type "en-US" for English.
  6. Choose the "Voice" of your agent. In this case, type "Polly.Matthew-Neural."
  7. You can add an optional "Greeting Phrase" if you'd like your agent to answer the phone in a specific way.
  8. Click Save.

Enable the Twilio Connector

Once a connector is created, its status will be "Stopped," and you will need to enable it.

  1. Click the three dots icon on the right of the created connector.
  2. Click Run.

Create an Event (Twilio Integration)

  1. Navigate to your agent's Flow.
  2. Click the plus icon next to the Event Subscription section on the left-side panel.
  3. Under the “Event Idn,” select “user_message” from the dropdown.
  4. Under “Integration,” select “twilio” from the dropdown.
  5. Under “Connector,” select “tw_[phone number]” from the dropdown.
  6. Under “Skill selector,” select “skill_idn” from the dropdown. You are telling your flow that when a user sends a message from the Sandbox chat, select a specific Skill to activate.
  7. In this case, you want to activate the newly created Skill. Select it from the “Skill name” dropdown.
  8. Add an “Event description.” This field is optional but will help in the future when identifying the purpose of an event from a complex flow containing multiple event subscriptions.
  9. Click Create to save the event.

Test Functionality

  1. Click Save and Publish in the top-right corner of the Flow Builder.
  2. Call the number you selected when setting up the Twilio connector. You can also see this number by looking at the event you just created (i.e., tw_[phone number]). Your digital employee should answer the phone. Have fun asking your agent questions and hearing the responses.