Twilio Studio makes it as simple as a drag-and-drop to build an IVR (Interactive Voice Response) for your business. With IVR, you can create a phone menu that’s easy to navigate by voice or keypress, and route users’ calls to the correct department in a snap.
We’ll start with a fresh Twilio Studio flow; log into your Twilio account and navigate to the Studio Dashboard, then tap the + icon to create a new flow. You can name your flow anything you like; we’re calling ours IVR.
You’ll notice that the canvas comes with a widget already in place -- that’s the Trigger widget, which kicks off our flow when the trigger we specify is fired. In this case, our trigger is going to be an incoming call, since we want callers to reach our automated menu.
We’ll start by dragging a Gather Input on Call widget onto the canvas, and connecting it to the Incoming Call trigger by dragging the red dot to the grey dot in the corner of the new widget. We can use this widget to specify what we want the menu to say when the caller picks up. In this example, we’re going with “Hello, how can we direct your call? Press 1 for sales, or say sales. To reach support, press 2 or say support,” but you can enter any message of your choosing, or select Play a Message from the dropdown to play an audio file instead.
The Gather Input on Call widget expects the user to press keys or say something after they hear the message. Let’s look at the key press option first.
We want to route sales calls to sales and support calls to support, so we’ll need some logic that will help us know which one the user wants to connect to. We’ll use the Split Based On… widget to help handle that. Drag it onto the canvas and connect it to the dangling User Pressed Keys dot from our Gather widget.
First, we’ll need to configure the variable we’re testing. In this case, we’re concerned with keys that the user is pressing following the Gather widget, so we’ll select Digits from the dropdown on the right-side panel.
Next, we’ll need to declare the choices we’re looking for in those key presses -- the digits 1 and 2. Tap the red New at the bottom of the Split widget to reveal the Transition On… dropdown menu. Select Condition Matches to create a new Transition.
In the right sidebar, find the new Transition that you just created, and select Equal To from the dropdown. We’re going to set this value to 1, to connect to sales. Save the new transition and it will appear on the widget.
Next, we’ll need a condition for if the user has pressed 2 for support. Just as with the first Transition, we’re going to tap New, then select Condition Matches…., then set the value equal to 2 in the sidebar and save. Our widget should look like this, with No Matches, 1, and 2 dangling from the bottom:
We’re going to need to connect those calls to sales and support, and the way to do that is with the Connect Call To widget. Drag two of those onto the canvas (one for sales and one for support). You’ll need to enter the Phone To Call for each -- do this by tapping on the widget and editing the field in the right sidebar to reflect the correct numbers for sales and support (the default number will be the one the user called from, so we’ll need to override this).
Next, we’ll need to connect the dots -- match the dangling dot from the Split widget that says 1 to the Connect Call To widget that you’ve set up for sales, and the dot for 2 to the widget for support. Voila! Key presses are now a functional part of your IVR.
Next, it’s time to wire up the other Split widget -- the one for voice input. Drag another Split Based On… widget onto the canvas, and set SpeechResult from your Gather widget as the variable to test. Connect the dots between the Gather widget’s User Said Something and the new Split widget you just added.
Just as before, we’re going to set conditions on our Split widget so “sales” goes to sales and “support” goes to support. Tap New to create each condition, then follow the same steps as before to create the condition matches on the second Split widget.
The final state of the canvas is that we have our Trigger widget take an incoming call, connect to the Gather Input on Call widget, then split to two Split Based On… widgets (one for key press and one for speech result), each of which has condition matching Transitions to route to a Make Outgoing Call widget for sales or support.
After we’ve saved and published the flow, the last thing to do is hook up our flow to a phone number! In the Twilio console, select Manage Numbers and choose the phone number that you would like to connect to your IVR.
Scroll down to the section for Voice and Fax, then select Studio Flow from the first dropdown and IVR (or whatever you’ve named your flow) from the second dropdown. Click save, and you’re all set!
Test out your brand new IVR by calling the Twilio number that you’ve set for your IVR, and enjoy traversing the automated menu!