1. Install the Twilio module
  2. Apply for the TWilio API Credentials
  3. Use the Client of Twilio module to send short messages

In this article, I’ll show you how to make a phone call in Python and play a voice. I’m sure there will be more scenarios for making a phone call in Python.

Note: This function needs to be upgraded to a paid account (before you can set the voice to play for receiving or making calls)

First, the results show:

Then, look at the code implementation:

The contents of the XML file in the url parameter above:

The code is still very simple. I think anyone who has read the previous article knows how to install Twilio and how to apply for API Credentials and Twilio phone numbers. This article will only cover the details that we haven’t covered yet.

The only thing I think is a bit strange about the above code is the URL parameter of the XML, which is used to indicate the action when making a phone call (such as playing a voice message, etc.). See the syntax of the XML:

www.twilio.com/docs/api/tw…

The address of the XML file and the address of the MP3 file to play in it must be public and directly accessible (200 OK, not 301, etc.), and the MP3 file must be content-type: audio/mpeg; Content-type: text/ HTML;

For additional questions, please refer to the Official Twilio documentation and Stack Overflow’s Twilio Tag discussion board:

  1. www.twilio.com/docs/
  2. Stackoverflow.com/questions/t…

The hand of a person using a smartphone

Is there anyone who needs Python learning materials? If you want to learn more about Python, you have to learn more about it