My grandma didn’t know what to wear anymore

March 15, 2018
Written by

s1f2u5nt1hu83asPxcpjrcwdVpCHBScbQOFHBhQ5O-Iv3BhOF8vA3AZX4ir46GwdAKMhaWPo28DMW0Swj8J4n3H8pMz_a7JUNwy-mhn-ps-phYbDJ8JmDx59veovYSg0bouMVRaY

Last time I visited my grandma, she was quite –rightfully– upset with the fact that one of the telephone services she’s been using for decades had been disabled without notice.

Her daily routine for the past few decades has been to dial a number provided by her phone company every morning and be greeted with that day’s weather forecast. Said service would give her just enough to know what to wear and whether to bring an umbrella or not so she could get on with her day.

The millennial inside me very quickly came up with the “I’ll just get her an Amazon Echo” solution, but the idea fell flat when I realised her house doesn’t have WiFi. Even if it did, I would be effectively volunteering for eternal family support on that device.

So I took a step back and decided to build her the experience she loved and trusted for many years.

Before we start

I want this to be as “maintenance free” as possible. I don’t want to think about servers, deployments or code maintenance, so we will build this using Twilio Studio. That way, everything is hosted by Twilio, and even if I need to make changes, all I need to do is log in to the Twilio Console.

When subscribed to OpenWeatherMap, head to the API Keys page and make a note of the key it generated for you.

Building the flow

Head to the Twilio Studio Dashboard and create a new flow. I called mine “Weather for Grandma” and chose Start from Scratch.

In that flow, add an HTTP Request widget and connect it to Incoming Call. We’re telling our flow to make an HTTP request every time a new call comes in to a number. We will configure that in just a minute.

Click on the HTTP Request widget, then change the Request Method to GET and the Request URL to the following, making sure you replace “YOUR-API-KEY” with the API key you took note earlier:

http://api.openweathermap.org/data/2.5/weather?q=London,uk&units=metric&appid=YOUR-API-KEY

I’ve used London, UK as the location for my weather forecast. Change that accordingly with the units you’d like to use and your grandma’s address. You can choose between various options such as zip codes or even geo-location. More information here.

In that widget, there will be two connectors, one for Success and one for Fail. If our API request is successful, we’re going to want to check that the results aren’t blank. Add a Split Based On… widget and connect it with Success.

Click on the new split widget. On the right pane choose Transitions and click New Transition. Choose the Is Not Blank option and hit Save. You will then see a tooltip saying “Value to test has not been set”. Click the link that says “Set value now” and under Variable to Test choose body.

Lastly, add a Say/Play widget and connect it to the Is Not Blank transition you’ve just created.

Because we know what the structure of the JSON returned by the OpenWeatherMap API is, we can just access its values directly. There’s a sample response here if you want to get more information.

Still, in the Say/Play widget add the following to the Text to Say field in the right pane:

Good day, the expectation for today is {{widgets.http_1.parsed.weather[0].description}} and the temperature is {{widgets.http_1.parsed.main.temp}} degrees.

The above not only configures the message we want our grandma to hear but reads variables from the API response which Twilio Studio has automatically parsed.
We’re done with this flow, and it should look like this now:

Configuring our phone number

Now that we have a flow, we will configure a phone number so when our grandma calls it the flow triggers. Head to the phone numbers page and get a new number or use an existing one.

Under Voice & Fax choose Studio Flow to be used when a call comes in and then choose the flow you just created from the list.

Save it and give it a ring. You should hear something like this:

https://www.twilio.com/blog/wp-content/uploads/2018/03/GrandmaCall.mp3

A happy grandma!

Nothing like getting to my grandma’s place and seeing that peace has been re-established and she can now focus on more important things – 🥘🥞🍕🍖🍨.

Best of all, we can always make some nice changes to our flow if we like. These could be things like changing locations for when grandma is away, giving her a personal greeting on her birthday or even adding this same functionality to be triggered via SMS.

How will you make your grandma or loved one happy today? I would love for you to share your ideas with me via @marcos_placona or by leaving a comment below.