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 Imran Khan
    Build a Soccer Stats WhatsApp Chatbot with Python, Flask and Twilio Build a Soccer Stats WhatsApp Chatbot with Python, Flask and Twilio

    There isn’t much live sport to watch at the moment which gives us the perfect opportunity to analyze historical data about the sport instead!  In this tutorial I’m going to show you how to build a basic chatbot for WhatsApp using the Twilio API for WhatsApp and the Flask framework for Python.

    The chatbot will allow users to get information about soccer teams and match statistics.  Here’s an example showing how it works:

    soccer chatbot demo

    Tutorial requirements

    To follow this tutorial you will need the following:

    • Python 3.6 or newer.  You can download an installer from python.org.
    • Flask.  We will use this web framework to build an application that responds to incoming WhatsApp messages.
    • ngrok. We will use this free utility to connect our Flask application running on our local system to a public URL that Twilio can connect to from the Internet.  Installation instructions for your operating system …
    Read More
  • By Sam Agnew
    COVID-19 tracking via SMS with Twilio and Python Copy of Language template - PYTHON2.png

    Around the world, the Coronavirus Pandemic is affecting people and their communities. It might impact different areas in varying ways, but the virus causing the COVID-19 disease has reached a level of global pervasiveness. The situation is constantly evolving so it can be hard to keep track of.

    If you are in the United States, there is a COVID Tracking Project which provides up-to-date statistics for the nation as a whole and for each individual State on the number of tests administered, positive cases, and the death toll. The project also provides this data in the form of an API.
    You can text the phone number +1 (864) 77-STATS which is +1 (864) 777-8287 with a particular US State abbreviation to get the current statistics for that State, or any other message to get the nation-wide data.

    Let's walk through how to build a text-message-based COVID-19 tracker in Python …

    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 Scott Sturdivant
    Build a VoIP System with Twilio, 3CX and Python Build a VoIP System with Twilio, 3CX and Python

    Spinning up your own VoIP phone line has never been easier with Twilio and 3CX.  In this tutorial, we’ll go over how to integrate the two and get you well on your way to making cheap phone calls.

    Project Dependencies

    To implement this project we will use a number of products described below.

    Twilio Elastic SIP Trunk

    A SIP Trunk is a critical component that connects your VoIP phone system to the Public Switched Telephone Network (PSTN).  Twilio’s SIP Trunking solution provides an affordable, flexible, and robust solution that can power enterprise businesses or a single home phone line.

    sip trunk diagram 

    More information about SIP Trunks can be found here.

    Don’t have a Twilio account yet?  Open your free account now. Use this link to sign up and you’ll receive a $10 credit when you upgrade to a paid account.

    Twilio Phone Number

    To make or receive phone calls, we’ll …

    Read More
  • By David Fundakowski
    Sending MMS with Twilio Programmable SMS, Python and Django Sending MMS with Twilio Programmable SMS, Python and Django

    Modern communication through texting includes so much more than simple text messages. People use images, GIFs, audio files, web links, and any other media in messages in order to communicate with each other effectively. Twilio Programmable SMS makes it extremely simple to send basic SMS, but it’s just as simple to send MMS media like GIFs and images.

    In this tutorial, you will be setting up a Django project using virtual environments, creating a free Twilio account, provisioning a phone number, and finally, creating an app to respond to inbound SMS with either a GIF, an image, or a basic SMS.

    By the end of this tutorial, you will be able to:

    • Set up a free Twilio account
    • Parse inbound SMS content using Twilio Programmable SMS in a Django app
    • Respond to inbound SMS with a GIF, an image, or an SMS depending on the inbound message

    mms example use

    Tutorial requirements

    To …

    Read More
  • By Delores Diei
    Building a Microlearning Application with Python and Twilio SendGrid Build a Microlearning Application with Python and Twilio SendGrid

    The sheer amount of information we have out there is enormous and it can be overwhelming for people trying to learn a new skill to decide what resource to use and actually follow through on learning these skills. For the worker especially, it can be really difficult finding the time to focus on learning these skills. Courses take months to complete and books have hundreds of scary pages. This difficulty calls for a need to modify the way we learn, and Microlearning is one successful attempt at adaptation.

    Microlearning is a learning approach that involves getting your learning material in micro-units over a period of time. What this means is, if you want to read an online book that has 600 pages, you can read a few pages of the book per day. This way, you can estimate how long it will take you to complete the book and you’re …

    Read More
  • By Brian Thompson
    Build a Shipment Notification Service with Python, Flask, Twilio and EasyPost Building a Shipment Notification Service with Python, Twilio and EasyPost

    With eCommerce becoming more mainstream, companies are shipping goods directly to their consumers now more than ever.  Once consumers buy something online, they want to know where their order is in the fulfillment process and when it should arrive, and that’s where Twilio and EasyPost come in handy.

    In this tutorial, you’ll see how easy it is to track the movement of shipments with the EasyPost API for Tracking, and programmatically notify individuals via the Twilio SMS API and the Flask framework for Python.

    Below is an example of the type of notifications that you’ll be sending automatically with this app:

    shipment notification sms

    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 webhooks from …
    Read More
  • By April Speight
    Create a NASA Astronomy Picture of the Day Scheduled SMS with Python, Twilio and Azure Functions Create a NASA Astronomy Picture of the Day Scheduled SMS with Python and Azure Functions

    Recently, my friends and I were invited to NASA to take part in a behind-the-scenes tour and briefing on five new research campaigns that will take to the field in 2020 to explore questions critical to understanding our home planet!

    With so much to look forward to, I decided to create a countdown for the days leading up to our road trip! Rather than execute the group chat countdown manually, I decided to get a little help from my friends at Twilio, Azure Functions and NASA's astronomy picture of the day API. My goal was to accomplish the following:

    • Countdown the number of days remaining until the trip to NASA
    • Include NASA's astronomy picture of the day
    • Schedule a message to be sent every morning at 9AM

    Here's an example of a message:

    scheduled sms demo

    In this tutorial I’m going to show you how to create a countdown SMS that sends a …

    Read More
  • By Gabriela Cavalcante
    Build a Secret Santa Bot for WhatsApp Using Python and Twilio Build a Secret Santa Bot for WhatsApp Using Python, Flask and Twilio

    In this tutorial we’re going to use Twilio Whatsapp, Flask and Python to build a simple Secret Santa bot. Also, I’ll show you how to use Dynaconf to manage configuration in a Python Project. You can find the complete code for this project on my GitHub repository.

    A user just needs to send a message to the bot to create a Secret Santa contest. The bot will respond by sending a unique code that identifies the event. With this code, the participants can send a message to the bot to join. The creator can then send a text message to carry out the selection of partners. Once the pairings are known, the bot sends a message to each participant with the name of their secret friend.

    secret santa bot screenshot

    Tutorial Requirements

    To follow this tutorial you need the following components:

    • Python 3.7 or newer. If your operating system does not provide …
    Read More
  • Newer
    Older
    Sign up and start building
    Not ready yet? Talk to an expert.