Can I Wear Shorts?

Modern society is racing towards the promised heaven on earth: the ability to live like Iron Man without resorting to selling nuclear weaponry or shouldering the responsibility of fighting scary armoured space whales.

We at Solid State have proudly contributed to this race, and we have a new update.

Our Voice Skill for Alexa and Google Home “Can I wear Shorts“ is now live!

Yes, you too can now live with J.A.R.V.I.S-like abilities. All you have to do is download our Skill, and shout, “Alexa, ask can I wear shorts?” and the application will look at the weather forecast and tell you “yes” or “no”, followed by weather info and chance of precipitation.

If only Patrick had our app.

By removing the need to view the weather forecast ourself, we at Solid State estimate this voice skill saves our team around 4% of their working day, prevents 8% of heat stroke incidents in the office, and translates into £5 billion of productivity over the next 4 years when taken in conjunction with lottery predictions.

So in a bid to help the UK economy make similar gains in a post-Brexit economy, here’s how we did it.

(This man is well prepared for the weather.)

(But this man has many regrets.)

But first, one thing to know: there might be 15,000 voice skills on Alexa, but 69% boast only a couple of downloads, and the vast majority are apps for your home (light controls etc) or news flash briefings. People are getting very excited about a future “without typing”, but just because Caveman Bog managed to set a stick on fire, doesn’t mean he’s off to the Moon just yet.

We wanted to get involved at the stick-on-fire-stage and see what Voice can actually do right now. When we were searching for ideas, we knew wanted to make something useful but which Google Search can’t already do better, so we designed Can I Wear Shorts because it actually makes a decision for you - as opposed to merely searching for an answer or providing a poor alternative to activating an app tactily.

Plus, we live in London, we love wearing shorts, and we hate making decisions before coffee, so we decided to solve a big issue in our lives and make our Intelligent Assistants tell us whether we can wear shorts.

We crafted the app using API.AI to build the conversational interface for multiple services (Alexa and Google Actions). We hooked it up to ssg-node-cli - a one line command to generate our node express app / API.

To get the weather forecast we used… Weather Forecast - a simple weather forecast module used to get weather data for a specific location.

Then to get the app working for both Google and Amazon, we used actions-on-google to integrate the nodes of google actions, and alexa-app as the node wrapper for the Amazon Alexa SDK.

The good news is that the skill works, you can download it here for Alexa, and here for Google Home.

The bad news is that we encountered some hiccoughs along the way.

For example, Google Actions still don’t support spoken British English, most probably because of Donald Trump, so we had to change our phones to American English to access the skill. This means my phone thinks I should say hiccup.

Likewise, NLP (Natural Language Processing) still has a ways to go, this limits how many intents you can reasonably work with in voice. You won’t be discussing 20th century philosophy with Alexa quite yet.

But, what was most frustrating by farrrrrrrrrrrr was the app submission process for Amazon. It took ages, it hampered our efforts to iterate, so it’s a must to mitigate this. Now we know the quirks, we could cut our next app submission time by 90% - but my god it was annoying getting to that point. Salt to the wound was the dev tooling - Amazon offer a simulator but we couldn’t test scenarios such as requesting user info.

So, if you too want to join humanity’s quest to use artificial intelligence to recreate popular comic book heroes from the 1960s, here are a couple of top tips to do with voice skills:

Start with alexa-app framework.

Incorporate a skill such as Can I Wear Shorts into your own app. If you have an API written in Node JS and Express you can easily extend it to work with Alexa and Google Home. To begin with we wrote a REST API where you can get a can I wear shorts answer given a latitude/longitude or postcode from a webpack, extending this to incorporate alexa was as easy as :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
**return **alexa.getAddress(req)
.then(({ postalCode, countryCode }) => {
**if **(!postalCode || !countryCode) {
**return **response.say(NO_LOCATION_MESSAGE)
}
**return** canIWearShorts(postalCode)
.then(({description}) => {
**return **response.say(description);
});
});

In a simple project like this, use Slack for logging. We have set up Slack integration so as soon as Can I Wear Shorts gets executed, a bot sends a message to Slack, so we can see in real-time when people are using it. This saves us from having to look at console logs on an ad hoc basis, while also gathering data on requests. Everything is on the Slack channel. We even have reports every day at 8am. It’s my favorite Slack Channel.

p.s. here is the full list of tools we used:

  • API.AI - tool to build the conversational interface for multiple services (Alexa and Google Actions)
  • ssg-node-cli - a one line command to generate our node express app / API
  • Weather Forecast - a simple weather forecast module used to get weather data for a specific location
  • actions-on-google - node integration of google actions
  • alexa-app - node wrapper for the amazon alexa sdk