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 Matthew Gilliard
    Transcribing Phone Calls using Twilio Media Streams with Java, WebSockets and Spring Boot Transcribing Phone Calls using Twilio Media Streams with Java,  WebSockets and Spring Boot

    Websockets are a web technology used to create long-lived bidirectional connections between a client and web server over the internet. With Twilio Media Streams you can stream real time audio from a phone call to your web application using WebSockets.

    This blog post will show how to create a WebSocket server in Java using Spring Boot which will receive real time audio from a phone call, and forward the audio data to Google’s Speech-to-Text to provide a live transcription of the voices on the call.


    In order to follow along, you will need to have:

    If you just want to skip to the end, you can check out the completed project on GitHub.

    Getting Started

    The fastest way to create a new project with Spring Boot is to use the Spring Initializr. Leave Project, …

    Read More
  • By Matthew Gilliard
    How to Send Email in Java using Twilio SendGrid How to Send Email in Java using Twilio SendGrid

    If you’re writing a Java app and you need to programmatically send some emails, the Twilio SendGrid API is just the thing you need.

    You’ll need to sign up for a free Twilio SendGrid account and create an API key. Then you can get started with a few lines of code.

    In this post I’ll go through each step to get you up and emailing in no time.

    Starting Out

    You’ll need:

    The first thing you should do is to create a SendGrid account. The free tier will work just fine for this tutorial. Once you are signed up and logged in, create an API key. You can choose any name you like, but make sure to save the key before moving on.

    A screenshot of the "Create API Key" dialog on the SendGrid  console, showing 3 options, of which I have selected "Full Access" and called my key "my-api-key"

    Choose “Create & View” …

    Read More
  • By Matthew Gilliard
    Wake up to Useful Daily Messages with Java and Azure Functions Wake up to Useful Daily Messages with Java and Azure Functions

    I wake up slowly. I often need a few minutes to remember where I am and what day it is. I usually have my phone handy - it’s my alarm clock, too. But then I decide to check the weather, and before I know it I’ve got carried away on Twitter, Reddit, email and so on. It takes me ages to start getting ready for the day. I decided to build a small app which would send me an SMS every morning. I can see what the day has in store without getting involved in anything online.

    I decided to use Azure Functions with a TimerTrigger to run some Java code every morning. The code pulls data from wttr.in and affirmations.dev, formats it into a dense (read: emoji-laden) message and sends it to me:

    An SMS in my messaging app: Good morning (weather: rain showers, temp +10 Celsius), Today is Monday, October 7. Remember you are a capable human being. Have a great day (rainbows and sparkles)

    In this post I’ll walk you through how to create this and customise it …

    Read More
  • By Matthew Gilliard
    Working with HTML on the Web Using Java and jsoup Working with HTML on the Web Using Java and jsoup

    So, you need to parse HTML in your Java application. Perhaps you are extracting data from a website that doesn’t have an API, or allowing users to put arbitrary HTML into your app and you need to check that they haven’t tried to do anything nasty?

    Have you tried using regular expressions?  It won’t end well. The author of that now-infamous text managed to recover from their distress enough to suggest using an XML parser (before, presumably, collapsing into the void). The problem with this is that an awful lot of the HTML in the world is not valid XML. People open tags without closing them, they nest tags wrongly, and generally commit all kinds of XML faux pas. Some non-XML constructs are perfectly valid HTML and admirably, browsers just cope with it.

    To adopt the flexible and stylish attitude of web browsers, you really need a dedicated …

    Read More
  • By Matthew Gilliard
    Using Twilio Functions with ClojureScript Blog post header: Using Twilio Functions with ClojureScript

    Twilio offers several APIs for programmable communication which rely on webhooks. Twilio Functions is a serverless runtime which can handle these webhooks by running your code on Twilio’s platform to generate customized responses to phone calls, text or WhatsApp messages, emails and more - without having to manage a server yourself. Functions supports JavaScript, and therefore any of the compile-to-js languages can be used too, such as TypeScript.

    Here I’ll show how you can use Shadow CLJS, the Twilio CLI and Serverless Toolkit to create a Twilio Function in ClojureScript. If you want to jump straight to the final code, you can find the project on GitHub.



    Project Setup

    Create a new Shadow CLJS project using npx which is …

    Read More
  • By Matthew Gilliard
    Getting Started with JavaFX Getting Started with JavaFX

    JavaFX is a Java toolkit for making GUI applications which run on Windows, MacOS or Linux and mobile. It is the successor to the old Swing and the older AWT toolkits.

    Since the release of Java 11 in 2018 JavaFX has been part of the OpenJDK project, so it is open-source and is developed by many people from many different companies. If you are interested in creating a desktop application today then I would recommend starting with JavaFX and not using Swing or AWT, but it can be hard to know how to get started.

    This post will walk you through creating a JavaFX desktop application from scratch - the application will use JavaFX’s controls module to draw a label with some text, then we’ll move on to creating an interactive app that can send SMS messages.

    What do I need in order to make a JavaFX Application?

    Read More
  • By Matthew Gilliard
    Be a Magician by Calculating Powers of Two in Your Head Be a Magician by Calculating Powers of Two in Your Head

    As a programmer you might have to deal with questions like these:

    What's bigger, 243 or 7 trillion?


    How many items can we store if our database uses a 32-bit identifier?

    Gif of someone doing complex math

    Calculations involving powers of two come up often in programming, and it's completely possible to work these out in your head faster than opening your calculator app, using this one (weird?) trick.


    There are three things to remember:

    • First, 2(a+b) = 2a × 2b
    • Second, 210 is 1024, which is really close to 1000.
    • Third, you need to know the powers of 2 up to 210

    Powers of 2 from 1 to 9: 2, 4, 8, 16, 32, 64, 128, 256, 512

    These facts are the basis for the rule:

    Add three zeros for each ten in the power, then multiply by whatever is left.

    Read More
  • By Matthew Gilliard
    Detecting Robocalls in Java with Twilio Lookup and Nomorobo Detecting Robocalls in Java with Twilio Lookup and Nomorobo

    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 in Java that will help us identify an unwanted call using the Twilio Lookup API with the Nomorobo Spam Score Add-on.

    Set Up

    In order to create this project you’ll need

    Add the Nomorobo Add-on to your Twilio Account

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

    Nomorobo Add-on logo

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

    Setting Up your Java Project

    Create a new Maven project with the java8-quicks …

    Read More
  • By Matthew Gilliard
    How Twilio’s Programmable Voice Saved My Vacation How Twilio's Programmable Voice Saved My Vacation

    After booking some train journeys with Deutsche Bahn (the German rail network) for my summer vacation this year, I found I needed to call their reservations desk to change something important about my tickets. Unfortunately the number they provide is a specially-priced Premium Rate number in Germany, and international calls to these are blocked from my phone. Twilio’s Programmable Voice products are perfect for solving this kind of problem. Read on to find out how I did it and how you could do the same.

    Step 1: Getting A Local Number

    The first thing to do is to get a number which you can call. Twilio’s phone numbers console allows us to buy phone numbers in over a hundred countries so once you have signed up for an account click the “+” button to buy a new number that’s local to you:

    Step 2: Forwarding Incoming Calls

    After buying a …

    Read More
  • By Matthew Gilliard
    Getting Started with the Java Streams API Blog Header: Getting Started with the Java Streams API by Matthew Gilliard, Developer Evangelist

    The Streams API was added in 2014 with the release of Java 8 so you’ve almost certainly got it available today. It is used to pass a series of objects through a chain of operations, so we can program in a more functional style than plain iteration allows. Still, when working with collections many developers still reach for the classic for loop.

    In this post, I’ll introduce the terms used when talking about Streams, show some examples of each term and how they can be used together to create compact and descriptive code. Then I’ll show a real-world example of Streams code I wrote recently to pick winners in a raffle.

    What’s a Stream?

    A Stream is a (possibly never-ending) series of Objects. A Stream starts from a Source. The objects in a Stream flow through Intermediate Operations, each of which results in another stream, and are gathered …

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