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 Miguel Grinberg
    Building a Chatbot with OpenAI's GPT-3 engine, Twilio SMS and Python Building an SMS Chatbot with OpenAI's GPT-3 engine, Twilio and Python

    A GPT-3 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 Twilio SMS using the OpenAI platform and the Flask framework for Python.

    Want to have an idea of what the capabilities of GPT-3 are? Take a look at the following interaction I had with this bot using the project we are going to build in this tutorial:

    conversion with the openai chatbot

    Introduction to GPT-3

    GPT-3 (Generative Pre-trained Transformer 3) is a highly advanced language model trained on a very large corpus of text. In spite of its internal …

    Read More
  • By Ayoyinka Obisesan
    Design a Phone Survey System with Python, Google Sheets and Twilio Design a Phone Survey System with Python, Google Sheets and Twilio

    Surveys serve as a great tool for gathering information from a sample of people and can take multiple forms but are most common in the form of a questionnaire, either written, online or over the phone.

    In this tutorial, I’m going to walk us through how to build an automated Phone Survey System which is a form of an Interactive voice response (IVR) system. An IVR system is a technology that allows a computer to interact with humans through the use of voice and DTMF tone input via the phone’s keypad. To build this application, I will be working with the Twilio Python Helper Library, the Flask framework for Python and Google Sheets. Below is a high-level overview of how the application works:

    project diagram

    For the purpose of building this application, I have selected the following three questions to include in the survey:

    1. Do you own or rent a house? …
    Read More
  • By Miguel Grinberg
    Sending SVG Images by SMS and WhatsApp with Python and CairoSVG Sending SVG Images by SMS and WhatsApp with Python and CairoSVG

    Twilio Programmable Messaging makes it easy to embed images in text messages, but a notable omission in the list of supported formats is Scalable Vector Graphics (SVG). While SVG is not one of the most popular image formats, it is the preferred choice for generating diagrams and charts, because this format renders without quality degradation at any resolution.

    So what do you do if you have an SVG image and need to send it via SMS or WhatsApp? In this article I will show you how I use the CairoSVG package for Python to convert SVG images to the PNG format, which the messaging APIs support.

    Tutorial requirements

    The only requirement that you need for this tutorial is 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.

    Installing CairoSVG

    Let’s begin by creating a directory …

    Read More
  • By Mwangi Kabiru
    Monitor your Apache Airflow Workflows with Twilio Monitor Your Apache Airflow Workflows with Twilio

    Airflow is an open source platform used to orchestrate workflows. It is perfect for Extract, Transform, Load tasks, data migration and data integration, among other jobs.

    In this tutorial we will see how we can leverage Twilio’s Programmable Messaging to set up an alerting system for Airflow jobs.

    Dag - Graph view

    Airflow DAG (source: Apache Airflow)

    Tutorial requirements

    To follow this tutorial you need to have:

    Set up Airflow to run locally

    We are going to start off by cloning a repository that contains the docker image we shall use for this tutorial. The image is based on Python 3.7-slim-buster and will create Postgres and Redis containers. Postgres is …

    Read More
  • By Sam Agnew
    Retrieving Twilio MMS Image URLs in Python Copy of Generic Blog Header 4.png

    When working with Twilio MMS, you often need to access a URL to the pictures contained in a message. Typically when the message is initially received, the webhook request that Twilio sends to your application will contain MediaUrl properties that you can use directly in your application. But if you want to use the REST API to access a URL to an image contained in a Message Resource, you need to do a little more work, as the only option available to you is the uri of the Media resource:

    if int(message.num_media) > 0:
        for media in message.media.list():
            media_url = 'https://api.twilio.com' + media.uri[:-5] # Strip off the '.json'
            print(media_url)
    

    Let's wa …

    Read More
  • By Diane Phan
    Look at the Sky! Learn Data Visualization with WhatsApp, Google Maps, Python, Twilio, and Clarifai header - Look at the Sky! Learn Data Visualization with WhatsApp, Google Maps, Python, Twilio, and Clarifai

    Do you remember Second Sky in 2019 when Porter Robinson and his team put up a huge board for attendees to draw and sign on? Due to COVID-19, his music festival transitioned to the virtual world. Inspired by his new song, “Look at the Sky” which debuted at the end of his Secret Sky set, I built this fun digital board to visualize where fans are in the world and how we’re all still connected under the same sky.

    In completing this tutorial you will build a data visualization webpage after applying image recognition on WhatsApp photos.

     

    gif of "Look at the Sky!" project of sending in a WhatsApp message gif of "Look at the Sky!" project viewing data on map

    In this article, we’ll walk through how you can view data visualizations from your Python app that easily share and identify media content in a private WhatsApp sandbox using Twilio API for WhatsApp, Clarifai API, and Flask.

    Tutorial Requirements

    In order to build this project, you will …

    Read More
  • By Diane Phan
    What's Cookin’? Build an Image Recognition App on WhatsApp using Twilio MMS, Clarifai API, Python, and Flask Header image for with title "What's Cookin’? Build an Image Recognition App on WhatsApp using Twilio MMS, Clarifai API, Python, and Flask"

    Food and photos go hand in hand - if there’s food, then you know there’s going to be an impromptu photoshoot to show it off. There are plenty of apps online that promote the lifestyle of making sure “the camera eats first” on any occasion, no matter where you are.

    Completing this tutorial will allow you to apply image recognition on pictures that your friends and family share in WhatsApp.

    gif demonstrating the play through of sending and receiving messages in  the WhatsApp picture sharing and image recognition app

    In this article, we’ll walk you through how you can develop a functional Python program to easily share and identify media content in a private sandbox through WhatsApp using Twilio Programmable MMS, Clarifai API, and Flask.

    Tutorial Requirements

    In order to build this project, you will need to have the following items ready:

    • 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. …
    Read More
  • By Kyle Lawlor-Bagcal
    Build an SMS Dashboard with Python, Flask and Twilio Build an SMS Dashboard with Python, Flask and Twilio

    In this tutorial we will build a dashboard for receiving Twilio SMS messages on your computer. What we will build here can be a foundation for a custom dashboard project. By the end of the tutorial you will have a web application running on your computer which you can use to check SMS messages on your Twilio phone number.

    The dashboard we build will allow us to view all incoming and outgoing messages. Here is how it looks:

    SMS Dashboard Screenshot

    Getting set up for this tutorial

    There are a few prerequisite steps we need to follow before we begin working through the code.

    1. Install Python version >= 3.6 on your computer
    2. Set up your Twilio Account
    3. Set up your Python virtual environment

    We assume that you already have Python installed. We will now walk through setting up your Twilio account and preparing the virtual environment.

    Setting up your Twilio Account

    If you …

    Read More
  • By Mridu Bhatnagar
    Build a Vocabulary Bot for WhatsApp with Python and Twilio Build a Vocabulary Bot for WhatsApp with Python and Twilio

    My mother teaches English to visually impaired students. Due to the current situation with the Coronavirus, in-person classes had to be suspended, and now she is teaching through phone conference calls, with all learning material being exchanged on WhatsApp. I saw an opportunity to solve a problem here, so I decided to build a Vocabulary chatbot to assist her in her teaching.

    This tutorial will show you how to create a WhatsApp chatbot that can help you in improving your vocabulary using the Twilio API for WhatsApp, Python and Flask. Below, you can see the conversation I had with the bot.

    VocabBot demo

    Tutorial Requirements

    To follow this 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 …
    Read More
  • By Chris Hranj
    How to Send a vCard with Twilio Programmable SMS header - How to Send a vCard with Twilio Programmable SMS

    If you've ever sent or received contact information from one phone to another (especially in a time before smartphones), then you may have unknowingly encountered a vCard before. vCards, also known as Virtual Contact Files, are a standardized (RFC 6350) file format for sending business/contact information which can be easily imported into address/contact books.

    example text of vcard information listing name, phone number, address, and body message

    This post will quickly walk you through creating a vCard using Python and sending it as an MMS using Twilio Programmable SMS.

    The sample code used later in this post can be found here.

    NOTE: Depending on your location and Twilio number, you may not be able to receive MMS outside the US/Canada and thus won't be able to receive vCards.

    Getting Started

    It's important to understand that vCards are essentially just text in a specific format.

    If you've used Twilio MMS before, vCards can be thought of the same way as …

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