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 Grinberg
    How to Receive Images on WhatsApp using Django and Twilio How to Receive Images on WhatsApp using Django and Twilio

    The WhatsApp Business API from Twilio is a powerful, yet easy to use service that allows you to communicate with your users on the popular messaging app. In this tutorial you are going to learn how to create a Python application based on the Django web framework that can receive and handle images sent by your users on WhatsApp.

    Project demo

    Prerequisites

    To follow this tutorial you need the following items:

    The Twilio WhatsApp sandbox

    Twilio provides …

    Read More
  • By Kyle Lawlor-Bagcal
    Build a Voice Conference Line with Twilio, Python and Flask Build a Voice Conference Line with Twilio, Python and Flask

    In this tutorial you will walk through the process of setting up a basic voice conference phone line using Twilio Programmable Voice, Python and Flask. By the end of this tutorial you will have a conference call room with a security PIN implemented, plus a demonstration of how to process events from the call in real time.

    The only prerequisite step you need to follow before you begin working on the tutorial is to have installed Python 3.6 or newer on your computer. The tutorial will walk you through setting up your Twilio account and preparing the Python virtual environment required to run and develop the application.

    Setting up your Twilio Account

    If you do not already have a Twilio account please follow these sections from the official Twilio guide. You only need to complete these sections for this tutorial:

    1. Sign up for your free Twilio trial
    2. Verify …
    Read More
  • By Miguel Grinberg
    Flaskアプリケーションの実行方法 how to run a flask app header

    この記事はMiguel Grinbergこちら(英語)で執筆した記事を日本語化したものです。

    長い間、Flaskアプリケーションの有名な「Hello, World」というサンプルコードは、7行構成でした。以下は、2017年6月12日のFlask Webサイトのスナップショットです。

    old flask website

    その後、このサンプルアプリケーションは5行に短縮されました。以下は2017年6月17日の同じページです。

    new flask website

    ご覧のように、アプリケーションのコア部分は変更ありませんが、アプリケーションサーバーの開始方法が大幅に変更されています。以前のサンプルでは、アプリケーションスクリプト内で単純なapp.run()コールを使用していますが、新しいサンプルではflask runコマンドとFLASK_APP環境変数を使用しています。

    その後の数年間でFlask Webサイトのデザインは大きく変わりましたが、この記事を執筆している2020年の段階では、flask runメソッドはフレームワークの公式ドキュメントで最も頻繁に目にします。

    現在も、多くのアプリケーションやコードチュートリアルでapp.run()メソッドが使用されています。理由の1つは、Flaskでは古くとも重要なコンテンツが数多く存在しているためです。app.run()が今も便利で使いやすいコマンドとして、広く利用されていることもあります。

    この記事では、それぞれのメソッドの長所と短所について解説します。では、本題に入りましょう。

    「app.run()」と「flask run」のどちらを使用するべきか?

    最初から難しい質問が登場しま …

    Read More
  • By Miguel Grinberg
    Build a Phone Tree with Python, Twilio and a State Machine Build a Phone Tree with Python, Twilio and a State Machine

    The Twilio Programmable Voice service provides a complete line of features that allow you to implement phone trees or Interactive Voice Response (IVR) systems for your business or organization.

    In this tutorial you will learn how to create an extensible phone tree using Python, the Flask web framework, and the power and simplicity of a state machine. The phone tree that you are going to have by the end of this tutorial will match the following diagram:

    Phone tree diagram

    Tutorial Requirements

    Read More
  • By William Essilfie
    Construire des bots Facebook Messenger avec Python Construire des bots Facebook Messenger avec Python

    Ah, la magie des chatbots... Ces produits remarquables permettant aux individus de créer de nouvelles expériences, allant de l'envoi d'actualités personnalisées à la diffusion d'informations sur les soins de santé destinés aux femmes. La première fois que j'ai entendu parler des bots, je n'imaginais pas que je serais un jour capable d'en créer un moi-même. Cela étant, je me suis vite plongé dans la documentation de Facebook Messenger et j'ai commencé à apprendre comment faire fonctionner un bot en un rien de temps, avec un peu de Python 3 et de Flask.

    Dans cet article, nous aborderons les bots en allant des notions de base sur leur fonctionnement jusqu'à la construction de notre propre bot Facebook Messenger basique. Nous allons plus précisément construire une version de base de Black Girl Magic Bot, un bot Facebook Messenger qui envoie aux utilisatrices des images, des listes de lecture, et …

    Read More
  • By Sam Agnew
    How Python has changed from the perspective of the Brood X Cicadas Copy of Generic Blog Header 3(6).png

    Every 17 years in the Eastern United States, billions of cicadas belonging to a brood called Brood X emerge from their underground burrows. Their last emergence was in 2004, and now in 2021 they are out and about once again.

    A lot has changed over the last 17 years for these cicadas to catch up on, including massive updates to the Python programming language. Let's take a look at Python 2.3.4, the version of Python released in May 2004, and see how it differs from how we write Python today to put things in perspective for our buggy friends.

    Two cicadas on a leaf

    from may_2004 import newest_python_version

    Releases for old Python versions are all still available on python.org, including Python 2.3.4, the that the Brood X Cicadas are most familiar with.

    On this release archives page there are two tarball source release files, as well as a Windows installer. You can compile these …

    Read More
  • By Miguel Grinberg
    Manage the Recordings of Your Video Calls with the Twilio Compositions API, Python and Flask Manage the Recordings of Your Video Calls with the Twilio Compositions API, Python and Flask

    Do you use Twilio Programmable Video for your video meetings? One of the many optional features is to enable recording of your video rooms. When recording is enabled, each participant's audio and video are recorded in separate tracks. You can then use the Compositions API to combine these tracks into a single playable video that will be compatible with most common media players.

    In this tutorial, you will learn how to build a quick application for creating, viewing, and downloading your video compositions using the Compositions API, Python, and the Flask web framework. Let's get started!

    Prerequisites

    • 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 Twilio account. If you are new to Twilio click here to create a free account now and receive $10 credit when you upgrade to a paid account. You can …
    Read More
  • By Miguel Grinberg
    SMS Usage Alerts for your Twilio Account with Python and Flask SMS Usage Alerts for your Twilio Account with Python and Flask

    The Twilio API has many capabilities, including allowing you to keep track of how much money you spend on it. In addition to checking your usage amounts, you can also set up a trigger that will let you know when you’ve spent a certain amount or made a given number of API calls. To learn how to do this, follow along!

    Prerequisites

    To get started with this tutorial, you’ll need the following items ahead of time:

    Project setup

    In this section you …

    Read More
  • By Renato Byrro
    Python Error Alerting with Twilio and SendGrid Python Error Alerting with Twilio and SendGrid

    Error detection is a key part of any application deployed in the cloud. No matter how much care we give to testing and software quality, there will always be factors - sometimes outside our control - that can make our applications fail.

    In this article, we will build a native Python solution that extends the standard logging library to send application failure alerts through Twilio Programmable SMS and/or SendGrid Email APIs.

    Requirements

    We will be using Python 3.9, but any version of Python from 3.6 should work as well. You can download Python from the official python.org website.

    Since our code will use Twilio and SendGrid services to dispatch error alerts, you will need an account in at least one of these services (ideally both). We provide instructions below on how to sign-up or log-in and also collect the data you will need from each account.

    Twilio Account

    Login to …

    Read More
  • By Diane Phan
    How to Use Image Recognition on Twilio WhatsApp API header - How to Use Image Recognition on Twilio WhatsApp API

    The concept of recognizing images might seem like a challenge, but with the help of Clarifai's image recognition API, the code can predict the contents of a given image and figure out the concepts to describe the picture, as well as the prediction value of how accurately the image is classified.

    In this article, we’ll walk you through how you can develop a functional Python program to identify media content using Twilio WhatsApp API, Clarifai API, and Flask.

    gif demonstration for How to Use Image Recognition on Twilio WhatsApp API

    Tutorial Requirements

    In order to build this project, you will need to have the following items ready:

    • 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 is a handy utility to connect the development version of our Python application running on your system to a public URL that Twilio can connect to. …
    Read More
  • Newer
    Older
    Sign up and start building
    Not ready yet? Talk to an expert.