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 Ubani Balogun
    Introducing Twilio's SOCless: Automated Security Runbooks Decorative header image "Introducing Twilio's SOCless: Automated Security Runbooks"

    How can an organization’s security team defend its customers against threats at scale?

    When the Twilio Security Operations team (SecOps) was founded, this challenge weighed heavily on our minds. We knew that automating all our threat investigation and response procedures would be key to safeguarding our customers, but we had no clue where to begin. We also knew that many of our peers were in the same boat.

    That’s why today, we’re proud to open-source SOCless: a serverless framework to help organizations easily automate their security workflows and respond to threats quickly and at scale.

    To get started with SOCless, visit the documentation at https://twilio-labs.github.io/socless/

    Building automated security runbooks

    When performing investigations and responding to threats, security professionals follow well-documented, pre-planned, step by step procedures. We call these procedures runbooks.

    A typical runbook may require a security professional to use multiple security products, custom scripts, and decision trees to …

    Read More
  • By Sam Agnew
    Generating Nintendo Music Over the Phone in Python with Magenta and Twilio Copy of Generic Blog Header 1-3.png

    Artificial creativity is amazing, and I am always blown away by what people accomplish with neural networks. Lots of developers have used Python libraries like Magenta to create awesome music.

    I used Magenta to train a neural network on a bunch of classic Nintendo music, and I thought it would be fun to hack around with that and make a Twilio phone number you can call to hear computer-generated NES music. If you're in the US, try calling ‭(424) 398-8637‬ (424-39-TUNES) to hear!

    Let's walk through how to build a phone number that plays computer generated music using Magenta.

    Installing dependencies

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

    Run the following command to install Magenta in your …

    Read More
  • By Sam Agnew
    Training a Neural Network on MIDI data with Magenta and Python Copy of Generic Blog Header 3-5.png

    Since I started learning how to code, one thing that has always fascinated me was the concept of computers creating music. With Magenta, a Python library built that makes it easier to process music and image data, this can be done more easily than before. Magenta has pre-trained example models you can use to generate music, as seen in a previous blog post, but it's a lot more fun to create your own.

    Let's walk through how to use Magenta to train a neural network on a set of music data from classic Nintendo games to generate new Nintendo-sounding tunes.

    Super Mario Bros 2 GIF

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

    Run the following command to install Magenta in your …

    Read More
  • 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
  • Newer
    Sign up and start building
    Not ready yet? Talk to an expert.