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 Renato Byrro
    Receive SMS Transaction Notifications for your TransferWise Account with Twilio and Python Receive SMS Transaction Notifications for your TransferWise Account with Twilio and Python

    TransferWise is a digital bank that can save us from dread expensive bank fees. I have an account and love the service, but I’m really concerned about bad actors defrauding my card or login credentials.

    What if TransferWise would send proactive alerts on debit transactions? Then I could act quickly to lock it down and minimize losses in case anything bad happens.

    Twilio to the rescue!

    In this tutorial, we’ll build a real time bank account monitor with the Transferwise API and Twilio SMS API. The application will send SMS alerts to a phone number notifying about debit transactions.

    Preparing the requirements

    To follow this tutorial, you will need the following:

    Python: we’ll use Python3.9 (latest stable), but the code should also run on Python3.6+. To download and install, follow instructions on the official website. Python runs on Windows, Linux/UNIX and MacOS.

    TransferWise account: if you …

    Read More
  • By Diane Phan
    Build React Projects with a Background in Python, Flask, HTML, and CSS header - How to Pick Up React from a Python, Flask, and HTML Background

    There comes a time in every developer's life when they have to figure out – do I need to learn a new language for this? Should I stop using Python and try out a JavaScript project? How do I know if React is the right tool for me to use over Vue? There's just so much out there – and you're not alone in having these thoughts.

    Although learning Python can help you pick up other languages, it can be a challenge to figure out which technologies make the most sense for you and your project. In this post, I’ll show you React, a JavaScript library that has plenty of support online from professionals within the industry as well as independent developers.

    In this article we’ll build a simple Flask app and change it so that it can be scaled up further using React. This will help you see the …

    Read More
  • By Alex Kiura
    Build a GraphQL API with Subscriptions using Python, Asyncio and Ariadne Build a GraphQL API with Subscriptions using Python, Asyncio and Ariadne

    In my previous GraphQL article, we learnt about creating a GraphQL API that implements queries and mutations. GraphQL, however, has a third type of operation called subscriptions.

    Nowadays, most applications have a real-time component. For example, social media applications notify you in real time of new messages, or ride hailing apps stream the driver’s location in real time. GraphQL subscriptions allow a server to send real time updates to subscribed clients each time new data is available, usually via WebSocket.

    In this tutorial, we will build a project in which the server pushes messages sent by other users to subscribed clients.

    Requirements

    The only requirement to follow this tutorial is to have Python 3.6 or higher installed.  If you don’t have it installed, get it here.

    Create a Python virtual environment

    We will install a few Python packages for our project. A virtual environment will come …

    Read More
  • By Miguel Grinberg
    How to Check your Twilio Account Balance in Python How to Check your Twilio Account Balance in Python

    Twilio APIs make it easy to add communication features to your application, but to consume these APIs you have to keep track of your spending and ensure your account balance stays above zero.

    Your balance is available in the main page when you log in to your Twilio Console, but having to actively monitor your account is tedious and inconvenient. In this tutorial you are going to learn how to retrieve your account balance using Python, which will allow you to build automated account balance monitoring within your application!

    Prerequisites

    To follow this tutorial you will need:

    • 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.

    Creating a Python …

    Read More
  • By Miguel Grinberg
    Generating Twilio Access Tokens in Python Generating Twilio Access Tokens in Python

    Several Twilio services can be accessed from a web application running on the browser, but given that this is an inherently insecure platform, the authentication flow is different than for server-based applications.

    An application running on the browser needs to obtain an Access Token from your server, and then use this token to authenticate. This is more secure because it prevents you from having to expose your Twilio account credentials in the browser, and also because access tokens have a short lifespan. In this tutorial you are going to learn how this authentication flow works and how to generate access tokens for Twilio services using Python and the Flask framework.

    Tutorial requirements

    To follow this tutorial you will need:

    • 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 …
    Read More
  • By Liz Moy
    Building a Netflix Recommendation SMS Bot with Python and Twilio Autopilot for #GiftofCode Build a Netflix Bot with Python and Autopilot

    Photo from freestocks.org used under Creative Commons Zero

    For #GiftofCode this year I wanted to build something useful for my family. One fun conversation topic that’s kept us close is what we are watching on Netflix and other streaming platforms.

    While the in-app experiences of most major streaming apps give recommendations aplenty, making a recommendation bot that someone could text sounded like a fun thing to try.

    I had a few requirements in mind for this one:

    • Power the bot using Twilio Autopilot
    • Ask the texter for the type of media they want to watch and which genre
    • Use the Netflix “Viewing Activity” data to determine shows and movies my family has already watched
    • Use a publicly available API in case other folks want to build their own

    There are some useful streaming metadata APIs available. A robust paid option that I tried out was Reelgood. I ended up …

    Read More
  • By Miguel Grinberg
    Server Push in 5 Easy Steps with Flask, React and Twilio Sync Server Push in 5 Easy Steps with Flask, React and Twilio Sync

    When considering a server push solution for your web application, you will likely evaluate WebSocket, HTTP long-polling, Server-Sent Events and maybe even Socket.IO. In this tutorial I want to introduce you to yet another option that you may not know: Twilio Sync. Sync is a cloud synchronization service that works across browsers and mobile devices and that it is incredibly easy to integrate with your application.

    To learn how Twilio Sync works, we are going to add server push capability to a small web application that has a React front end and a Python and Flask back end. We’ll get the job done in just five easy steps!

    server push demo

    Note that “server push” in this context refers to technologies that allow web servers to initiate an exchange with clients and “push” events, notifications or data to them. Do not confuse this with “HTTP/2 Server Push”, which is …

    Read More
  • By Taylor Facen
    Sharing Data Between Services Using Python and Twilio Sync Sharing Data Between Services Using Python and Twilio Sync

    If you have an application that uses multiple Twilio services, you’ve probably used a database to share data from one medium to another. Although this gets the job done, it’s not always scalable, fast, or easy to implement. Twilio Sync is a service that allows data to be easily stored and shared across devices, services, and even other Twilio APIs. This blog post will demonstrate how to use Sync by building a voice memo application that utilizes Autopilot, SMS, and Voice, all from Python. By the end of this project, you’ll know how to make data flow from text to voice and back to text all within milliseconds!

    The goal of the Voice Memo bot is to allow users to create, record, and retrieve voice memos on their phone. First, the user sends a text to the project’s Twilio number saying that they want to create a …

    Read More
  • By Grey Li
    Build a Collaborative Whiteboard with Python, Flask, and Twilio Sync Build a Collaborative Whiteboard with Python, Flask, and Twilio Sync

    In this tutorial, we will implement a collaborative whiteboard that can be edited by multiple users at the same time. To build this project we will use three key components:

    • Flask, a Python web application framework
    • Twilio Sync, a state synchronization service
    • Canvas API, a set of functions to draw graphics on a web page using JavaScript and an HTML <canvas> element

    The project will present a whiteboard that you can access from multiple web browsers. When any of the connected users draws on it, the others will immediately display the drawing.

    Sync whiteboard demo

    Tutorial requirements

    To follow this tutorial, you will need to have the following requirements:

    • A computer with Python 3.6 or a newer version installed. If your operating system does not provide a Python package, download an official build from python.org.
    • A free Twilio account. If you use this link to register, you will …
    Read More
  • By Gabriela Cavalcante
    Build an SMS Microservice using Python, Twilio and Redis Pub/Sub Build an SMS Microservice using Python, Twilio and Redis Pub/Sub

    A few weeks ago I needed to build a solution to send alert messages to clients of my company. The core service had access to the database, but this service had many responsibilities already and adding a new feature to send a large number of messages could overload it. So I decided to use a different approach: the core service gets the users that should receive the message from the database and builds the message content, but then sends everything to a separate service that actually sends the messages.

    This new service that sends SMS messages could be used for many other applications: an alert service to notify clients of promotions, or maybe a reminder service of scheduled appointments. Since it is completely generic, it is easy to reuse it.

    For this tutorial we are going to build a simple example of two Python services communicating using Redis Pub/Sub. …

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