Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

How to build an IVR with Twilio Studio


Twilio Studio is a visual drag-and-drop editor for creating communications workflows. Studio Flows are composed of widgets that represent operations in the Twilio API. By connecting these widgets, you can build applications, such as an IVR (Interactive Voice Response) system, without writing code.

If you've ever pressed 1 on your phone to connect to an agent, you've interacted with an IVR. An IVR is an automated phone menu that lets callers navigate by voice or keypress so that calls are routed to the appropriate destination.

In this tutorial, you'll create a basic IVR that:

  • Collects a keypress or speech input.
  • Routes callers to one of two phone numbers (Sales or Support).
(information)

Info

New to Twilio Studio? Review the Getting started guide for Twilio Studio before beginning this tutorial.


Prerequisites

prerequisites page anchor

Before you start, you need:


Create a new Studio Flow that will hold the logic for the IVR.

Use the Twilio Console to create a Flow from scratch. If this is your first Flow, see Create a Flow for detailed steps. Name the Flow, for example, "IVR Tutorial."


The first task is to gather information from callers.

  1. In the Widget Library, locate the Gather Input on Call widget and drag it to the Canvas.
  2. Connect the Trigger (Start) widget to the new widget by dragging from the red dot under Incoming Call to the Gather widget. This connection tells the Flow how to handle an incoming call.

Configure the Gather Input on Call widget

configure-the-gather-input-on-call-widget page anchor
  1. Select the widget on the Canvas and, in the configuration pane, rename it to greet_caller.

  2. Ensure Say/Play a Message is set to "Say a message," then enter the following prompt (or similar) in the text field:

    Hello, how can we direct your call? Press 1 for Sales or say "Sales". Press 2 for Support or say "Support".

  3. Scroll to Stop gathering on keypress?, choose YES, and set Stop gathering after _ digits to 1. This setting prevents the widget from waiting for additional input after the caller presses one key.

Config screen for gathering input on call, stop on key-press set to 'Yes', stop after entering 1 digit, with save button.

With caller input collected, determine where to route the call.

Split based on key press

split-based-on-key-press page anchor
  1. Drag a Split Based On… widget to the Canvas and connect it to the User Pressed Keys transition from greet_caller.
  2. Rename the widget to split_key_press.
  3. In the configuration pane, set Variable to test to widgets.greet_caller.Digits.
Connect split_key_press widget to User Pressed Keys transition from greet_caller widget.

Create transitions for key presses

create-transitions-for-key-presses page anchor
  1. In the Transitions tab of split_key_press, click New, select Condition Matches, and set If value equal_to… to 1.
    This transition represents callers who pressed 1 for Sales.
  2. Repeat the step above, creating a second condition where the value equals 2 for Support.

The widget now shows transitions for "1," "2," and No Matches.

split_key_press with transitions for None, 1, and 2.

Use the Connect Call To widget to forward the call.

  1. Drag two Connect Call To widgets to the Canvas—one for Sales and one for Support.
  2. Rename them connect_call_to_sales and connect_call_to_support.
  3. For each widget, choose Single Number and enter the appropriate destination phone number (use different test numbers for Sales and Support).
Two widgets and the widget configuration panel for call connection.

Next, handle callers who speak their selection.

  1. Drag another Split Based On… widget to the Canvas and rename it split_voice_input.
  2. Set Variable to test to widgets.greet_caller.SpeechResult.
  3. Connect User Said Something from greet_caller to split_voice_input.
Split based on widget for voice input linked to User Said Something transition.

Create transitions for speech input

create-transitions-for-speech-input page anchor
  1. In Transitions for split_voice_input, click +, choose Condition Matches, select Contains, and set the value to Sales.
  2. Add another Contains condition with the value Support.

Using Contains instead of Equal To allows the match even if punctuation is present (for example, "Sales.").

Twilio Studio IVR tutorial conditions for SpeechResult.
  1. Connect the Sales transition to connect_call_to_sales and the Support transition to connect_call_to_support.

The final Canvas should show:

  • Trigger (Start)Gather Input on Call (greet_caller)
  • greet_callersplit_key_press (Digits) → Connect Call To (Sales or Support)
  • greet_callersplit_voice_input (Speech) → Connect Call To (Sales or Support)
Twilio Studio IVR tutorial full flow.

After saving and publishing the Flow, connect it to a Twilio phone number.

Connect your Twilio phone number to the IVR flow

connect-your-twilio-phone-number-to-the-ivr-flow page anchor

Once you're happy with your Flow and you've published all changes, you can connect it to a Twilio Number so people can start interacting with it.

Navigate to the Active Numbers section of the Twilio Console(link takes you to an external page) and click on the number you'd like to connect to the Flow. (If you do not have any phone numbers, you can purchase one from the Console(link takes you to an external page).)

After clicking on the number, you will see its configuration menu where you can connect the number to your Studio Flow.

To configure this number to trigger your Studio Flow from an Incoming Call, scroll down to the Voice & Fax section of the configuration menu. Under Configure With, select the dropdown option "Webhook, TwiML Bin, Function, Studio Flow, Proxy Service". Then, under A Call Comes In, select the dropdown option "Studio Flow". You'll see another dropdown menu appear where you can select the Studio Flow you'd like to connect to when a call comes in to this number.

Voice configuration with active US1 region routing and Studio Flow selection options.

Choose the Flow you'd like to connect the number to, and then press Save to save these changes. Your Flow is now connected to your Twilio number!

Call the configured Twilio number and verify that keypress or speech input routes the call to the correct destination.


Explore additional Studio tutorials: