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
    A Phone Number Input Field for Flask Forms A Phone Number Input Field for Flask Forms

    The Flask-WTF package makes working with forms in Flask straightforward and even fun – unless you need to include a field that falls outside of the standard primitive field types.

    Consider an application that needs to ask users for their phone number in a friendly way, regardless of the country or region the user is in. You could use a standard text input and hope your users know how to enter their phone number, but based on my experience, you are going to find that many users do not know the rules to enter a full phone number that includes the country code and can be used internationally.

    In this post, we’ll build an example Flask application that includes a phone number field that makes it virtually impossible to enter an invalid number.

    Phone number input field demo

    As you can see, this field includes a dropdown that lists all the countries, with cute little …

    Read More
  • By Miguel Grinberg
    Add Two-Factor Authentication to a Python Flask Application with Twilio Verify Add Two-Factor Authentication to a Python Flask application with Twilio Verify

    Twilio Verify is an easy-to-use service that allows your application to send verification codes to your users via SMS or phone call. While the main purpose of this API is to verify users when they sign up for a new account, I want to show you how the same functionality can be used to quickly implement two-factor authentication support.

    In this article I’m going to take a complete, non-trivial Python application that uses the Flask framework and modify it to allow users to optionally enable two-factor authentication on their accounts. The application that I’m going to use for this exercise is the one featured in my Flask Mega-Tutorial, a microblogging web application very appropriately, though unoriginally called Microblog.

    To give you a taste of what this looks like once implemented, below you can see how a user enables two-factor authentication on this application:

    Two-factor authentication demo

    Once two-factor is enabled, the …

    Read More
  • By Tilde Thurium
    Sending Bulk Emails With Twilio SendGrid and Python Sending Bulk Emails with Twilio SendGrid and Python

    Sending a single email is great, but one of the big advantages of email is the ability to quickly reach a wide audience. Today I’ll show you how to send mass emails with Python and SendGrid. Just for fun, let’s say you’re a Python developer who works at a donut shop. You need a way of letting the customers who have signed up for your email list know when fresh donuts have come straight out of the oven. 🍩

    Prerequisites

    Read More
  • By Brian Iyoha
    Building a Food Ordering App in PHP with Laravel and Twilio SMS Building a Food Ordering App in PHP with Laravel and Twilio SMS

    In this tutorial, I will teach you how to use Twilio’s Programmable SMS to create an SMS based food ordering service using Laravel. After we’re finished, your users will be able to place orders for food items via SMS.

    Prerequisites

    In order to follow this tutorial, you will need:

    Getting Started

    Start off by creating a new Laravel project. This can be done using either the Laravel installer or Composer. We will be making use of the Laravel installer in this tutorial. If you don’t have it installed, you can check out how to do so from the Laravel documentation.

    To generate a fresh Laravel project, run the following command on your terminal:

    $ laravel new twilio-food-ordering
    

    Next, proceed to install the Twilio SDK for PHP. Change your working directory to …

    Read More
  • By David Pine
    Running a Twilio Video Chat Application Built with Angular 8 and ASP.NET Core 3.0 on Microsoft Azure running-twilio-video-chat-asp-net-3-azure.png

    With Twilio Programmable Video you can add robust video chat functionality to web applications built with Angular and ASP.NET Core. With the Microsoft Azure App Service you can host your video-enabled apps on a fully managed, enterprise-grade cloud platform. Deployment and configuration are easy and take just minutes.

    Build a Video Chat App with ASP.NET Core 3.0, Angular 8, and Twilio showed you how to integrate the Twilio JavaScript SDK and the Twilio .NET SDK seamlessly with ASP.NET Core and Angular. This post will show you how to deploy applications built with these technologies to the Azure App Service.

    In this post you will learn how to publish your application to the Azure App Service, and securely configure the app on Azure to use the Twilio Video Chat API with the App Service settings. You’ll be able to try out the production applications’ video chat features and verify that it’s …

    Read More
  • By Brian Iyoha
    Securing a Laravel PHP Application with 2FA using Twilio Authy Securing a Laravel PHP Application with 2FA using Twilio Authy

    In this tutorial, you will learn how to secure your Laravel application with Two-factor authentication using Twilio Authy.

    Prerequisites

    Completing this tutorial will require the following:

    Getting Started

    Create a new Laravel project using the Laravel Installer. If you don’t have it installed or prefer to use Composer, you can check out how to do so from the Laravel documentation. Run the following command in your terminal to generate a fresh Laravel project:

    $ laravel new twilio-authy
    

    Next, you will need to set up a database for the application. For this tutorial, we will make use of MySQL database. If you make use of a database administrator like phpMyAdmin for managing your databases then go ahead and create a database named twilio-authy and skip this section. If not, install MySQL from …

    Read More
  • By Gary Hockin
    Adding Twig as a View Renderer to Slim in PHP Adding Twig as a View Renderer to Slim in PHP

    Slim is an excellent PHP micro-framework. Out of the box it gives you compatibility with PHP standards (PSRs), PSR-11 for the container, PSR-7 for HTTP messages and PSR-15 for middleware. Its lightweight design gives you the bare minimum to get started with your web application; routing, a middleware dispatcher, error handling and a container. You need to wire up the additional services needed to handle requests and return responses.

    But where do we start? Let's take a look at installing a clean installation of Slim from a community skeleton, and add our first component to it; the Twig templating engine.

    Starting with Slim

    Slim provides a skeleton application that lets you get started quickly, but it's designed more with an API in mind than a web application. I prefer to start with a more lightweight skeleton from Slim maintainer Rob Allen. Rob’s starter comes with PHP-DI dependency …

    Read More
  • By Phil Nash
    Track email statuses in Ruby on Rails with SendGrid Track email statuses in Ruby on Rails with SendGrid

    When your application sends emails it is useful to know what happens to those emails, like whether it has been delivered or opened. Or, sometimes more importantly, whether it bounced. The Twilio SendGrid email API doesn't just send emails, it can also send you events via webhook that tell you what happened to your emails.

    In this post we'll build a small application using Ruby on Rails to send emails and update their status based on the Twilio SendGrid event webhooks.

    What you'll need

    In order to build this application along with this post, you will need:

    If you have all of that, then you're ready to get building.

    Preparing the example application

    I …

    Read More
  • By Dustin Ewers
    Containerize an Existing .NET Core App with Docker and Deploy It to Azure containerize-existing-dot-net-docker-azure.png

    In a previous post you learned how to take a fresh application and deploy it to a Kubernetes cluster. While it’s great to start with a new application, most of us don’t get that luxury. Usually, you’re going to start off with something older and have to refactor and then migrate it.

    This tutorial will show you how to take an existing application, refactor it using cloud-native principles, and deploy it to Azure Kubernetes Services. By the time you’re done, you will know how to move your own applications to the cloud.

    Cloud Migration Patterns

    When migrating applications to the cloud, there are a handful of different patterns you can follow. Which pattern you choose will depend on what you are trying to migrate and how much time you want to spend migrating them. Each of these patterns has different tradeoffs, so it’s good to understand them all when looking …

    Read More
  • By Miguel Grinberg
    Build a SMS Chatbot With Python, Flask and Twilio Build an SMS Chatbot with Python, Flask and Twilio

    In a previous article I showed you how to build a WhatsApp chatbot with Python, Flask and Twilio. Today I’m going to use similar techniques to build a chatbot that communicates with users through text messages using Twilio’s Programmable SMS.

    The chatbot that I’m going to build performs a simple analysis of what the user writes to find keywords of interest, which trigger the response of the chatbot. The two keywords in my implementation are “quote” and “cat”, which trigger responses of famous quotes and cat pictures respectively.

    Below you can see the chatbot in action:

    Chatbot demonstration

    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.
    • Flask. We will create a web application that responds to incoming SMS messages with it.
    • ngrok. We …
    Read More
  • Newer
    Older
    Sign up and start building
    Not ready yet? Talk to an expert.