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

Code, Tutorials and Hacks

  • 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 Elvis Rosario
    Automatically Trigger Twilio SMS in MongoDB through MongoDB Functions Automatically Trigger Twilio SMS in MongoDB through MongoDB functions

    There are quite a few cases in an application when you want to trigger notifications to users on database changes. One of the most common examples would be updates to feeds. When a new web feed arrives in your database you would want to send a notification to your users regarding this feed.

    Usually, in an application, you might trigger an event after storing the feed in your database, which will asynchronously send a notification to your users. But is that the best solution available out there? Wouldn’t it be a lot better if you could send messages automatically when a document is created or updated in a collection, thus separating it from your business logic?

    Recently, MongoDB Atlas released MongoDB functions as part of their new collaboration with Realm. These functions currently support modern JavaScript (ES6+) syntax and execute in a serverless manner. It is part of their …

    Read More
  • By Oluyemi Olususi
    Build a GraphQL Powered API with Laravel Build a GraphQL Powered API with Laravel

    Often referred to as a platform or programming language agnostic query language, GraphQL is a comprehensive approach to guide software engineers in building data-driven applications. It is, in my opinion, the new API standard, offering client applications the flexibility to request exact data and not an entire record from the database. If you are not yet conversant with this technology or looking for simplified technical content to guide you through, you are in the right place.

    In this tutorial, you will learn some of the fundamental concepts required to build a Laravel API powered by GraphQL. This is a shift from the conventional architecture of building REST APIs, as we will take a different approach in this tutorial. To help us explore GraphQL, we will build a bookstore API with an ability to carry out CRUD ( Create, Read, Update, Delete ) operations on data, in your database.

    Prerequisites …

    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 Maciej Treder
    Asynchronous JavaScript: Using Promises With REST APIs in Node.js async-js-apis-nodejs.png

    In JavaScript, like many programming languages, asynchronous processing can be used to handle tasks that take a long time to run or are potentially unresponsive. The JavaScript Promise object provides a way of monitoring their state and serves as a placeholder and container for the data they’ll eventually return — or not.

    Often it doesn’t matter when a Promise returns data and the members of a collection of Promises can be resolved independently without regard to timing. A function can perform asynchronous tasks that don’t depend on the data from, or the success of, other asynchronous tasks.

    But sometimes business rules or program design require that asynchronous actions are dependent on other asynchronous operations. For example:

    • Establishing a remote database connection must be preceded by loading configuration information from the file system.
    • Performing a REST API call to a weather API must be preceded by obtaining the user’s location from …
    Read More
  • By Phil Nash
    How to build a one-time passcode protected conference line with Twilio Verify and Ruby How to build a one-time passcode protected conference line with Twilio Verify and Ruby

    We've seen how to build a conference line and then protect it with a static passcode. However, passcodes can be guessed or leaked, especially if they are reused over time. An alternative is to make a list of numbers that are permitted to join the call. But, since spoofing phone numbers is relatively easy, this still may not protect you.

    A one-time passcode (OTP) sent to a caller's phone or email, can verify they are who they say they are and increase the security of your conference line once more.

    In this post we will take the Rails application we previously developed and add a conference line secured in two ways. We will:

    1. Ensure that the caller is a known participant by checking their caller ID against a list of permitted phone numbers
    2. Send them an OTP using Twilio Verify which they then have to enter correctly to ensure …
    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 Isabel Hildebrand
    Tracking Time Spent in Meetings With Google Calendar, Twilio, and n8n tracking-time-with-n8n.png

    Time is a commodity that can’t be purchased but, if managed well, you can free up time to spend on the things you love. According to an article by Dorie Clark of Duke University in the Harvard Business Review, tracking your time can give you a better overview of how you spend your time during the week.

    You might realize that you’re spending too much time during the week on meetings. If you are curious to learn exactly how much time — even if you dread the answer — this post is for you!

    In the tutorial that follows you’ll learn how to pull the details of your meetings from your Google Calendar using the Google Calendar API. Then you’ll use Twilio Programmable SMS to send yourself a weekly text message with the total for the previous week. 

    You’ll also learn how to use n8n (pronounced “nodemation”) to create …

    Read More
  • By Diane Phan
    Embark on an Adventure to Build Your Digital Presence: Redirect a Website to Another Domain Name header - Embark on an Adventure to Build Your Digital Presence: Redirect a Website to Another Domain Name

    You might have reached the point in your career where you ask yourself the question, “should I invest in a personal domain name?” If you are a young professional who owns a GitHub page for their portfolio and is looking to build their online presence, then the answer is “yes!” It is absolutely time to build your digital brand.

    Follow along this journey to learn how to quickly redirect your GitHub Pages site (normally located at your username.github.io) to your custom domain name in less than 10 minutes! Get ready to impress people by sharing a newly accessible URL to showcase your interests and hackathon projects.

    Tutorial Requirements

    • A GitHub repository with static files for your personal site. If you’re reading this, you might already have a functional portfolio site hosted on a GitHub page with a free github.io domain name but want to change your domain name. You do …
    Read More
  • Newer
    Older
    Sign up and start building
    Not ready yet? Talk to an expert.