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
    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
  • By Miguel Grinberg
    Phone Verification with Twilio For Python Developers Phone Verification with Twilio for Python Developers

    Twilio Verify is a service that allows you to add phone verification to your applications. If you’re curious about the benefits of verifying your users, consider the following two use cases:

    • Reduce fake accounts - If you ask users to provide a valid phone number while they create an account, they will be less likely to create phony or duplicate accounts.
    • Two-factor authentication - Sending a verification code to your users when they sign-in can help protect their accounts if their credentials are compromised.

    In this tutorial, we’ll learn how to work with the Twilio Verify API in Python. Since this is such a simple API, we will be doing all the work from a Python shell!

    Tutorial Requirements

    To follow this tutorial you need the following items:

    • Python 3.5 or newer. If your operating system does not provide a Python 3.5+ interpreter, you can go to python.org to download …
    Read More
  • By Miguel Grinberg
    A Phone Number Input Field for Flask Forms A Phone Number Input Field for Flask Forms

    The Flask-WTF package makes working with forms in Flask straightforward and even fun – unless you need to include a field that falls outside of the standard primitive field types.

    Consider an application that needs to ask users for their phone number in a friendly way, regardless of the country or region the user is in. You could use a standard text input and hope your users know how to enter their phone number, but based on my experience, you are going to find that many users do not know the rules to enter a full phone number that includes the country code and can be used internationally.

    In this post, we’ll build an example Flask application that includes a phone number field that makes it virtually impossible to enter an invalid number.

    Phone number input field demo

    As you can see, this field includes a dropdown that lists all the countries, with cute little …

    Read More
  • By Miguel Grinberg
    Add Two-Factor Authentication to a Python Flask Application with Twilio Verify Add Two-Factor Authentication to a Python Flask application with Twilio Verify

    Twilio Verify is an easy-to-use service that allows your application to send verification codes to your users via SMS or phone call. While the main purpose of this API is to verify users when they sign up for a new account, I want to show you how the same functionality can be used to quickly implement two-factor authentication support.

    In this article I’m going to take a complete, non-trivial Python application that uses the Flask framework and modify it to allow users to optionally enable two-factor authentication on their accounts. The application that I’m going to use for this exercise is the one featured in my Flask Mega-Tutorial, a microblogging web application very appropriately, though unoriginally called Microblog.

    To give you a taste of what this looks like once implemented, below you can see how a user enables two-factor authentication on this application:

    Two-factor authentication demo

    Once two-factor is enabled, the …

    Read More
  • By Miguel Grinberg
    Build a SMS Chatbot With Python, Flask and Twilio Build an SMS Chatbot with Python, Flask and Twilio

    In a previous article I showed you how to build a WhatsApp chatbot with Python, Flask and Twilio. Today I’m going to use similar techniques to build a chatbot that communicates with users through text messages using Twilio’s Programmable SMS.

    The chatbot that I’m going to build performs a simple analysis of what the user writes to find keywords of interest, which trigger the response of the chatbot. The two keywords in my implementation are “quote” and “cat”, which trigger responses of famous quotes and cat pictures respectively.

    Below you can see the chatbot in action:

    Chatbot demonstration

    Tutorial Requirements

    To follow this tutorial you need the following components:

    • Python 3.6 or newer. If your operating system does not provide a Python interpreter, you can go to python.org to download an installer.
    • Flask. We will create a web application that responds to incoming SMS messages with it.
    • ngrok. We …
    Read More
  • By Miguel Grinberg
    Securing Your Twilio Webhooks in Python Securing your Twilio Webhooks in Python

    Last month a Twitter user described in detail how he almost fell victim to a very credible phishing attempt against his bank account. One of the key aspects of this attempted scam was that the attacker, posing as a bank representative, was able to make the bank send a legitimate verification code to the user’s phone.

    While this was just a very clever abuse of the bank’s lax user verification protocols and not a result of a hack, it helps reinforce the idea that you cannot stop thinking about security, and this obviously also applies to the webhooks that support applications that are based on Twilio APIs.

    In this article I’m going to discuss the risks that are specific to webhooks and the techniques that you have at your disposal to make them secure.

    Understanding the Risks

    Before I go into the available solutions, I want to help you understand …

    Read More
  • By Miguel Grinberg
    Build a WhatsApp Chatbot With Python, Flask and Twilio Build a WhatsApp Chatbot with Python, Flask and Twilio

    A chatbot is a software application that is able to conduct a conversation with a human user through written or spoken language. The level of “intelligence” among chatbots varies greatly. While some chatbots have a fairly basic understanding of language, others employ sophisticated artificial intelligence (AI) and machine learning (ML) algorithms to achieve an almost human conversational level.

    In this tutorial I’m going to show you how easy it is to build a chatbot for WhatsApp using the Twilio API for WhatsApp and the Flask framework for Python. Below you can see an example interaction I had with this chatbot:

    WhatsApp chatbot demo session

    Tutorial Requirements

    To follow this tutorial you need the following components:

    • Python 3.6 or newer. If your operating system does not provide a Python interpreter, you can go to python.org to download an installer.
    • Flask. We will create a web application that responds to incoming WhatsApp messages with it. …
    Read More
  • Newer
    Older
    Sign up and start building
    Not ready yet? Talk to an expert.