Voice Biometrics Using Twilio Serverless and VoiceIt

Team discussing how to apply Voice biometrics around a table
September 27, 2022
Written by
Roo Kosherbay
Contributor
Opinions expressed by Twilio contributors are their own
Reviewed by
Paul Kamp
Twilion

Biometrics technology is frequently used for authentication and identification purposes across industries, including financial services, healthcare, and the humanitarian sector. Integrating biometrics into development and humanitarian assistance programs can help to identify the people targeted for assistance, reduce fraud and de-duplication, and simplify registration and identification.

The World Food Programme uses biometrics to make sure that the right assistance reaches the right people. Vodacom Tanzania uses voice biometrics to enable people with disabilities to access their products and services more easily. Chase Bank uses Voice ID to identify callers accessing personal bank account information. Another interesting fact about voice biometrics is that if compromised, they can be invalidated by enrolling a new phrase. If your face, fingerprint, or iris data is hacked you cannot invalidate the data, and your identity is lost forever. It's complicated, however – we recognize that the use of biometrics has pros and cons, and it's up to each organization to weigh those for their program.

This tutorial shows how to use Twilio Programmable Voice with a voice biometrics integration to identify callers accurately and with just a few lines of code. In this tutorial, we are using VoiceIt as the voice identification system, but you can use other voice biometric vendors such as Veridas.

Prerequisites

For this tutorial, you’ll need:

  • A VoiceIt account. VoiceIt offers an API for voice biometrics that we'll be using during this blog post. Follow this link to sign up: https://voiceit.io/getstartednow. You can use a different API to integrate voice biometrics with Twilio, however you'll need to change some of the code.
  • A Twilio account. Sign up here for a free trial: https://www.twilio.com/try-twilio
  • An Airtable account. Sign up here for a free trial: https://airtable.com/#. You could use a different database or CRM here as well with some code changes.
  • A Linux or MacOS terminal with npm and the Twilio CLI installed.

Currently, the project is deployed in Node version 14. To make things consistent, it would be best to run it locally on Node 14 as well.

Build a VoiceIt integration

We will use Twilio Serverless and Programmable Voice to build a call flow that authenticates a caller using voice biometrics through VoiceIt. Each caller’s phone number and corresponding VoiceIt User Id are stored in Airtable.

Step 1: Clone the repo

The first step is cloning the repository that hosts the code for this demo.

  1. In your terminal, clone the tutorial repo by running: git clone https://github.com/Gunjan-twilio/voiceit.git
  2. Using a code editor of your choice, copy the contents of .env.example into a new file called .env in the same directory.

Step 2: Set up Airtable

The next step is to set up Airtable, a low-code collaborative platform, to store each caller’s phone number and biometric user ID. You could also choose to modify the code to use a different CRM or database.

  1. Log in to Airtable. Create a new workspace or use an existing one to create a new base.
  2. Name the table “Voice Biometric”
  3. Rename the default primary field to “Phone Number”. Add another field for “Biometric UserId”. Your table should look like this:
Airtable base example
Twilio Integration on VoiceIt
VoiceIt credentials
  • Get your VoiceIt API key or VoiceIt API token 
  • Paste these values into your .env file accordingly.
  • Step 4: Deploy to Twilio Serverless

    The Twilio Serverless API allows you to deploy Twilio Functions and Assets programmatically. You’ll use this API to create a Service that executes code to identify callers.

    1. In your terminal, navigate into the root directory of the repo you cloned above.
    2. Run npm install to install the necessary packages.
    3. Authenticate into your Twilio account in the command line by running the following command, replacing the default values with your own. You can find these values in the Twilio Console.
      export ACCOUNT_SID=ACXXXXXXXXXXXXXXXXXXXXXXXX 
      export AUTH_TOKEN=XXXXXXXXXXXXXXXXXXXXXX
    4. Run twilio serverless:deploy to deploy your functions and assets to Twilio’s serverless environment.

    Step 5: Connect your Phone Number

    Now it's time to put it all together! The final step requires linking the code you just deployed to a Twilio phone number so you can test your experience out.

    1. If you do not already have a Twilio Phone Number, follow these instructions to buy one.
    2. Access the Active Numbers page in the Console. Click the desired phone number to modify.
    3. Scroll to the Voice & Fax section. Under Configure With, select Webhook, TwiML Bin, Function, Studio Flow, Proxy Service from the drop down.
    4. Under A Call Comes In, select Function.
    5. Under Service, select “voiceit”
    6. Under Environment, select “dev-environment”.
    7. Under Function Path, select “/voice/incoming_call”.
VoiceIt configuration with Twilio webhook
  • Test it out! Call your Twilio number and register yourself using VoiceIt biometric identification. You’ll be asked to enroll yourself by repeating your VOICEPRINT_PHRASE three or more times. After completion, refresh your Airtable table to see your phone number and biometric user id.
  • Demo Experience

    Optional: Change the Demo Language

    Twilio supports text-to-speech capabilities in dozens of languages using Twilio Markup Language (TwiML). VoiceIt supports many languages and dialects, listed here. You can change the phrase and language of your demo by updating environment variables VOICEPRINT_PHRASE and CONTENT_LANGUAGE, and redeploying the demo by running twilio serverless:deploy. To change these variables in VoiceIt, follow these steps:

    1. Go to voiceit.io and login
    2. Go to the “Voiceprint phrases” section or directly to link:  https://voiceit.io/phraseManagement
    3. Type in your new phrase and select the desired content language from the drop down
Setting a VoiceIt language
  • Request the new phrase by clicking the “Request New” button, and look for an email that describes the next steps. Usually a new phrase requires 10 recordings from two different people to be approved, but these requirements can be more or less strict depending on the phrase and content language.
  • Once the phrase is approved, make sure to change the environment variables CONTENT_LANGUAGE and VOICEPRINT_PHRASE to their corresponding values. For the example above, it would be:
Setting a Russian VoiceIt voiceprint phrase
  • Tips:

    1. When entering content language make sure to type it in exactly like in the content language table in VoiceIt documentation here.
    2. Try to choose phrases that are simple and are logically straightforward. People often forget the correct order of the words and swap words with synonyms.
  • Conclusion

    Congrats! You’ve built a voice biometric identification phone line. Here's a video of the demo in action:

     

This solution could be used for identifying healthcare patients, independent family members on a shared phone number, bank customers, or vulnerable citizens with limited forms of identification. You could expand this demo to include other Twilio services such as Twilio Pay to accept authorized payments over the phone, and view key quality analytics using Voice Insights.

Angela Wieber is a Principal Solutions Engineer at Twilio, where she loves building and educating on cloud-based technologies that enable critical communications. She is based out of Austin, TX, home of the best BBQ and live music venues. She can be reached at awieber@twilio.com

Roo Kosherbay is a Full-Stack Software Engineer at VoiceIt, where he maintains a handful of projects that involve Golang, React, and Docker. Outside of work, his dog Kanga and Roo (Get it? 🦘) like to explore many of Minneapolis’ parks, forests, and lakes. He can be reached at rustam@voiceit.io