

This verb is used to collect digits from the caller. One of such classes is the Gather class which is used for working with TwiML’s verb. The Python Twilio library provides some helper classes for working with TwiML. We’ve defined a predefined message format and set of instructions to speak using the Twilio Markup Language (TwiML), which at its core is an XML document with special tags defined by Twilio.

Let’s go over what’s happening in this function. The incoming_voice_call() function will be executed when our Twilio phone number receives a phone call. The load_dotenv() function loads our environment variables from a. Run the following command on your terminal window to start ngrok:Īt the top of this file, we’ve imported all the dependencies our project will be needing. Thankfully, this is where Ngrok comes in handy, allowing us to set up a temporary public URL so that our app is accessible over the web. Since we’ll be building our application locally, there is no way for Twilio’s requests to reach our application. To be able to successfully respond to and process incoming calls, we need to configure an endpoint where Twilio can send an HTTP POST request whenever our Twilio phone number receives an incoming call. Twilio makes use of webhooks to asynchronously notify our application when certain events occur. Note that if you have a trial account you will be using your trial account funds to make this purchase. Click “Buy” to purchase the number that you like. Next, you’ll be presented with a list of phone numbers along with their location, type, capabilities as well as pricing that match your search request. If you would like the phone number to support other communication capabilities besides voice calls, you can select any other options you wish. For the “Capabilities” section, make sure the “Voice” checkbox is selected. Fill the “Number” and “MATCH TO” fields to suit your needs. Select the “Country” you want the phone number to be from. You’ll be presented with a screen similar to the one below

Click the “+” sign to start the process of buying a new number. Head over to the Phone numbers section on the Twilio Dashboard. If you don’t already have one, we’ll go over how you can purchase one in this section. Before we can get started with making outbound voice calls via Twilio, you’ll need to have a voice enabled Twilio phone number.
