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

"python" posts

  • By Philip Kiely
    Build an Email Newsletter with Django and Twilio SendGrid Build an Email Newsletter with Django and Twilio SendGrid

    In recent years, email newsletters have become an increasingly popular way for content creators to reach their audiences. In software development, newsletters from Sacha Greif’s Sidebar to the now multi-line Cooper Press have found success distributing curated links and original articles. A number of services exist to solve the myriad of technical and non-technical barriers to reliably distributing to a large mailing list, including Twilio SendGrid’s own official solution and resources on starting a newsletter. While what we develop in this tutorial may not be as fully-featured as the off-the-shelf product, today we’ll take a dive into creating our own minimal email newsletter backend using Python’s Django Web Framework and Twilio SendGrid’s core email-sending API.

    Tutorial Requirements

    To complete this tutorial, you’ll need the following:

    • Python 3.6 or newer. If you don’t have a previously installed Python interpreter, you can go to python.org to download an installer. …
    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 Parry Cadwallader
    Build a WhatsApp Flashcard Bot With Python, Flask and Twilio Build a WhatsApp Flashcard Bot with Python, Flask and Twilio

    A flashcard is one of the most tried and true study tools, helping anyone from medical students to language learners all approach their goal of memorizing facts and figures. Software like Anki or Memrise have provided countless features and robust settings that make digital flashcards increasingly useful. However, there are plenty of times where you might not be able to pull up one of the more robust applications and need something more lightweight to study with.

    For example, when your cell signal is good enough for texting, but cannot load a full-featured web application. Or perhaps you’re in an airplane that doesn’t allow various websites, but does allow you to text phone numbers down on the ground.

    This tutorial will show you how to make a basic flashcard bot for WhatsApp or SMS to get you started on your way to reviewing flashcards wherever you are. You can see an …

    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 Tilde Thurium
    Queueing Emails With Python, Redis Queue And Twilio SendGrid Queueing emails with Python, Redis Queue and Twilio SendGrid

    If you’re sending email from within a web application, you’ll want to do so asynchronously so you don’t block requests from completing. Especially if it takes additional (potentially slow) requests to construct the email content. There are several Python libraries available to help with asynchronous tasks, such as celery. Alternately, you can use asyncio if you’re on Python 3.4 or above.

    Redis Queue is the friendliest to get started with. Today I’ll show you how to queue emails to be sent asynchronously with Redis Queue and Twilio SendGrid.

    To keep things spicy, let’s use the Taco Fancy API to email a randomly generated taco recipe.

    Getting Started

    To follow along, you’ll need:

    • Python 3.5 or above installed
    • A free SendGrid account - sign up here
    • An email address, to test things out and make sure they’re working

    First, create a new Python project. In case you need it, …

    Read More
  • By Scott Sturdivant
    Receive Faxes with Twilio, Python, and Flask Receive Faxes with Twilio, Python and Flask

    Wouldn’t you know it.  As soon as we have sent our first fax, someone now wants to respond! Follow along as we quickly setup the means to receive faxes delivered as a PDF attachment via email.

    Project Dependencies

    We'll be using a Twilio Programmable Fax number, Python 3, Flask, and the Twilio Python Helper library as our core requirements.

    Twilio

    It’ll be difficult to receive faxes if we don't have a Twilio Fax-Enabled number, so if you do not already have one, head on over and sign up for a free account.

    Once you have registered, buy a phone number in the console. Be sure to select the Fax capability!

    Phone number capabilities screenshot

    Search for a number that meets your region criteria then press buy.

    Python

    To keep our libraries separate from the system libraries, we follow Python best practices and create a virtualenv and activate it:

    $ python3 …
    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 Sam Agnew
    Identifying Phone Number Carriers in Python with Twilio Lookup Copy of Generic Blog Header 2 (1).png

    Trolls and bad actors sometimes use phone numbers from free online providers to create fake profiles for making spam calls. Twilio's Lookup API helps you identify the carrier behind the phone number to learn which users have real mobile numbers.

    Setting up

    To lookup a phone number you will need:

    To install the Twilio Python module, navigate to the directory where you want this code to live and make sure you create a virtual environment. Once you have a virtual environment activated, run the following command to install the dependencies:

    pip install twilio==6.31.1
    

    After this you should be good to write some code!

    Looking up a carrier with Twilio

    You can query the Twilio Lookup API for information about a phone number. There are two Type …

    Read More
  • Newer
    Older
    Sign up and start building
    Not ready yet? Talk to an expert.