One of the latest additions to the Twilio telephony platform is Studio, where you can publish Flows to manage inbound calls coming into your business. This article gives you a simple method using Twilio Studio, Functions and SendGrid to set up an intelligent Free IVR Online.
Create your own automated telephone answering service that will; answer your inbound calls, check the time of day against your business opening hours, route incoming calls to your landline or mobile number; and forward voicemail message voice recordings to email.
Free Online IVR for Small Business
Twilio Studio provides a free cloud communication platform to all Twilio customers, for setting up and creating amazing IVR call flows; to manage there inbound business calls, text messages and other interactions. With very reasonable prices for non-geographic numbers, local numbers and calling rates, these additional free cloud telecoms tools are hard to beat.
Register using this link and get $10 FREE CREDIT when you upgrade from your free trial on Twilio twilio.com/referral/0Bkojr
What will you need?
In order to follow this tutorial, you will need:
- Registered Twilio phone number that can receive voice calls.
- Free SendGrid account with a verified sender (email address or domain).
- A text editor like notepad for storing temporary notes.
OK, now that you have all of those at the ready, let’s get started…
1. Set-Up Twilio Studio Free IVR Online
Once you have logged into your Twilio account go to the Studio Dashboard and click the BIG RED PLUS button to create a new Flow. Give your new call flow a name and click NEXT, select the Start from scratch template and continue. You will now be presented with a new Flow, ready for you to set-up your free online IVR system.
Download Free Twilio Studio IVR Template
We’ve created a free Twilio Studio IVR template for you to download and import into your new Twilio Studio Flow. This tutorial is based around our template, so follow this link and download the template from our GitHub pages. Once you have the JSON file content you can simply import it into your new Flow by following the next steps.
Import Free Twilio Studio IVR Template
To import our free online IVR template, simply click on the Trigger widget in your new empty call flow and in the settings on the right-side panel, find the Show Flow JSON button. Paste our JSON script into the pop-up box (overwriting any existing content) and click SAVE.
Allow the platform to map out the content of the Flow and hey presto, you should see your free IVR call flow template all nicely laid out, ready for you to play with.
Customising Free Twilio Demo IVR
You will need to enter you business specifics into the Twilio IVR setup to finalise the call flow. See the detailed guidelines below on what you must change and some other options you can choose to customise this free online IVR template.
Twilio IVR Example Critical Changes
These are the 5 minimum changes you will need to make to your Twilio Studio IVR call flow:
- gather_input widget – set <Your Company Name>
- say_play_2 widget – set <Your Company Name>
- connect_call_1 widget – set <Your Call Number>
- record_voicemail_1 widget – set <TRANSCRIPTION CALLBACK URL>
- Business_hours widget – set <FUNCTION URL>
Besides these critical adjustments you have to customise, there are a few alterations you can make to change the way your online IVR system works.
Twilio Voice IVR System Optional Changes
In this Free IVR online call flow you can also customise some other features:
- Change the text to speech voice accent
- Select a male or female voice for outgoing IVR messages
- Change the ring delay before going to voicemail
- Select unusual or extended business opening hours
- Customise the IVR outgoing company greeting
- Change the in-hours outgoing voicemail greeting
- Change the out-of-hours voicemail greeting
Once you have finished customising your Twilio Studio Flow don’t forget to publish it, then you can continue with this tutorial.
2. Free IVR Business Hours Call Routing
To activate the time based call routing and manage your business opening hours in your free IVR online system, you will need to set up a function in your Twilio account. Go to the Functions section and add a new function; with the name set as UK Business Hours, a path of uk-business-hours and then paste the content below:
Twilio UK Business Hours Function
exports.handler = function(context, event, callback) { // With timezone: // In Functions/Configure, add NPM name: moment-timezone, version: 0.5.14 // Timezone function reference: https://momentjs.com/timezone/ let moment = require('moment-timezone'); // // timezone needed for Daylight Saving Time adjustment let timezone = event.timezone || 'Europe/London'; console.log("+ timezone: " + timezone); // const hour = moment().tz(timezone).format('H'); const dayOfWeek = moment().tz(timezone).format('d'); if ((hour >= 9 && hour < 17) && (dayOfWeek >= 1 && dayOfWeek <= 5)) { // "open" from 9am to 5pm, GMT. response = "open"; } else { response = "after"; } theResponse = response + " : " + hour + " " + dayOfWeek; console.log("+ Time request: " + theResponse); callback(null, theResponse); };
After clicking save, copy the path URL to your notepad for use in your Business_hours widget.
Unusual or Extended Opening Hours
Alter the following line of code in your Function, if you need different opening times from the usual (9-5 mon-fri):
if ((hour >= 9 && hour < 17) && (dayOfWeek >= 1 && dayOfWeek <= 5)) {
Business Hours Function NPM Module Dependency
As those with a keen eye will notice from the comments in this script, you will need to import an NPM Module for this Function’s Daylight Saving Time to work correctly. These Function Packages enable developers to access an incredible collection of tools provided by the node.js community.
In the Functions Configuration section of your account create a new entry under Dependencies. Set the name to moment-timezone and the version as 0.5.14.
3. Free IVR Voice Recordings to Email
While the Voicemail Twimlet has email forwarding built in and teamed with out previous post about Twilio call routing, you should be able to piece something together. Many Twilio users find it limiting and need a way to forward voicemail recordings to an email address, without the Twimlet or a complicated web server.
We will be using Twilio’s own email sending platform called SendGrid, to forward the voice recordings of your voicemail messages to your chosen email address.
Twilio SendGrid Email SMTP API
In order to use the Twilio SendGrid API to send emails you will need a SendGrid API key. First, create a SendGrid account (if you don’t have one already), confirm your email address; then head over to the API Keys area in the SendGrid dashboard and create an API Key with Full Access.
TOP TIP: Be sure to save the SendGrid API Key Secret to your local drive or somewhere safe (you will need this again and you cannot recover it from your account).
SendGrid Verified Email Sender
You will also need to verify one of your emails or domain name, to send from it using SendGrid. To do this, go to the Senders page for single email addresses (or Sender Authentication for domains), click Create New Sender, fill out the info, then go to your email inbox and click the link in the verification email.
Twilio SendGrid Voicemail to Email Function
Now let’s write another Twilio Function. This is the Voicemail to Email Function and it will initialise a SendGrid mail client, then use it to email your voicemail message voice recording URL as a link.
Create a new Function with the name as WR VM-Email and path set to record2email. Then paste the code below and click save (don’t forget to copy the full path URL to your notepad and add it to your record_voicemail_1 widget).
//Initialize SendGrid Mail Client const sgMail = require('@sendgrid/mail'); // Define Handler function required for all Twilio Functions exports.handler = function(context, event, callback) { // Build SG mail request sgMail.setApiKey(context.SENDGRID_API_SECRET); // Define message params const msg = { to: context.TO_EMAIL_ADDRESS, from: context.FROM_EMAIL_ADDRESS, text: `Recording URL is: ${event.url}`, subject: `New Voicemail from: ${event.From}`, }; // Send message sgMail.send(msg) .then(response => { console.log("Neat.") callback(); }) .catch(err => { console.log("Not neat.") callback(err); }); };
Voicemail to Email Function Environment Variables & Dependencies
To make requests with SendGrid’s API, we need a way to authenticate. To do this, we’ll use your SendGrid API Secret that you created earlier and should have a note of ready and waiting.
Add a new Environment Variable in your Functions Configuration section called SENDGRID_API_SECRET and paste in your SendGrid API Key Secret (this should begin with SG).
We also need to make Environment Variables for the email addresses that you’ll be sending your voicemails To and From. Create a TO_EMAIL_ADDRESS variable and enter the email to receive your voicemails. Create the Environment Variable FROM_EMAIL_ADDRESS and enter one of the verified sender emails in your SendGrid account (or one from an authenticated domain name).
In addition, to the Environment Variables, you need to include the “@sendgrid/mail” library in your Dependencies on the same page. Scroll down to Dependencies, add @sendgrid/mail and the version 6.3.1, then click save.
Automatic Voicemail Message Transcriptions
We’ve included the feature for an automated transcription of the voicemail message to be included in the email. Do bear in mind this is a free service and very reliant on clear pronunciation by the calling. This feature can be a little ‘hit and miss’ so just disable it if you want to, find the TRANSCRIBE AUDIO TO TEXT setting, in the record_voicemail_1 widget.
4. Configure Your Twilio Number
Now you just need to configure the Incoming Call webhook of your Twilio Number to use the free IVR online Twilio Studio Flow you just created and customised. In your Twilio Dashboard click the number you want to use for your voicemail in your Active Numbers and configure the settings as below.
Scroll down to the “A CALL COMES IN” dropdown in the Voice section and select Studio Flow. Select your new Flow in the Select a Flow dropdown to the right. Do the same for the “PRIMARY HANDLER FAILS” dropdown and set the “CALL STATUS CHANGES” as HTTP POST to the WEBHOOK URL of your new Studio Flow; the URL can be found in the settings of the Trigger widget, at the very top of your call flow. These settings ensure that Twilio handles call disconnections and hang-ups correctly.
If everything went smoothly, you should now hear your voicemail greeting when you call your Twilio number and the voicemail you leave should be emailed to you.
5. Test Twilio Studio Free IVR Online
Using a phone number that is not used in the new Flow, call your Twilio phone number and wait for an answer. If you are outside the business hours that you setup, you will hear the message, “Thank you for calling <Your Company Name>. Our office, is now closed. Please leave a message after the tone”.
Otherwise, during working hours, you will be connected to the gather_input widget, hear the text to speech outgoing company greeting and call forward to the phone number you set.
Get $10 FREE CREDIT when you upgrade from your free trial on Twilio twilio.com/referral/0Bkojr Share on X
Troubleshooting Your Free IVR Online
If your call fails at any point, retrace your steps through this tutorial and make sure you haven’t missed anything out. Common issues are: not having the correct email or domain verified in SendGrid, correct formatting of ‘Call to’ number (+443300581580), missing Dependencies or Environment Variables.
Let us do it for you…
If setting up this Free IVR Online all seems a bit too much hassle, why not let our team set this up for you. At a low fixed price we will configure your call flow and test it all out for you (we just need to be set up as a DEVELOPER in your Twilio account).
You can simply get in touch now to let us know this is what you need and we’ll take it from there.
Founder and strategic mind behind White Rabbit. Associate Member of the Chartered Institute of Marketing, focused on serving clients with a creative and ethical business model. Digital philanthropist giving time to support charitable groups, projects and organisations; that revolve around the arts, wildlife conservation, local community and heritage crafts.