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 Tilde Thurium
    Fighting Impostor Syndrome With Twilio Internet of Things Fighting-Impostor-Syndrome-Twilio-IoT

    If you’re reading this, you’ve probably grappled with impostor syndrome at one time or another.

    Experience doesn’t always help, either. As our skills grow, we tackle harder problems. Technologists are always working at the edge of our knowledge.

    What can we do to fight impostor syndrome? Studies have shown that self-affirmation can counteract negative ruminations and increase achievement.  So I decided to build an Internet of Things button that delivers an SMS affirmation when pressed.

    Physical responses to negative thoughts

    Why use hardware to fight imposter syndrome?

    This project could totally be a web application. But – taking a physical action in response to negative thoughts helps ground me emotionally.

    Using SMS lets me receive the affirmation without the cognitive load of opening another browser tab. Twilio’s IoT capabilities let me take the button anywhere with cell service. No WiFi configuration required!

    The imposter syndrome button was my first hardware …

    Read More
  • By Sam Agnew
    Working with MIDI data in Python using Mido Working with MIDI data in Python with Mido

    MIDI is an extremely popular and versatile format for music data, whether you're using it as a digital musical instrument interface or just transcribing music in it to show your bandmates new songs. Mido is a Python library you can use to interact with MIDI in your code.

    Let's walk through the basics of working with MIDI data using the Mido Python library.

    Setting up

    Before moving on, you will need to make sure you have an up to date version of Python 3 and pip installed. Make sure you create and activate a virtual environment before installing Mido.

    Run the following command to install Mido in your virtual environment:

    pip install mido==1.2.9

    In the rest of this post, we will be working with these two MIDI files as examples. Download them and save them to the directory where you want your code to run.

    VampireKillerCV1.mid …

    Read More
  • By Ryan Kauffman
    How to Make a Smart Baby Monitor with Python, Raspberry Pi, Twilio SMS, and Peripheral Sensors How to Make A Smart Baby Monitor with Python

    Have you ever wanted a smart monitor that not only lets you see your kids, but also texts you the temperature in their crib, so you can be certain they are comfortable? I certainly have!

    That’s why I made the Raspberry Pi (RPi) Smart Baby Monitor, and I want to show you how easy it is to build yourself using Twilio, a Raspberry Pi, and a little bit of code.

    Here's my son at 4 months old along with the smart baby monitor I created for him:

    Smart baby monitor

    The Tech Stack

    The IoT app we are going to create will use the Python programming language, a Raspberry Pi, a Raspberry Pi camera, a DS18B20 temperature sensor, and the Twilio SMS API:

    - Python version 3.5: The language we will write our code in

    - Raspberry Pi: Environment that will hold our software (code) and our hardware (peripherals)

    - RPi …

    Read More
  • By Matt Makai
    Spaces Not Tabs: Our Favorite Python Tutorials for May 2019 E8UIen2vI0xmW5JjQD5o87O584rJJRBGTFuNOjzkjdWcQAveKKqQgFta7tdwIJ0kgAZifeOW64y212a0AIZOLGJ5iOrumK0T0PnTR3aJTDUFD2m6TOMnTZbod3Vno1q8UfhhqW3t

    Python programmers love to help – the community publishes detailed tutorials for their fellow developers every day. Over the last month, we’ve been collecting some of those posts we found most helpful.

    Each tutorial is easy enough for beginner-level programmers to follow. More experienced developers should be able to breeze through the code while building a useful project, or use them as convenient refreshers.

    Whichever bucket you belong to, enjoy the posts!

    Exercising, or Slacking? Build a Python Bot for Either

    The term "bot" feels so 2017 in this community. However, they are still a great way to learn how to build Python applications.

    Use Bokeh to Visualize All the Data!

    Bokeh, the wonderful Python visualization library …

    Read More
  • By Sam Agnew
    How to Send Emails in Python with Sendgrid PythonEmails

    So you're building a Django or Flask app and you need to programmatically send some emails. The Twilio SendGrid API for sending email is a great solution to this problem. If you have a SendGrid account and an API key set as an environment variable, here is all the code you need to send an email in Python:

    import os
    from sendgrid import SendGridAPIClient
    from sendgrid.helpers.mail import Mail
    message = Mail(
        subject='Sending with Twilio SendGrid is Fun',
        html_content='<strong>and easy to do anywhere, even with Python</strong>')
    sg = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
    response = sg.send(message)
    print(response.status_code, response.body, response.headers)

    Let's walk through how to get this running step by step.

    Development Environment Setup

    Make …

    Read More
  • By Matthew Vielkind
    Build Your Own Personal Training Exercise Bot with Python, Zappa, AWS and Twilio SMS lc0KtAlkT8PNC0ldM_tqY52yk6vDUA_HhKuGCEGm1vXbHgz7bp_sfxcjUnzN06rM_LyLN_6soOY7yUgSebofc7HbJTQhDPpLzM8jpkll-y3iS9RPdmiU66AyfS4oSiYHqZ_GGP8W

    Heading into the new year I wanted to set myself up to be successful living a healthier life.  Saying you’re going to do something is easy, following through with action is the hard part.  To ensure success being more physically active I needed help with a seemingly simple question, what should I do for a workout?  With so many options available I wanted to spend less time thinking about what I’m going to do and more time doing the actual workout.  

    I needed a prescriptive solution to dictate a workout each day that would be balanced with enough daily variation to avoid becoming redundant.  Most of the fitness apps available allow tracking of workouts, but lack the prescriptive component I was looking for.  

    Unsatisfied, I decided to roll-up my sleeves and build my own SMS-enabled personal trainer bot I call twilio-fit.  Twilio-fit designs a workout on-demand that incorporates my personal …

    Read More
  • By Sam Agnew
    How to send WhatsApp Media Messages with Python PythonWhatsApp

    WhatsApp is a messaging service used by people all over the world. With Twilio's Messaging API you can programmatically send WhatsApp messages. Let's walk through how to use Python to send a media message over WhatsApp.

    Development Environment Setup

    Make sure we have the right software installed and set up that we'll need to use for the rest of this post. Throughout this post, you will need:

    Here is a good guide to follow in general if you are going to be doing more with Twilio and Python.

    Sign up for Twilio and activate the Sandbox

    Before you can send a WhatsApp message, you'll need to sign up for a Twilio account or sign into your existing account and activate the Twilio Sandbox for WhatsApp …

    Read More
  • By Kelley Robinson
    Detect Robocalls with Twilio Lookup and the Nomorobo Spam Score Add-on bG2utclWVzVcVomibKtYGe99wJ0WvTItH9LDAeHYR5JP7XJ9EjaiFHv1608ZZ0FvkJRbXMHiP_y13RhJczikwUygbOuZ8jld-ag8FNLEqAIx-4g1ArTDbPLqTYvFXroUaH1y9l42

    Twilio's CEO Jeff Lawson recently wrote about the history of robocalls and what we're doing to eliminate them. Until that happens, we can build a tool that will help us identify a robocall with a bit of Python, the Twilio Lookup API, and the Nomorobo Spam Score Add-on.

    Set Up

    In order to code along with this post you'll want to start with the following:

    1. Create a Twilio account
    2. Install Python 3
    3. Install the twilio-python helper library

    Head to the Twilio Console and install the Nomorobo add-on. Look for the yellow logo and click through to "Install".

    Leave the name as nomorobo_spamscore and "Save" the Add-On.

    Create a new file called nomorobo.py and add the following code.

    # Download the helper library from https://www.twilio.com/docs/python/install
    from twilio.rest import Client
    # Your Account Sid and Auth Token from twilio.com/console
    # DANGER! This is insecure. See http://twil.io/secure
    account_sid = 'your_account_sid'
    auth_token = …
    Read More
  • By Elmer Thomas
    Selling 5,000+ Boxes of Girl Scout Cookies with a bit of Twilio Magic UNADJUSTEDNONRAW_thumb_57a7.jpg

    Selling Girl Scout cookies can be challenging, especially if the goal is to sell 5,000 boxes in 50 days! Why would one want to do such a thing? Well, first of all, selling Girl Scout cookies teaches girls life skills such as goal setting, decision making, money management, people skills, business ethics, and so much more. Secondly, the Girl Scouts of San Gorgonio council offers some amazing incentives. In addition to the many prizes like a robot, 3D printer, iPad, and a one week trip to Canada at 4,000 boxes sold (and much more). The prize for selling 5,000 boxes in 2019 is a two week trip to China and Japan, including an entire day at Shanghai Disney! Going to Japan has been a bucket list item for my ambitious daughter, Audrey, to travel to since preschool. So, game on!

    Out of 12,386 registered Girl Scouts in our region, …

    Read More
  • By Matt Makai
    How To Send a WhatsApp Message in 30 Seconds with Python uDU_MWBJHg-z8j5Jzymi03iLb6dQC_iUsBF1qtRxPfzyPxYB39odAdqU5zKAxA5SiR7JTRLQAT-z_EkdAhD6EJ83DgUJDZG2y2EtzuTrmEMejJnakbTR0Tctj-OvqID1iqXjC5wv

    WhatsApp is an over-the-top (OTT) messaging service widely used throughout the world. In this tutorial, we will learn how to quickly send WhatsApp messages through the Twilio Messaging API with reusable code that can be added to any Python application.

    Development Environment Setup

    We need the following dependencies installed on our local development environment to send WhatsApp messages.

    If you do not have Python already installed on your machine, go to the Python downloads page and install the latest version now.

    Next, log into your existing Twilio account or sign up for a new free Twilio account.

    After you log into the Twilio Console, take note of your Account SID and Auth Token. The Account SID is a unique identifier for your account while the Auth Token is …

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