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 Ángel Ramírez
    Create an Appointment Booking Bot for WhatsApp using Python, Google Calendar and Twilio Autopilot Create an Appointment Booking Bot for WhatsApp using Python, Google Calendar and Twilio Autopilot

    I always struggle to take my dogs to the groomer because scheduling an appointment is a bit tedious and complicated. I always have to call directly to the store, hoping someone is available to pick up the phone, then wait for them to check on their calendars to see if there is a spot available for them and confirm it.

    Technology is all about automation and making people’s lives easier so I thought it would be a good idea to come up with a scheduler bot that would do all that work for us, taking advantage of a great AI platform from Twilio called Autopilot and a bit of logic with Python on the backend to connect to a Google Calendar.

    bot demonstration

    The interaction flow would be something like this:

    bot diagram

    1. The user starts the conversation by sending a message to the bot on WhatsApp
    2. WhatsApp redirects the request to Autopilot for …
    Read More
  • By Sam Agnew
    Generating Lyrics in the Style of your Favorite Artist with Python, OpenAI's GPT-3 and Twilio SMS Copy of Generic Blog Header 4(3).png

    With concerts canceled and many artists being unable to release new music, people around the world are missing their favorite bands. What if you could fill that void by bringing any band or artist's lyrical style home with Python code to generate new songs?

    Try texting the name of your favorite artist to +1 (315) 65-LYRICS (+1 315 659-7427) or +44 7401 193427 if you're in the UK to get lyrics in their style, and continue reading to find out how to program this yourself!

    Computer-generated Black Sabbath lyrics

    OpenAI's new GPT-3 (Generative Pre-trained Transformer 3) model was trained on a massive corpus of text making it incredibly powerful. This can be used to generate song lyrics in the style of any artist with surprisingly little input text given to it as a prompt.

    Let's walk through how to create a text-message powered bot to generate song lyrics in Python using Twilio Programmable …

    Read More
  • By Sam Agnew
    Building a Punk Lyrics Bot in Python with OpenAI's GPT-3 and Twilio SMS Copy of Generic Blog Header 1(2).png

    In the midst of pandemic-related lockdowns, many people around the world miss seeing their favorite bands. What if you could bring the anti-authoritarian, do-it-yourself ethos of punk rock home in the form of new song lyrics created by your Python code?

    OpenAI's new GPT-3 (Generative Pre-trained Transformer 3) model was trained on a massive corpus of text making it incredibly powerful. This can be used to generate song lyrics with surprisingly little input text given to it as a prompt.

    Let's walk through how to create a text-message powered bot to write Punk songs in Python using Twilio Programmable Messaging and OpenAI's API for GPT-3.

    STAGE DIVE

    Before moving on, you'll need the following:

    • 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.
    • A virtual environment enabled before installing any Python libraries.
    • A Twilio account and a …
    Read More
  • By Diane Phan
    Control a Spooky Ghost Writer for Halloween with OpenAI's GPT-3 Engine, Python, and Twilio WhatsApp API header - Control a Spooky Ghost Writer for Halloween with OpenAI's GPT-3 Engine, Python, and Twilio WhatsApp API

    October is a pretty cool month because not only do the days get dark faster, but Halloween is just around the corner. If you enjoy finding new ways to trick your friends or spook someone out, this article has a fun and unique idea for you! Whether you're already tech savvy or a beginner at coding, you might find it enjoyable to build an app to spook someone out this year!

    Using Python, GPT-3, and Twilio WhatsApp API, you have the chance to control a ghost writer and have them write a story directly onto your computer screen. No witch magic involved, just Twilio magic!

    Tutorial Requirements

    • 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.
    • An OpenAI API key. Request beta access here.
    • A free or paid Twilio account. If you are new …
    Read More
  • By Leonard Volarić Horvat
    Orchestrate a Twilio Webhook Deployment to AWS EC2 Using Ansible Orchestrate a Twilio Webhook Deployment to AWS EC2 Using Ansible

    Suppose you have a Flask application handling a Twilio webhook of yours. For instance, one which saves an SMS or a recording of a Twilio phone call to some cloud storage or a database.  For a production deployment of your webhook you would likely want to spin up a virtual machine instance in a cloud server provider, such as EC2 on AWS. But that can quickly become too cumbersome and error-prone to handle manually, especially when upgrading the application, or if you want to do some complex cloud storage schema.

    In this tutorial, we will demonstrate how to use Ansible, an open-source orchestration tool, to deploy a Twilio webhook on EC2 in a maintainable and extendable manner. First we will go through core Ansible concepts, then we will write a simple Flask application (our webhook) and explain how to serve it, then we will cover provisioning an EC2 instance …

    Read More
  • By Dotun Jolaoso
    Build a Serverless User Verification Service with Python, Twilio Verify and the Chalice Framework Build a Serverless User Verification Service with Python, Twilio Verify and the Chalice Framework

    Chalice is a Python Framework for writing, building and deploying serverless applications. It was built and is currently maintained by the team at AWS. Using familiar decorator-based syntax that is common within popular Python frameworks such as Flask, FastAPI, etc, Chalice is easy to get started with. In this tutorial, we’ll see how to deploy a Chalice application that integrates with the Twilio Verify Service to AWS Lambda.

    The application that we’ll build exposes a set of API endpoints to send verification codes to phone numbers via SMS, and then verifying them once the user receives them and sends them back. This is useful in scenarios where you would like to add phone number verification or two-factor authentication to your application.

    Technical requirements

    To follow along, you’ll need the following:

    • An AWS account. If you don’t have one, you can sign up here to enjoy a generous allowance during …
    Read More
  • By Joyce Lin
    Visualize Twilio Usage Data with Python, Pandas and Jupyter Notebooks Visualize Twilio Usage Data with Python, Pandas and Jupyter Notebooks

    Some mysteries in life can only be answered by data. For example, if you have questions about your Twilio usage, there’s a few ways to dig into the data. There’s prebuilt summaries and graphs of your activity in the Twilio console, and if you’re handy with a spreadsheet, you can export the data. There’s also third-party providers with out-of-the-box analytics and visualizations.

    If nothing answers your particular question, this tutorial shows you how to make custom reports using the Twilio REST API to access your data and drive your own insights.

    Tutorial requirements

    • Python version 3
    • A free or paid Twilio account with a history of activity

    Set up the Python virtual environment

    Make a new project directory, and change into the directory from the command line.

    $ mkdir twilio-jupyter
    $ cd twilio-jupyter
    

    Create a virtual environment called venv. If you’re on Unix or Mac operating systems, …

    Read More
  • By Alex Kiura
    Build a WhatsApp Weather Bot with Python, OpenWeather and Twilio Build a WhatsApp Weather Bot with Python, OpenWeather and Twilio

    WhatsApp has become the defacto messaging application that most people use to keep in touch. Wouldn’t it be convenient to build a WhatsApp bot that receives your location and responds with an instant weather update?

    Using the Twilio WhatsApp API, OpenWeather One Call API and Django, we will build our very own weather bot, which will provide current weather information and the forecast for the next week.

    See a sample interaction below:

    Weather Bot Demo

    Prerequisites

    • Python 3.6 or higher. If you don’t have it installed, get it here
    • Twilio account: If you are new to Twilio, sign up for an account here.
    • OpenWeather account: If you are new to OpenWeather, sign up for an account here.
    • ngrok: a tool that allows us to expose local servers to the public internet. We will use it to create a public URL that Twilio can use to securely communicate with our …
    Read More
  • By Rising Odegua
    Build a Deep Learning Spam Detection System for SMS using Keras, Python and Twilio Build a Spam Detection System for SMS using Keras, Python and Twilio

    In this tutorial, you’re going to build an SMS spam detection web application. This application will be built in Python using the Flask framework, and will include a deep learning model that you will train to detect SMS spam. We will work with the Twilio SMS API, so that you’ll be able to classify SMS messages sent to the phone number you have registered in your Twilio account.

    One practical use of this application is to monitor and effectively classify SMS messages from your customers into spam or not-spam folders.

    Below is the result of the final application you’ll build:

    Application demo

    As you notice from the picture above, you have two sections, one representing non-spam messages and the other representing spam messages. These messages are all retrieved from your SMS inbox and classified by the trained model before they are displayed in the dashboard.

    Prerequisites

    In order to follow and fully …

    Read More
  • By Sam Agnew
    Automated Yugioh Deckbuilding in Python with OpenAI's GPT-3 and Twilio SMS Copy of Generic Blog Header 1(1).png

    Coming up with a deck in any trading card game is often very difficult, and takes a lot of thought and experimentation. What if we could just have a computer do it for us?

    OpenAI's new GPT-3 (Generative Pre-trained Transformer 3) model was trained on a massive corpus of text making it incredibly powerful. This can be used to generate something similar to pretty much any text found on the internet, including in our case Yugioh deck lists.

    Let's walk through how to create a text-message powered bot to generate Yugioh deck lists in Python using Twilio Programmable Messaging and OpenAI's API for GPT-3.

    EXODIA THE FORBIDDEN ONE

     

    Before moving on, you'll need the following:

    • 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.
    • A virtual environment enabled before installing any Python libraries.
    • A Twilio account and a Twilio …
    Read More
  • Newer
    Older
    Sign up and start building
    Not ready yet? Talk to an expert.