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
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
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 ...
When things go wrong in a running Java application, often the first sign you will have is lines printed to the screen that look like this:
Exception in thread "main" java.lang.RuntimeException: Something has gone wrong, aborting! at com.myproject.module.MyProject.badMethod(MyProject.java:22) at com.myproject.module.MyProject.oneMoreMethod(MyProject.java:18) at com.myproject.module.MyProject.anotherMethod(MyProject.java:14) at com.myproject.module.MyProject.someMethod(MyProject.java:10) at com.myproject.module.MyProject.main(MyProject.java:6)
This is a Stacktrace, and in this post I'll explain what they are, how they are made and how to read and understand them. If that looks painful to you then read on...
Anatomy of a Stacktrace
Twilio’s APIs enable communication in a whole host of ways: by phone, WhatsApp, Facebook, SMS and more. Usually when events such as incoming messages or calls happen Twilio will make an HTTP request to a server the user provides to discover what it should do - these are called webhooks. HTTP servers can be written with any technology to respond to these webhooks, and for Java developers the most popular framework is Spring Boot.
In this post we’ll create a Spring Boot app which can respond to incoming phone calls by playing callers a short message followed by the marvellous Rogers and Hammerstein song “It Might As Well Be Spring”.
Creating a Spring Boot App
AI services like Computer Vision (CV) are getting easier and easier to play with, and we can have some fun by making them available to use from our cellphones. In this post, we will use Java to connect the Twilio API for WhatsApp with Azure’s CV APIs to create a bot that can describe photos. It would be neat to use this for generating alt-text to help make your images more accessible online, for example.
We will need the following to get started with this post
- Java 8 or higher
- A Twilio Account
- An Azure account and Cognitive Services subscription key
Overview of our app
How it works
When Twilio receives a WhatsApp message it will send an HTTP request to a URL we provide.
Our mission is to create an app in Java which can handle those requests. The app will take the URL of any ...
When I was a young kid we used to take family holidays from the UK to France. I remember meeting other kids on holiday with their families for a week at a time, spending time playing with them and having loads of fun.
These other kids were from exotic-sounding places like Germany and France. Despite enjoying the same kinds of games and having loads of fun together we didn’t speak the same language and could never have a conversation. As children we had a lot in common but our lives and toys and everything were so different.
Since that time I always wanted to travel - to meet people and see what life is like in different places - how it is similar and how it is different.
Living and Working Abroad
I was very shy of public speaking when I was young. After two years of working as a programmer ...