Menu

Expand
Rate this page:

Robocall-Resistant Voicemail with Add-ons and Functions

Twilio Add-ons are designed to enhance existing messaging and voice systems and APIs. In this tutorial, you will learn how to set up a voicemail using Twilio Functions, and then integrate it with Add-ons designed to filter out robocalls.

Set Up Your Voicemail

This tutorial assumes that you are completely new to Twilio, and have just created an account for Twilio Console. Additionally, this tutorial utilizes Twilio Functions for serverless operation, which helps with hosting, scalability, and maintenance of your voicemail. For more information about the service, we recommend taking a look at their landing page.

Twilio Functions only support Node.js.

Step 1: Within the Twilio Console, on the left navigation bar, click Functions and Assets, and select Services from the dropdown menu. Create a new Service, and give it a relevant name. In this example, the Service is named “Test-Voicemail”

Add-ons Voicemail Tutorial -- New Service

Step 2: Name your Service and click Next. You will be moved to the Development panel for your new Service. Here, we can create a Function that will be executed automatically when a call comes in. Click the Add+ button, select Add Function, and name the path to your Function in the resulting text field. For this example, the path is named “VoicemailHandling”

Add-ons Voicemail Tutorial -- New Function

Step 3: Once you see this screen, it’s time to replace the template code in your Function with some code that will record a voicemail. To do so, you want to first accept a call, prompt the user to leave a message, and then capture the recording. The code below serves this purpose, and is annotated for a more in-depth explanation of each section:

        
        
        
        Create a voicemail using Twilio Functions

        Voicemail Setup with Twilio Functions

        Create a voicemail using Twilio Functions

        Step 4: Click Save to save your code, and then click Deploy All to deploy your Service. The last step is to set up the Webhook to your application. To do that, you will need an active Twilio phone number.

        Obtain a Twilio Phone Number

        In order to set up a voicemail that will record calls for you, you’ll need an active phone number from Twilio, which can then trigger your application Webhook to obtain voicemails and the Add-ons data associated with them.

        Step 1: To get a Twilio Phone Number from the Twilio Console, select Phone Numbers from the navigation menu on the left side of the screen. From the dropdown menu, select Buy a Number

        Add-ons Voicemail Tutorial -- Buy a Phone Number

        Step 2: Once you’ve found a number that you like, buy it, go to the Active Numbers tab, and click on the number you just bought. For consistency, we recommend selecting a number with an area code similar to numbers within your area or region.

        Add-ons Voicemail Tutorial -- Phone Number Config

        Step 3: Within the Configure tab scroll down to the Voice and Fax section. There’s an option to set up a programmatic response to calling your number, which we can do now. Under A Call Comes In, change the default webhook to Function, and you should see additional boxes pop up in place of a URL input box. Select the service you just created, the environment you’re running it on (the default is ui), and select the function path you created.

        Add-ons Voicemail Tutorial -- Twilio Functions Webhook

        Step 4: Once you’re finished, click Save, and the equivalent webhook will be created for you. You now have a serverless line that accepts voicemail messages from your clients. To test your application, call your number, and you should hear the message you input, along with a beep that signals that recording has begun.


        To get your recording, go to the call log for your number and select View All My Call Logs. Select your call, and you should see the recording data. Documentation for programmatic retrieval of voicemails and other relevant data can be found within Twilio Programmable Voice’s API Reference

        Add-ons Voicemail Tutorial -- Recording Image

        Install and Configure an Add-on Service

        Now that you have an active Twilio number and a voicemail, it’s time to enhance it with Add-ons to improve the quality of the recordings in your mailbox. This tutorial will walk through the steps to make use of the Ekata Phone Validation Add-on, which filters robocalls so they are unable to leave voicemail messages.

        Step 1: Add-ons can be found in the Twilio Marketplace. To get there, select Explore Products on the bottom of the navigation bar, and scroll to the bottom.

        Add-ons Voicemail Tutorial -- Twilio Marketplace

        Step 2: Select the Add-ons panel, and select Ekata Phone Validation, which should be one of the first add-ons available to you.

        Add-ons Voicemail Tutorial -- Ekata Phone Validation

        Step 3: After you install and agree to the terms and conditions, you should now see a Configure tab for the Add-on. Since we need data on incoming voice calls, select that option and hit Save.

        Add-ons Voicemail Tutorial -- Ekata Config

        Integrate your Twilio Function with Add-ons

        The final step is to integrate the Add-ons data into the Twilio Function that you’ve set up. In order to do so, the voicemail code needs to be modified to take in the Add-ons data, which is served in the HTTP request being sent to your Function. You want to take the information and either accept the call if it’s a legitimate caller or block if it’s a robocall. Here is the code:

              
              
              
              Integrate a voicemail with the Ekata Phone Valid Add-on to block robocalls.

              Robocall-Filtered Voicemail using Ekata Phone Valid Add-on

              Integrate a voicemail with the Ekata Phone Valid Add-on to block robocalls.

              Save your code and click Deploy All. Your voicemail is now integrated with Add-ons, making it resistant to robocalls.

              Next Steps

              Once you have your voicemail set-up, there’s a lot more functionality that can be added onto it. Take a look at these resources to see how to further extend your voicemail:

              Check out the full Add-Ons API Reference documentation if you want to learn more about how add-ons work, or even how to publish your own.

              Alexander Chen
              Rate this page:

              Need some help?

              We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.

                    
                    
                    

                    Thank you for your feedback!

                    Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

                    Sending your feedback...
                    🎉 Thank you for your feedback!
                    Something went wrong. Please try again.

                    Thanks for your feedback!

                    thanks-feedback-gif