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 Robert Alford
    Build a Contact Form for a Python Django Application with Twilio SendGrid Build a Contact Form for a Python Django Application with Twilio SendGrid

    A contact form is a common feature of many websites that provides a way for users to get in touch with the site’s administrators without having to open their email or hop on the phone. In a Python Django application, a contact form can be used to store a user’s contact information in the site’s database. And with Twilio SendGrid, we can also trigger an automated email containing that information as soon as the form is successfully submitted.

    In this tutorial, we will build a simple contact form for a Django web application that does just that.

    Project screenshot

    Tutorial requirements

    • Python version 3.6 or higher. If you do not have Python installed on your computer, you can download a free installer here.
    • A free Twilio SendGrid account. Sign up here to send up to 100 emails per day completely free of charge.
    • The Django web framework. Django is a fully …
    Read More
  • By August Allard
    Introducing Python Developer for Technical Content, August Allard augustallard.png

    Ask just about any programmer why they like to write code, and I’ll bet you a giant slice of chocolate cake that every single person will give at least one of these answers:

    • “I love making things!”
    • “I love learning how things work!”
    • “I love solving problems!”

    Of course, this isn’t an exhaustive list of the reasons why people like to write code, but the exclamations in this list have reliably and recurrently come up when I get into conversations with fellow developers. Often, these developers will tell me that not only do they love making things, love learning how things work, or love solving problems, they have actually always enjoyed these things, even in their childhood.

    This unique collection of interests — building, learning, solving — is the longstanding core of my identity.

    How it started

    In elementary school, Mrs. Elliott was my daycare provider and watched over me …

    Read More
  • By Diane Phan
    How to Send a Picture on WhatsApp Using Twilio and Python header - How to Send a Picture on WhatsApp Using Twilio and Python

    The WhatsApp Business API from Twilio is a powerful, yet easy to use service that allows you to communicate with your users on the popular messaging app.

    In this article, we’ll walk you through how you can develop a functional Python program to send an image to a user through WhatsApp.

    Twilio WhatsApp console with an image and message "check out this owl!"

    Prerequisites

    To follow this tutorial you need the following items:

    The Twilio WhatsApp sandbox

    Twilio provides a WhatsApp sandbox, where you can easily …

    Read More
  • By Miguel Grinberg
    How to Send an SMS in FastAPI with Twilio How to Send an SMS in FastAPI with Twilio

    Twilio is all about powering communication and doing it conveniently and fast in any language. But if you have a Python application written with the asyncio package, it may not be completely clear how to translate the examples from the documentation into non-blocking code that works well with an asynchronous loop.

    In this tutorial you’ll learn how to properly deliver SMS notifications from a FastAPI application. The techniques shown here are also applicable to other asyncio frameworks.

    Project demo

    Tutorial requirements

    Read More
  • By Miguel Grinberg
    How to Receive WhatsApp Messages in Python using Django and Twilio How to Receive WhatsApp Messages in Python using Django and Twilio

    The WhatsApp Business API from Twilio is a powerful, yet easy to use service that allows you to communicate with your users on the popular messaging app. In this tutorial you are going to learn how to create a Python application based on the Django web framework that can receive and handle WhatsApp messages.

    Project demo

    Prerequisites

    To follow this tutorial you need the following items:

    The Twilio WhatsApp sandbox

    Twilio provides a WhatsApp sandbox, where …

    Read More
  • By Diane Phan
    How to Store Multimedia Files in a SQLite3 Database with Python header - How to Store Multimedia Files in a SQLite3 Database with Python

    If you're a developer who is building out a website that allows users to upload image files for reasons such as updating a profile picture, sharing images with other users, or utilizing other multimedia files, you will find yourself wondering, "what's the safest way to save their data?".

    You could store the files directly in the server’s file system, integrate with APIs from cloud storage platforms, or you can learn how to store the information in your database!

    In this tutorial, you will learn about blob (binary large object) data and why you need to convert your multimedia files to binary objects in order to store them properly in a database. Then you will learn how to retrieve the blobs and convert them back into regular files for use by your application.

    Let's get started!

    Tutorial requirements

    • Python 3.6 or newer. If your operating system does not provide a Python …
    Read More
  • By Adeyemi Atoyegbe
    Building GraphQL APIs in Django with Graphene Building GraphQL APIs in Django with Graphene

    GraphQL is an open-source data query and manipulation language for APIs, and a runtime for fulfilling queries with existing data. It was developed internally by Facebook in 2012 before being publicly released in 2015. It allows clients to define the structure of the data required, and the same structure of the data is returned from the server, therefore preventing unnecessary data from being returned.

    GraphQL has three primary operations: Queries for reading data, Mutations for writing data, and Subscriptions for automatically receiving real-time data updates. A GraphQL server provides clients with a predefined schema – a model of the data that can be requested. The schema serves as common ground between the client and the server.

    In this tutorial we will use Graphene, a GraphQL framework for Python, to build a Django API that uses queries and mutations.

    Tutorial Requirements

    To follow along with this tutorial you should have …

    Read More
  • By Sam Agnew
    Using Python and Twilio Messaging to find out if the Suez Canal is still blocked Copy of Generic Blog Header 1(4).png

    Recently a 200,000 ton container ship named the Ever Given has become stuck in the Suez Canal, halting one of the world's busiest waterways and disrupting global supply chains. And it looks like it might take weeks to move it. Luckily for those on the edge of their seats, with the Marine Traffic API we can access the location of marine vessels programmatically.

    My coworker Kelley Robinson used this to create a Twilio phone number that you can text to see if the Ever Given is still stuck. Try it out by texting +1 (586) 800-BOAT, which is +1 (586) 800-2628, to get the status of the situation.

    Boat still stuck? Text message

    Let's walk through how you could build your own version of this, using Twilio Programmable Messaging, Flask, and the Marine Traffic API.

    Setting up your environment

    Make sure to have your Python environment set up before we get started. …

    Read More
  • By Mwangi Kabiru
    Building a Serverless WhatsApp Chatbot using Python, Google Cloud Functions and Twilio Building a Serverless WhatsApp Chatbot using Python, Google Cloud Functions and Twilio

    A chatbot is a software application used to automate interactions and conversations with people via messaging platforms. Common uses of chatbots include request routing, customer service, and information gathering.

    Serverless architecture is a design pattern where applications are broken up into individual functions that can be invoked and scaled separately. The goal is to abstract the process of building and running applications from the complexities of developing and deploying infrastructure required to run them.

    In this tutorial, I am going to show how you can build a serverless WhatsApp chatbot using Twilio’s WhatsApp API and Python functions in Google Cloud. The chatbot will accept a country name and return information about it. The country data will be retrieved from the REST Countries public API.

    Project demo

    Tutorial requirements

    To follow this tutorial you need to have:

    • Python 3.7 or newer. If your operating system does not have a pre-installed Python interpreter, you …
    Read More
  • By Sam Agnew
    Asynchronous HTTP Requests in Python with aiohttp and asyncio Copy of Generic Blog Header 3(4).png

    Asynchronous code has increasingly become a mainstay of Python development. With asyncio becoming part of the standard library and many third party packages providing features compatible with it, this paradigm is not going away anytime soon.

    Let's walk through how to use the aiohttp library to take advantage of this for making asynchronous HTTP requests, which is one of the most common use cases for non-blocking code.

    What is non-blocking code?

    You may hear terms like "asynchronous", "non-blocking" or "concurrent" and be a little confused as to what they all mean. According to this much more detailed tutorial, two of the primary properties are:

    • Asynchronous routines are able to “pause” while waiting on their ultimate result to let other routines run in the meantime.
    • Asynchronous code, through the mechanism above, facilitates concurrent execution. To put it differently, asynchronous code gives the look and feel of concurrency.

    So asynchronous …

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