Finland

Selecting the “From” number to use for voice solutions within a single country is straightforward because there is typically just one phone number. However, many voice solutions need to make calls across the globe, and the optimal customer experience for these outgoing calls is to provide localized “From” numbers. For globalized voice solutions making outgoing calls, we recommend that customers implement a process for selecting FROM numbers based on the specific TO number for each call.

While you could certainly build a solution internally to select FROM numbers before making API calls to Twilio to initiate outgoing calls, this blog post outlines a solution that uses Twilio Functions to handle FROM number selection on-the-fly. This solution also uses Twilio Lookup to determine the country code for each TO number and also validate the TO number format before initiating the outgoing call.

FROM number selection is relevant to any solution Finland Phone Number that needs to initiate outgoing calls. This blog post will walk you through building a two factor authentication (2FA) solution that can receive API requests, select the best FROM number for a given TO number, then initiate Studio Flows to deliver 2FA codes via voice.

Outgoing voice call FROM number selection architecture

Let’s take a quick look at the solution.

 

  • POST call to a Twilio Function starts things off
  • The Twilio Function calls the Lookup API to validate the number formatting and get details on the phone number
  • Based on the details returned from the Lookup API, the Function selects the best FROM number to use for the outgoing call
  • The Function creates a Studio Flow “Execution” which makes the outgoing call and delivers the 2FA code

Prerequisites

  • A Twilio Account – Sign up for free today if you don’t yet have an account
  • Twilio CLI – CLI Quickstart
  • Twilio Serverless Plugin – Install
  • Two Twilio Numbers with Voice capability – Purchase a number

Let’s Build It!

Initial Setup and Twilio Studio

  1. Purchase two Twilio Phone Numbers
  2. Clone this repo
  3. From the repo directory, rename sample.env to .env
  4. From the repo directory, enter twilio serverless:deploy (you may need to run twilio login first!)

Moreover, The twilio serverless:deploy command will build a service in your Twilio account and upload some assets. The output of the command will look like this:  Best database provider | Buy Mobile Database

Copy down the Domain and the full url for the Asset that ends with “/create-studio-flow.html”. Both are marked with a red arrow in the image above.

Moreover, Paste the url that ends with “/create-studio-flow.html” and was copied in the step above, into a web browser. That will bring up a simple single page app, or SPA, that will create a studio flow for you. The SPA will look like this:

Leave a Reply

Your email address will not be published.