Build the future of communications.
Start building for free

"python" posts

  • By Kelley Robinson
    How to Build a Galentine's Day Compliment Generator with Python, Flask, and Twilio ann, you rainbow-infused space unicorn

    Happy Galentine's Day, you opalescent tree shark! The holiday dedicated to waffles and your best gal-pals only happens once a year, so I built an SMS-based bot that can generate compliments Leslie Knope would be proud of anytime. Send a text to (765) 234-3009 for a preview of what we're going to build in this short tutorial.

    Getting started

    Before we dig into some code, make sure that your Python and Flask development environment is setup. If you haven't done so already:

    1. Create a Twilio account
    2. Buy a phone number
    3. Install Python 3
    4. Install Ngrok to make your Flask app visible from the internet so Twilio can send requests to it
    5. Set up your Python development environment 

    If you're new to Python and Flask check out this handy guide for more information on getting started.

    We also need to install Flask to respond to incoming web requests.

    pip3 install Flask ...
    Read More
  • By Kelley Robinson
    PSD2 Compliant Authorization: Verifying Sensitive Actions with Python, Flask and Authy Screen Shot 2019-02-07 at 3.48.29 PM.png

    Adding two-factor authentication (2FA) to your login process increases the security of your user's data. We can extend that to validate sensitive actions like sending money from your account, changing your shipping address, or confirming a medical appointment. Even though the user should be already logged in with a username and password, we want to make sure that they authorize every payment. This blog post will show you how to secure payment actions using Python, Flask, a bit of Javascript, and the Authy API.

    PSD2 & SCA

    The European Payment Services Directive (PSD2) regulation requires Strong Customer Authentication (SCA) for all transactions over €30 by September 2019. This post will show you how to implement a compliant solution for your application. For more detail on PSD2, SCA, and dynamic linking, check out this post.

    The solution in this post is useful regardless of regulatory requirements. For example, Gemini uses push ...

    Read More
  • By Sameer Dholakia
    Twilio SendGrid Day One: Building My Track Jacket App sameer_jacket_hands.jpg

    From the beginning, Twilio and SendGrid have both enshrined customer experience in their core values. SendGrid strives to be Humble and exemplify a customer-first mindset. Twilio encourages employees to Wear the customer’s shoes.

    We live those values everyday. There’s a hallowed tradition here at Twilio: every Twilion who builds and demos a Twilio powered app earns their red track jacket. Working on an application from a customer’s perspective helps us truly build empathy for our users.

    Today, as Twilio and SendGrid celebrated coming together as one company, I had the opportunity to demo my track jacket app. Using building blocks from Twilio and SendGrid I built an SMS responder which also emails a GIF using Python and the microframework Flask.

    Let’s look at how it works so you can build your own.

    Prerequisites for my SMS and Email Responder

    To reproduce my code you’ll first ...

    Read More
  • By Ryan Kauffman
    How To Save A Child’s Life with Python, AWS IoT, AWS Lambda and Twilio Wireless 77o2jBhjIf7HoBJCaeCdzwMVsEGLGLJaBs9GEDW6I_Dt4VM5Zyi_BjdWnkeZF6oD92ndKyfIHngvH6zHbZOWP14V0JBOGUWlFHskiy1Xk2eeaqcNr_1PXz44GpN4-iygxMVe-3ZN

    Every summer, I read tragic stories of children that die because they were left in a hot car. And every summer, my heart breaks because of the senselessness of the deaths.

    So I decided to build a solution.

    Today, I want to show you how easy it is to build a Help! Button that a child in a hot car could press in order to alert someone that they are in danger and need assistance.

    As an aside, while I was building this project, it occurred to me that children dying in hot cars is actually two problems, not one. It is two problems because:

    1. Toddlers have the cognitive ability to recognize they are in danger and take some action to get out of the situation.
    2. Babies are not capable of recognizing danger, nor capable of taking any action. So a different solution is necessary for each scenario.(I’ll ...
    Read More
  • By Sam Agnew
    Generating music with Python and Neural Networks using Magenta for TensorFlow MIDI Data

    Machine Learning is all the rage these days, and with open source frameworks like TensorFlow developers have access to a range of APIs for using machine learning in their projects. Magenta, a Python library built by the TensorFlow team, makes it easier to process music and image data in particular.

    Since I started learning how to code, one of the things that has always fascinated me was the concept of computers artificially creating music. I even published a paper talking about it in an undergrad research journal my freshman year of college.

    Let's walk through the basics of setting up Magenta and programmatically generating some simple melodies in MIDI file format.

    Installing Magenta

    First we need to install Magenta, which can be done using pip. Make sure you create a virtual environment before installing. I am using Python 3.6.5, but Magenta is compatible with both Python 2 and ...

    Read More
  • By Joe Previte
    Identify Unknown Phone Numbers with Python 3, AWS Lambda, Twilio Lookup and SMS yq5zLkCfUFXfnq3eUlOjkM6oGzJMGVmwBT54nLVanuWt89DrhM0IelXCqJ6FErJTDeNv096tZzkHdpRbjtFssmyWQW25cPpPngLULcmpSjHYtIprWe1U4oZcPVi7W9tB5u13Xiiw

    Ever receive a text, probably from an old friend, but you don’t have their number saved? And you’re too embarrassed to ask, “Who is this?”.

    Don’t worry. We’ve all been there. But today, we’re here to tell you that we have a solution to avoid this situations! Let's build a small Python app that uses Twilio Lookup and SMS to help you lookup phone numbers over text on the go.

    The Tech Stack of Our App

    Our app will use two AWS products and two Twilio APIs:

    - AWS Lambda: the serverless environment which will hold our functions

    - Amazon API Gateway: our API which exposes our Lambda to our Twilio number

    - Lookup: to look up the phone number and see who it belongs to

    - SMS: to send us a text with the phone number.

    Here’s how everything will work together:

    1. We’ll send a text ...
    Read More
  • By Alex Laird
    Using Twilio to Build a Serverless SMS Raffle in Python GmRICmhwjC02v09YluVqfcQoHzr4641UIgNkcJW4pit2b6YFeD0e5W9GOdKIEgCmPjoeELWq0MU22kVx-BK_H92JSUG84XO5ZVpAvG79J81hYXlVH2KT6XS-vEneNNDLp706hswu

    If you’re like me, you drool just a little bit over serverless architectures. When Rackspace and AWS EC2 made cloud-based computing a mainstream reality, that was awesome enough. But you still had to spin up and maintain your own virtual servers.

    With the introduction of things like Twilio Functions or Lambda for truly serverless function execution, DynamoDB for cached state, and API Gateway for click-and-deploy routing—just to name a few—it’s become deliciously easy to build and deploy powerful (and fun) services in minutes. Seriously, the IoT possibilities are endless!

    With that in mind, let’s build something fun with Python – a Serverless SMS Raffle. What if users could text a word to a phone number and were entered in to a raffle? Then when we were ready to choose a winner, we could execute a Lambda to choose some number of winners at random and close ...

    Read More
  • By Sam Agnew
    Working with JSON in Python json

    Often developers need to deal with data in various different formats and JSON, short for JavaScript Object Notation, is one of the most popular formats used in web development. This is the syntax that the JavaScript language uses to denote objects.

    As a Python developer, you may notice that this looks eerily similar to a Python dictionary. There are several different solutions to working with JSON in Python, and more often than not this data is loaded into a dictionary.

    For this post, we are going to use the following modified JSON data from NASA's Astronomy Picture of the Day API. Navigate to where you want to run the example code, create a file called apod.json and add the following to it:

        "copyright": "Yin Hao",
        "date": "2018-10-30",
        "explanation": "Meteors have been shooting out from the constellation of Orion. This was expected, as October is the time of year for ...
    Read More
  • By Lesley Cordero
    Getting Things Done in Trello with Python, Flask and Twilio SMS DtWKZlxXe9iGEfIBw3E0HwBIbjtjcjBCY9-_aTM8b63Nr0a3PXzG-2mtaryFhcav6UKEEl3VDbnfo7ecyhMaojdxHa-rVN_XczlQIgWOUH5WYSTwu64eqACinscIcypwwYb_R86p

    Do you ever have so many things to do that you can’t even decide where to begin? This is me, all the time. So every once in a while, when I’m a bit overwhelmed by all the tasks I have to do, I make my code decide for me. In this tutorial, we’ll build a system that responds to a text with a to-do item. I’m an avid Trello user so we’ll use the Trello API and Twilio API to send tasks via SMS.

    First, we have to set our environment up. This guide was written in Python 3.6. If you haven't already, download Python, Pip and Ngrok. Next we will install virtualenv to create and activate your virtual environment by entering the followings command in your command-line:

    pip3 install virtualenv==15.1.0
    python3 -m venv twello
    cd twello
    source ./bin/activate

    Next ...

    Read More
  • By Ajao Iyanu
    Build and Deploy Twitter Bots with Python, Tweepy and PythonAnywhere Twitter and Python logos

    This article will guide beginner Python developers on creating Twitter bots. You will learn the Twitter API while building a your bot and then you will deploy the bot to a cloud platform. The Twitter bot tweets quotes randomly selected from a Random Quotes API service.

    Development Environment

    To build our Twitter bot, we first need to set up our Python development environment and install the required packages that are needed for us to follow along with this tutorial.

    In addition to Python 3, we will be using:

    • virtualenv – a development environment
    • Requests library – a http library for humans
    • Tweepy – an API wrapper for Twitter
    • json – a built-in Python library for working with json
    • time module – a built-in Python library for working with time

    First of all, it is highly recommended and best practice to create a virtual environment before you begin any Python project. We will create a virtual ...

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