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
  • 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 Sam Agnew
    How to Send a WhatsApp Message with JavaScript and Node.js WhatsAppNode

    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 JavaScript to send a message over WhatsApp.

    Development Environment Setup

    Let's start by making 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 Node.js and have any more questions.

    Sign up for Twilio and activate the Sandbox

    Before you can send a WhatsApp message from your web language, you'll need to sign up for a Twilio account or sign into …

    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 Sam Agnew
    Working with JSON in Swift Swift 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 choices. This is the syntax that the JavaScript language uses to denote objects.

    For this post, we are going to use the following modified JSON data from NASA's Astronomy Picture of the Day API to cover some basic examples of scenarios where you'd need to parse JSON. You will need to be running Swift 4.0 or greater. The following JSON is the example that we are going to be working with:

    {
        "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 the Orionids Meteor Shower. Pictured here, over two dozen meteors were caught in successively added exposures last October over Wulan Hada …
    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 …
    Read More
  • By Sam Agnew
    Improving your pun game with Python, Rhymebrain and the Twilio API for WhatsApp Guitarmony

    Puns are awesome and one easy way to come up with puns is to combine two different words. This is called a portmanteau. Let’s build a WhatsApp bot that gives you portmanteaus for certain words that you message it, so you can come up with better puns on the fly!

    We’ll be using the Rhymebrain API for the portmanteaus and the Twilio API for WhatsApp to program our WhatsApp bot.

    Setting up

    To get started make sure you have:

    Like with Twilio Programmable SMS we’ll need a webhook that will respond to incoming HTTP requests with every message …

    Read More
  • By Sam Agnew
    Sending text messages from your iOS app in Swift using MFMessageComposeViewController Screen Shot 2018-07-17 at 6.45.06 PM

    Do you ever want to send text messages in your iOS app from your user’s phone number? While you can’t do this directly without your user’s consent, you can display a pre-composed message for your user to send using MFMessageComposeViewController.

    If you want to programmatically send an SMS from a different phone number, you can do this with Swift using Twilio.

    That’s cool. Let’s send a message!

    If you already have an app and want to get straight to the point, here’s the code you need to display the message composition interface:

    let composeVC = MFMessageComposeViewController()
    composeVC.messageComposeDelegate = self
    
    // Configure the fields of the interface.
    composeVC.recipients = ["13142026521"]
    composeVC.body = "I love Swift!"
    
    // Present the view controller modally.
    if MFMessageComposeViewController.canSendText() {
        self.present(composeVC, animated: true, completion: nil …
    Read More
  • By Sam Agnew
    Handling Incoming Phone Calls with Server Side Swift, Vapor and Twilio Screen Shot 2018-06-01 at 11.37.46 AM

    You’re building a Vapor app and want to be able to handle phone calls? Let’s walk through how to add Twilio Programmable Voice to the barebones Vapor “Hello World” app.

    Swift Package Manager

    For this project we’re going to use Swift Package Manager to set everything up and install dependencies. Make sure you have Swift 4.0 or greater installed before moving on. You can check your Swift version by running the following in your terminal:

    swift --version
    

    Vapor has a convenient command line tool which can be used to generate templates for projects. Installing this will also take care of other necessary dependencies.

    You can install it using Homebrew with the following command:

    brew tap vapor/homebrew-tap
    brew install vapor
    

    Now initiate a new Swift project with the following terminal command in the directory where you want your code to live:

    swift package init --type …
    Read More
  • By Sam Agnew
    How to receive/download picture messages in Node.js with Twilio MMS Screen Shot 2018-05-30 at 2.57.40 PM

    Have you ever needed to programmatically download an image from an MMS message sent to your Twilio number? Well here’s all the code you need to do this using Node.js and Express:

    const fs = require('fs');
    const express = require('express');
    const bodyParser = require('body-parser');
    const request = require('request');
    const MessagingResponse = require('twilio').twiml.MessagingResponse;
    
    const app = express();
    
    app.use(bodyParser.urlencoded({ extended: false } ));
    
    app.post('/sms', (req, res) => {
      const twiml = new MessagingResponse();
    
      if(req.body.NumMedia !== '0') {
        const filename = `${req.body.MessageSid}.png`;
        const url = req.body.MediaUrl0;
    
        // Download the image.
        request(url). …
    Read More
  • By Sam Agnew
    Receiving and Responding to Text Messages with Server Side Swift, Vapor and Twilio Screen Shot 2018-05-29 at 7.05.00 PM

    You’re building a Vapor app and want to be able to respond to SMS messages? Let’s walk through how to add Twilio SMS to the barebones Vapor “Hello World” app.

    Swift Package Manager

    For this project we’re going to use Swift Package Manager to set everything up and install dependencies. Make sure you have Swift 4.0 or greater installed before moving on. You can check your Swift version by running the following in your terminal:

    swift --version
    

    Vapor has a convenient command line tool which can be used to generate templates for projects. Installing this will also take care of other necessary dependencies.

    You can install it using Homebrew with the following command:

    brew tap vapor/homebrew-tap
    brew install vapor
    

    Now initiate a new Swift project with the following terminal command in the directory where you want your code to live:

    swift package init --type …
    Read More
  • Newer
    Older
    Sign up and start building
    Not ready yet? Talk to an expert.