Level up your Twilio API skills in TwilioQuest, an educational game for Mac, Windows, and Linux. Download Now
Build the future of communications.
Start building for free
  • By Miguel Grinberg
    Play Chess with a Friend on WhatsApp using Python and Twilio Play Chess with a Friend on WhatsApp using Python and Twilio

    While most of the world is under some form of stay-at-home orders to prevent the spread of COVID-19, we are constantly looking for new ways to entertain ourselves and remain connected with family and friends.

    When I was little I used to play chess a lot, so now that I have additional time on my hands I decided to start playing again. The thing is, nobody in my immediate family plays chess, so I had this idea of using WhatsApp to play a game of chess against a remote friend.

    Chess game demo

    By the end of this tutorial you will know how to use the Twilio API for WhatsApp to implement a turn-based game that requires sending messages and images between multiple participants. You will also learn about how to manage a game of chess in Python, but even if chess isn’t your thing, you will be able to replace the chess …

    Read More
  • By Miguel Grinberg
    Build a COVID-19 Bot with Python and Twilio Autopilot Build a COVID-19 Bot with Python and Twilio Autopilot.png

    Twilio Autopilot makes it easy to build conversational bots that provide information to users in a highly engaging and intuitive format. A single Autopilot bot can be deployed on several channels including SMS, Voice, WhatsApp, Slack, Alexa and more.

    In this tutorial we are going to build a bot that provides COVID-19 stats for all countries using a purely conversational style. We will train the bot with example sentences to help it extract meaning from the freeform text entered by the user. Once you learn how this specific bot works, you will be able to adapt it to other data sources.

    Autobot conversation

    The aspects that make this bot interesting that I’d like you to notice are:

    • The user makes requests in an informal and conversational tone. Autopilot makes it very easy to “teach” the bot how people ask questions using freeform language, and how to extract the actual information embedded in …
    Read More
  • By Miguel Grinberg
    Build a Video Chat Application with Python, JavaScript and Twilio Programmable Video Build a Video Chat Application with Python, JavaScript and Twilio Programmable Video

    The efforts to limit the spread of COVID-19 around the world have forced a large number of people to work from home and this has naturally created a surge in interest for communication and collaboration tools.

    In this article we are going to look at a video conferencing solution, but instead of turning to a third-party system we are going to take the do-it-yourself approach and build our own. Our system is going to run on modern desktop and mobile web browsers, so participants will not need to download or install any software on their computers. The server-side portion of the project is going to use Python and the Flask framework, and the client-side is going to be built in vanilla JavaScript, with some HTML and CSS sprinkled in the mix for good measure.

    If you are worried that this is going to be a long, difficult and obscure tutorial …

    Read More
  • By Miguel Grinberg
    How to Run a Flask Application How to Run a Flask Application

    For many years the famous “Hello, World” example Flask application was 7 lines long. Below you can see a snapshot of the Flask website as it looked on June 12th, 2017:

    old flask website

    This example application then was shortened to just 5 lines. Here is the same page on June 17th, 2017:

    new flask website

    As you can see, the core of the application has not changed, but the method by which the application server is started has indeed changed, and in a very significant way. While previously a simple app.run() call inside the application script was used, now there is a flask run command, plus a FLASK_APP environment variable.

    While the design of the Flask website has changed considerably in the years that followed, as I’m wri …

    Read More
  • By Miguel Grinberg
    Receiving Emails with Python, Flask and Twilio SendGrid Receiving Emails with Python, Flask and Twilio SendGrid

    If you search online for tutorials or guides on integrating emails into your Python web application, in particular in relation to the Flask framework, you are going to find a lot of content on sending emails, but little or nothing on how to receive and process emails.

    The reason is that setting up an application to receive emails is incredibly difficult if you want to do it yourself. Luckily Twilio SendGrid includes the Inbound Parse feature, a greatly simplified method for receiving emails based on webhooks.

    In this short tutorial you are going to learn how simple it is to receive emails on your own domain, all from a Flask application and with the help of Twilio SendGrid.

    Tutorial Requirements

    To follow this tutorial you will need to have the following items:

    • Python 3 — If your operating system does not provide a Python 3 interpreter, you can go to …
    Read More
  • By Miguel Grinberg
    Serverless Phone Number Validation with AWS Lambda, Python and Twilio Serverless Phone Number Validation with AWS Lambda, Python and Twilio

    If your application requests phone numbers from your users, it’s a good idea to ensure that the numbers they provide are valid. The Twilio Lookup API provides an easy way to obtain information about any phone number, such as validity, carrier, line type, and even caller ID information for certain numbers in the United States.

    In this article, you will learn how to build a simple serverless function that performs phone validations. The application will be hosted on the AWS Lambda serverless platform and will be written in Python. Even if phone validation isn’t your thing, you will find that the techniques presented in this article can be applied to other APIs from Twilio or even other service providers.

    Tutorial Requirements

    To follow this tutorial you need the following items:

    Read More
  • By Miguel Grinberg
    SMS Doorbell with MicroPython and Twilio SMS Doorbell with MicroPython and Twilio

    The Internet of Things (IoT) has the potential to touch not only every industry, but also most everyday aspects of our lives. As a software developer, I’m excited about how low the barrier of entry is considering the low cost of IoT hardware and the wide availability of development tools in the open-source ecosystem.

    In this article, I want to show you how to build an IoT doorbell that sends you an SMS instead of producing sound. This project should give you a good idea of the kinds of projects you can build on your own with cheap microcontroller hardware using MicroPython and the same Twilio APIs that many users know and love.

    The project that we are going to build is an SMS doorbell using an ESP8266 microcontroller, a push button, MicroPython, and Twilio’s Programmable SMS service.

    Building an SMS Doorbell

    This is the perfect project if you are …

    Read More
  • By Miguel Grinberg
    Push Two-Factor Authentication in Python with Twilio Authy Push Two-Factor Authentication in Python with Twilio Authy

    Two-Factor Authentication (2FA) is one of the most effective ways to increase the security of online accounts and consequently reduce online identity theft. The 2FA implementation used by most applications is based on the Time-based One-Time Password algorithm, which requires users to read a numeric code from a hardware token generator or smartphone app and enter it on an application’s website to confirm their login attempts.

    Unfortunately, many users find this extra login procedure tedious and inconvenient. There have been efforts to simplify the 2FA flow with the goal of increasing adoption.

    A new method that is gaining popularity is Push Authentication, where instead of expecting a numeric code, the application server sends a push notification to the user’s smartphone. The only action for the user is to tap a button in this notification to confirm that the login attempt is legitimate.

    In this article, I will go …

    Read More
  • By Miguel Grinberg
    Using Twilio SendGrid To Send Emails from Python Django Applications Using Twilio SendGrid to Send Emails from Python Django Applications

    Deciding how to add email sending capabilities to a web application is always difficult. Do you go through the trouble of setting up and maintaining your own email server, or do you opt for a third-party email service? While the answer is dependent on a number of variables such as volume of emails, your hosting platform and your budget, the tendency is often to favor the simplicity offered by a dedicated email service.

    In this short tutorial you’ll learn how to configure a Python application based on the Django web framework to send emails using the Twilio SendGrid service.

    Tutorial Requirements

    To follow this tutorial you need the following items:

    • Python 3 — If your operating system does not provide a Python 3 interpreter, you can go to python.org to download an installer.
    • A Twilio SendGrid account — If you are new to Twilio Sendgrid you can create a free …
    Read More
  • By Miguel Grinberg
    Using Twilio SendGrid To Send Emails from Python Flask Applications Using Twilio SendGrid to Send Email from Python Flask Applications

    Deciding how to add email sending capabilities to a web application is always difficult. Do you go through the trouble of setting up and maintaining your own email server, or do you opt for a third-party email service? While the answer is dependent on a number of variables such as volume of emails, your hosting platform and your budget, the tendency is often to favor the simplicity offered by a dedicated email service.

    In this tutorial you’ll learn how to configure an application based on the Flask framework and the Flask-Mail extension to deliver email through the Twilio SendGrid service.

    Tutorial Requirements

    To follow this tutorial you need the following items:

    • Python 3.6 or newer. If your operating system does not provide a Python 3.6+ interpreter, you can go to python.org to download an installer.
    • A free Twilio SendGrid account. If you are new to Twilio Sendgrid you can create …
    Read More
  • Newer
    Older
    Sign up and start building
    Not ready yet? Talk to an expert.