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
  • 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 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 Miguel Grinberg
    Screen Sharing with JavaScript and Twilio Programmable Video Screen Sharing with JavaScript and Twilio Programmable Video

    The Twilio Programmable Video API allows you to build customized video chat applications on top of the WebRTC standard. In this article, I’m going to show you how to add a screen sharing option to a browser-based Programmable Video application built in JavaScript.

    Screen sharing demo

    Tutorial requirements

    In this tutorial we are going to add a screen sharing feature to the video chat application built with JavaScript and Python on a previous introductory tutorial. To run this application on your computer you need the following 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.
    • A free or paid Twilio account. If you are new to Twilio get your free account now! This link will give you $10 when you upgrade.
    • A web browser that is compatible with the Twilio Programmable Video JavaScript library (see below …
    Read More
  • By Miguel Grinberg
    Automating Ngrok in Python and Twilio Applications With Pyngrok Automating Ngrok in Python and Twilio Applications with Pyngrok

    When you are developing an application that uses Twilio services you need to expose your webhooks on public URLs that can be reached by Twilio. If you have followed some of the tutorials that we published on this blog you know that we recommend using the excellent ngrok tool to generate temporary public URLs for your development web server. Ngrok is an incredibly useful tool that creates a tunnel from a URL on the ngrok.io domain to your application running on your computer. You can then configure your webhook using the ngrok URL and when Twilio sends a request to it, ngrok redirects it to your application.

    If you use ngrok frequently enough, it pays off to become a paid customer, which allows you to secure a permanent URL. But if you only use this service occasionally, it is tedious to have to log into the Twilio Console to …

    Read More
  • By Miguel Grinberg
    Using Test Credentials and Magic Phone Numbers to Test Twilio Applications Using Test Credentials and Magic Phone Numbers to Test Twilio Applications

    A common problem when developing an application that uses Twilio services is how to effectively test it. Making real requests to Twilio for testing purposes is something that can be useful when done sparsely, but it is not ideal as a general approach to testing because it can end up being expensive. Also, when testing how your application responds to errors you are going to find that it is very hard to replicate all the possible error conditions that can occur in SMS or Voice communication.

    In this article you are going to learn how to work with your Twilio Test Credentials to be able to send fake, yet realistic requests to Twilio that have a predictable result, and more importantly, are 100% free.

    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 …
    Read More
  • By Miguel Grinberg
    Send WhatsApp Notifications with Python and Twilio Send WhatsApp Notifications with Python and Twilio

    Twilio makes it easy to send WhatsApp notifications to users directly from your Python application. In this tutorial we are going to build a simple product delivery form that sends WhatsApp notifications to customers regarding the delivery of their orders.

    whatsapp notification demo

    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.
    • ngrok. We will use this handy utility to connect the Flask application running on your system to a public URL that is accessible on the Internet. This is necessary for the development version of the application because your computer is likely behind a router or firewall. If you don’t have ngrok installed, you can download a copy for Windows, MacOS or Linux.
    • A smartphone with an active phone number and WhatsApp installed.
    • A Twilio …
    Read More
  • By Miguel Grinberg
    Play Chess with a Friend on WhatsApp using Python and Twilio Play Chess with a Friend on WhatsApp using Python and Twilio

    While most of the world is under some form of stay-at-home orders to prevent the spread of COVID-19, we are constantly looking for new ways to entertain ourselves and remain connected with family and friends.

    When I was little I used to play chess a lot, so now that I have additional time on my hands I decided to start playing again. The thing is, nobody in my immediate family plays chess, so I had this idea of using WhatsApp to play a game of chess against a remote friend.

    Chess game demo

    By the end of this tutorial you will know how to use the Twilio API for WhatsApp to implement a turn-based game that requires sending messages and images between multiple participants. You will also learn about how to manage a game of chess in Python, but even if chess isn’t your thing, you will be able to replace the chess …

    Read More
  • By Miguel Grinberg
    Build a COVID-19 Bot with Python and Twilio Autopilot Build a COVID-19 Bot with Python and Twilio Autopilot.png

    Twilio Autopilot makes it easy to build conversational bots that provide information to users in a highly engaging and intuitive format. A single Autopilot bot can be deployed on several channels including SMS, Voice, WhatsApp, Slack, Alexa and more.

    In this tutorial we are going to build a bot that provides COVID-19 stats for all countries using a purely conversational style. We will train the bot with example sentences to help it extract meaning from the freeform text entered by the user. Once you learn how this specific bot works, you will be able to adapt it to other data sources.

    Autobot conversation

    The aspects that make this bot interesting that I’d like you to notice are:

    • The user makes requests in an informal and conversational tone. Autopilot makes it very easy to “teach” the bot how people ask questions using freeform language, and how to extract the actual information embedded in …
    Read More
  • By Miguel Grinberg
    Build a Video Chat Application with Python, JavaScript and Twilio Programmable Video Build a Video Chat Application with Python, JavaScript and Twilio Programmable Video

    The efforts to limit the spread of COVID-19 around the world have forced a large number of people to work from home and this has naturally created a surge in interest for communication and collaboration tools.

    In this article we are going to look at a video conferencing solution, but instead of turning to a third-party system we are going to take the do-it-yourself approach and build our own. Our system is going to run on modern desktop and mobile web browsers, so participants will not need to download or install any software on their computers. The server-side portion of the project is going to use Python and the Flask framework, and the client-side is going to be built in vanilla JavaScript, with some HTML and CSS sprinkled in the mix for good measure.

    If you are worried that this is going to be a long, difficult and obscure tutorial …

    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
  • Newer
    Older
    Sign up and start building
    Not ready yet? Talk to an expert.