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 Phil Nash
    Set up a React app with a Node.js server proxy s2-0wBJwglXgY-J1SEQqjxzePIRwX0hewng9LVRP7tyf2KFKfLXJRdvtiSuexoeEpp-h3dsoH7cqqIwNghRfCZdd6ACB9x8FN8K9LwTA-cjdqmYXsGpEkaj_0D_4T3Z-uwEp6eU

    Create React App is a great tool for getting a React application up and running. It's a little less clear when you're building or prototyping an application that requires a server side component, like generating access tokens for Twilio Video or Chat, though. I've found it easiest to work with a server within the same project so that you can start everything up with one command.

    By the end of this post you will learn how to set up an Express server that runs alongside a React app. If you can't wait then you can jump straight into the starter project on GitHub.

    How it works

    There is an option that you can set in Create React App's package.json that proxies non text/html requests through to an alternative back end. You can use this feature to proxy to applications running elsewhere, but today we want to be …

    Read More
  • By Phil Nash
    Audio visualisation with the Web Audio API and React lI7CV0Ljd8jXb6wL-YJevh0h0D2eItC8P9mJtHZ_JgdSzFeR6OqMFcDobpxl73BqKUe-ilMj0BlJumcg8MzNOA11FcSCkR8B-Bx8wRdySdx_3W-UCRUtuLX-nr2jKKG_MrQpbjY

    The Web Audio API is a powerful browser API for creating, manipulating and analysing audio. I'm no musician, so I'll leave the creating and manipulating to the experts. Instead, in this post we're going look at analysing audio. To make things extra interesting, we're going to see how to visualise the audio in a React component with <canvas>.

    When we're done we'll have a React application that can listen to the microphone on your computer and show a waveform to visualise the data.

    Getting started

    We'll need Node.js to run the application, so make sure you have it installed. I've started the application for us, so follow these instructions to get it running:

    1. Clone or download the repo from GitHub
    git clone -b getting-started https://github.com/philnash/react-web-audio.git
    
    1. Change into the directory and install the dependencies with npm
    cd react-web-audio
    npm install
    
    1. Start the application
    npm start
    
    1. Visit localhost:3000 to see the …
    Read More
  • By Phil Nash
    Build a collaborative playlist over WhatsApp with Rails, Twilio, and Spotify ugrWaR5LljMMUPyVEqxuZ926T4rpyZUj4vpt0ObjwSQEo7kWscZbctRvJpNMbTakGAQLg7WF9gitzaELHYRhI9eFxJRHJjd6HRg6kkyBLkqTcrzU9qbx9M4L1Amr6iKSmS_5Dds

    Sharing music over playlists is a great way to discover new and old music. Spotify has collaborative playlists, but I don't like how they let your friends re-order and delete songs from the list. We can fix this by building our own collaborative playlist that only allows additions using the Spotify Web API. With the Twilio API for WhatsApp we can let our friends send in a song whenever they are struck by inspiration.

    In this post we are going to build a WhatsApp bot that can do all of the above using Ruby on Rails.

    Getting started

    To build this application we will need a few things:

    Read More
  • By Phil Nash
    👉 Emoji translations with the 📞 Twilio API for 💬 WhatsApp and Node.js twilio-loves-whatsapp

    I 💖 emojis, so when I heard about the new Twilio API for WhatsApp I wanted to build something emojiriffic. Inspired by Monica Dinculescu’s to_emoji Twitter bot and emoji translator I decided to build a WhatsApp text-to-emoji translator. You can try it out now by sending your message to our WhatsApp number +441745472072.

    An example of sending a message to the app we're going to build. The WhatsApp number responds with the message translated to emoji.

    Here’s how you too can build this app.

    🛠 Tools

    I decided to build this project using Node.js, following in the footsteps of Monica’s projects. WhatsApp messages via Twilio result in webhooks, much the same as receiving an SMS message to a Twilio number, so if you’ve built a Twilio SMS application before this will be familiar. For ease of deploying this, I’m going to build this as a Twilio Function.

    If you want to follow along with building the emoji translator you’ll need:

    Read More
  • By Phil Nash
    Switching cameras during a video chat with Twilio Video switch2

    We’ve looked at how to choose cameras in JavaScript using the mediaDevices API, particularly for the case of mobile devices with a front and back camera, and now it’s time to put that into practice in an application. In this post we will use what we learned to build a camera switcher into a video chat application using Twilio Video.

    Getting started

    We’re going to build this off a slightly modified version of the Twilio Video quickstart application. In order to build this app you will need:

    Clone the repo for this application, …

    Read More
  • By Phil Nash
    Screen capture in Microsoft Edge dhaghi8gCz4DR7oDsoL03H6jOPy25zPmMkdmCmPc7njb01BXjnTaz7hk9ygcwXbaqs__WUfZB7ZZvLhBdjcUjkEaO4IZcvuaeCrXmXPtK5Lr7LvjKB-b9Wq3-XlYOUT5cQ9xtI0

    We’ve looked before at how to capture a user’s screen in Chrome and Firefox. Good news, another browser has support now, Microsoft’s Edge.

    Let’s see how we can capture the screen with Edge.

    The result of the code in this post. When you visit the project in Edge, you can capture the screen and show it in a video on the page.

    What you need

    • The latest version of Edge, which is currently version 42 with EdgeHTML version 17 (if you’re on a Mac like me, you can get a free virtual machine with Windows 10 and Edge installed to test on)
    • A text editor
    • A local web server – I like to use serve for things like this
    • Either ngrok or an equivalent tunnelling service or TLS certificates set up for localhost (we’ll see why later)

    Screen Capture

    Whereas Chrome required an extension to be built and Firefox used getUserMedia with a mediaSource constraint of "screen" to get a handle on the stream of the screen, once again Edge uses a different method. While this doesn’t …

    Read More
  • By Phil Nash
    Choosing cameras in JavaScript with the mediaDevices API

    Most smart phones come with a front and back camera, when you’re building a video application for mobile you may want to choose or switch between them.

    If you’re building a chat app you probably want the front camera, but if you’re building a camera app then you’re more interested in the rear camera. In this post we’re going to see how to choose or switch between cameras using the mediaDevices API and media constraints.

    What you’ll need

    To follow along with this post you’ll need:

    • An iOS or Android device with two cameras to test with, if you have two webcams this will work on your laptop too
    • ngrok so you can easily access the project from your mobile device (and because I think ngrok is awesome)
    • The code from this GitHub repo to get you started

    To get the code, clone the project and checkout the starter …

    Read More
  • By Phil Nash
    Better passwords in Ruby applications with the Pwned Passwords API

    Here at Twilio we’re fans of using a second factor to protect user accounts, but that doesn’t mean we’ve forgotten the first factor. Encouraging users to pick strong passwords is still the first line of defence for their accounts.

    After spending years collecting lists of passwords from publicly available data breaches at HaveIBeenPwned, Troy Hunt has made available an API to check whether a password has been used before. This post will show you how to encourage your users to use stronger passwords by checking against the pwned passwords API.

    The Pwned Passwords API

    In 2017 NIST (National Institute of Standards and Technology) as part of their digital identity guidelines recommended that user passwords are checked against existing public breaches of data. The idea is that if a password has appeared in a data breach before then it is deemed compromised and should not be …

    Read More
  • By Phil Nash
    How to detect if a Chrome extension is installed

    In other posts we have investigated how to capture screen output in Chrome and built a screen sharing video chat application. There was one feature missing though. The Chrome extension made screen capture possible, but didn’t test whether it  had been installed before the application tried to use it. In this post we are going to build a Chrome extension that can be detected from the front end.

    Getting set up

    We’re going to use the extension we built for screen capture and add the functionality to make it detectable. We’ll then build an example to show handling the two cases, with and without the extension.

    Download the source for the extension from the GitHub repo or by cloning the building-extension-detection branch

    git clone -b building-extension-detection https://github.com/philnash/screen-capture.git
    cd screen-capture
    

    The extension

    Open extension/extension.js and take a look at line 1. …

    Read More
  • By Phil Nash
    Add screen sharing to your Twilio Video application

    In recent posts we’ve seen how to capture a user’s screen in Chrome and Firefox. Now it’s time to combine this with a real video chat application and share screens as part of a video chat.

    What we’re building

    In this post we’ll take the Twilio Video quickstart application and add screen sharing to it. When we are done your application will let you make calls between browsers and share screens from one to the other.

    Successfully sharing a screen from one video chat to another and then back again using Firefox and Chrome

    What you’ll need

    To build this application you will need a few things:

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