Mike MacDonagh's Blog

Somewhere in the overlap between software development, process improvement and psychology

Tag Archives: alexa

My Alexa skill is now live in the UK

Every month at my kung fu club, Chi Wai Kung Fu in Cheltenham UK, there’s a series of strikes of the month that are on rotation for extra attention. Also there’s a rotating black belt syllabus. It’s not the easiest thing in the world to remember all of these details, and whether or not you need to take a bo staff or set of escrima sticks to the club. So, I thought I’d write an Alexa skill to remind me 🙂

chiwai_alexa_out.png

If you’re into Alexa in the UK, then join my UK Facebook group, it’s got over 4,500 members:

echo_group_welcome

The basic skill is pretty simple, interrogating an array and returning the requested information. Getting it certified was a bit more fiddly because I wanted to use a single word invocation name “chiwai” which is against the rules normally, and because it’s a trademark infringement if it’s not official. Of course, in this case it was official as I developed it on behalf of the club. The Amazon skill dev support team were very helpful so now it’s live 🙂

Here’s a video of it in action:

To get it, if you’re in the UK, just say “Alexa, enable Chi Wai“.

You can also search for “ChiWai” in the Alexa app, or install direct from Amazon.co.uk.

You can then ask it questions like “what are the strikes of the month” or go a step further and say “what are the strikes of the month for October” or “what’s the black belt element in February”. Because of the way Alexa works, voice recognition on those second questions is greatly improved if you first start the skill by saying “Alexa, talk to Chi Wai” and then ask them. You can directly ask by saying “Alexa, ask Chi Wai for the …” but it’s not quite so accurate.

Also, try “Alexa, tell Chi Wai, Zoon Ching” 🙂

The code is on github here: https://github.com/macmike/chiwai-alexa-strikes

Advertisements

Chi Wai Kung Fu @ Cheltenham now with extra tech!

kung_fu_cats.pngFor over 6 years now I’ve been going to Chi Wai Kung Fu! A few years ago I achieved a lifelong ambition to become a Black Belt in Kung Fu. Now I’m a second Dan and a brown belt in Dacayana Eskrima as a bonus!

Chi Wai is great, my whole family go there 🙂
My two boys started when they were little and now are both black belts. It’s done them a huge amount of good, it’s far more than just self-defense (and that’s important by enough to justify it). They’ve learned respect, discipline, control, confidence and a positive attitude founded in the fact that they’ve worked hard at something to achieve their goals. me_sifu.jpgNot always achieving first time, but through persistence and hard work they’ve got there in the end! There’s a saying that a “Black belt is just a white belt that never gave up”, that’s something they’ve learned from Chi Wai.

My wife even does Kung Fu, and is heading towards her black belt this year. As a result I’m running out of wall space to hold all of our certificates. I’m also finding home practice sessions hurt a lot more!

The Chi Wai system mixes traditional kung fu with practical self-defence including weapons and group
attacks. Because the club has a full time dojo there’s lessons for separate age groups every day (except for Sunday, even ninjas need a rest).

It’s a great family run club with a genuine family atmosphere. It’s friendly and welcoming and manages to keep that positive environment consistently. A lot of that is down to the excellent instructors but it’s also down to the people and families that train there.

chiwai_family.jpgIt’s fantastic to have a family activity where we can all be at different levels, but all encourage each other and train together as the kids get older. As my eldest son’s gone from little kid to adult sized teenager he’s now fighting with the adults and enjoys putting me in arm locks in Black Belt lessons 🙂

If you’re in the Cheltenham, UK area then get yourself, your kids and your auntie to Chi Wai Kung Fu! You can even ask Amazon Alexa about it:

Or learn how to do the intro bow from my buddy the modelling guy:

 

 

How to remove duplicates in Amazon Music playlists

I’ve recently migrated to Amazon Music from Spotify and local media servers. It’s actually pretty good although getting my playlists migrated was a pain.

Uploading seemed to cause a lot of duplicates, so then creating playlists from the recently imported or added files caused a lot of duplicates in the playlists. I listen to playlists on shuffle so this annoyed me because it means the probability of duplicated tracks is higher and you miss out on the other files. I found a way around it though!

  1. Create your playlists however you want.
  2. On Windows, install the local Amazon Music app.
  3. In the Amazon Music Windows App you can select all of the files in a playlist, right click and add to a new playlist
  4. The app will popup and tell you how many duplicates there are and ask if you’d like them to be filtered out.
  5. Delete the original playlist
  6. Rename the new playlist.
  7. Rejoice in a lack of duplicates.

For Spotify playlists I used STAMP from FreeYourMusic – ok but expensive.

It managed most of the files on my wife’s spotify playlists fine, and produced a file of songs it couldn’t match. Some made sense because they were misnamed, or not part of Amazon Music so needed manual uploading from our local collection. However, across several thousand tracks it failed to match about 60 it should have.

Also, the CSV to Amazon Music doesn’t appear to work in STAMP on Android. STAMP support upgraded me to a multi-platform license and it worked on windows. Still, it saved me hours despite being over-priced and not perfect.

Send messages to another room using Amazon #Alexa #dirtyhack

Here’s a fun trick to get Amazon Alexa to send messages to the kids in another room or whatever…
This is a bit of a hacky workaround but it’ll do the job until Alexa can do push notifications.
1) Record some custom mp3s (or go to http://www.readthewords.com and generate some)
2) Save them with good names and upload them to Amazon Music in a “Messages” playlist, I recommend calling them “MSG_something”
3) From the Alexa app you can then choose a message to send to an Echo/Dot from the “Music and Books” area (the playlist and MSG_ prefix makes them easy to find)
For example, “Please come downstairs, dinner is ready”.
alexa_msg_screenshot
I use “z. msg” as a prefix so when my songs are sorted by names they’re all at the bottom. The msg_ bit is useful for searching by song to find them quickly 🙂

How to call a webservice api from Amazon Alexa using Javascript in a Lambda function

This wasn’t trivial and I’ve seen a lot of questions about it online so I thought I’d share how I did this to get Alexa to respond to questions about my kids pocket money 🙂

You can call a URL like this:
(note I’m assuming a JSON response, you’d need to modify for non-JSON)

var http = require('http');

function getWebRequest(url,doWebRequestCallBack) {
    http.get(url, function (res) {
        var webResponseString = '';
        //console.log('Status Code: ' + res.statusCode);

        if (res.statusCode != 200) {
            doWebRequestCallBack(new Error("Non 200 Response"));
        }

        res.on('data', function (data) {
            webResponseString += data;
        });

        res.on('end', function () {
            //console.log('Got some data: '+ webResponseString);            
            var webResponseObject = JSON.parse(webResponseString);            
            if (webResponseObject.error) {
                //console.log("Web error: " + webResponseObject.error.message);
                doWebRequestCallBack(new Error(webResponseObject.error.message));
            } else {
                //console.log("web success");
                doWebRequestCallBack(null, webResponseObject);
            }
        });
    }).on('error', function (e) {
        //console.log("Communications error: " + e.message);
        doWebRequestCallBack(new Error(e.message));
    });
}

You can then use it like this from inside an intent handler:

function getPocketMoney(intent, session, callback) {

    let shouldEndSession = false;
    let repromptText = null;
    let speechOutput = '';
    let cardTitle = '';

    let url = "http://mypocketmoneyservice/getpocketmoney?person=mike";

    getWebRequest(url, function webResonseCallback(err, data) {
        if (err) {
            speechOutput = "Sorry I couldn't connect to the server: " + err;
        } else {
            //something like this
            const balance = data.pocketmoney.person.balance;
            speechOutput = `${person} has £${balance} pocket money.`;            
            callback({}, buildSpeechletResponse(cardTitle, speechOutput, repromptText, shouldEndSession));                   
        }
    });
}

Amazon Alexa – what it needs to do next

I’m a big fan of Amazon Alexa. I bought a dot to experiment with and it’s so useful I have it in several rooms now. Alexa can control my smart lighting (courtesy of lightwaverf kit), play music, order food, order some amazon stuff, manage my shopping and to-do lists amongst other things, but she’s got a few drawbacks.

Here’s what I’d like to see Alexa tackle next:

  1. Conversation flow – the ability to add contextual follow up questions, without every command being “Alexa, do a thing…” It sounds trivial but when you’re having entire conversations with Alexa it’s a bit weird to have to use the wake word for every sentence.
  2. Multiple commands in one e.g. “Alexa, turn on the kitchen lights and start playing the cooking playlist” rather than “Alexa, turn on the kitchen lights” and “Alexa, start playing the cooking playlist”
  3. Unstructured search – Alexa’s great at facts but Amazon have decided not to make her opinionated.  She’s great at “what is a hoover?” and “what is 12 miles in kilometres?”.
    1. She can answer: “Who played harry potter in harry potter and the philosopher’s stone?”
    2. But can’t do things like “who played Harry Potter in the movies”. In contrast google can answer that question with a quick snippet about the cast. I read a blog that said they didn’t want to make a decision for users about simply returning the first search hit rather than making an informed choice – but if I’m making a voice search that’s exactly what I want. If I want to get a range of views and select my search result I’ll use a text interface. Returning “cards” with links to Bing isn’t good enough – just read me the top hit from <insert search engine here>
  4. Intercom – I want to be able to send a voice message from one Alexa device to another to create an intercom system in my house (e.g. “Alexa, send a message to the living room telling the kids to turn the TV volume down”)
  5. Delayed reminders – Alexa’s good at setting alarms but I want her to remind me with a message not just beeping (e.g. “Alexa, at 6pm remind me it’s time to order a taxi”). At the moment, that sentence will result in “Time to order a taxi” on the to do list. Or I can set an alarm for 6pm which beeps. I want a voice message at a specific time.
  6. Alarms – play music not just beeps. (e.g. “Alexa, wake me up at 7am with my Spotify Wake Up playlist”)
  7. Local DLNA integration. Alexa’s great at streaming music from the internet but doesn’t currently see home DLNA music as a streaming source. Which is odd, I can see how to program a skill to do discovery (similar to the current smart home discovery, or just built into that) and the rest is the same. Amazon, if you read this I’ll do it for you at a reasonable price.
  8. Chromecast e.g. Alexa, play Netflix: Game of Thrones”
  9. Order a Dominos. Yep, I know it can do this in the US so why not in the UK? Dominos allow ordering via chatbot in Facebook Messenger so this is easy to do from a coding point of view. Dominos, if you’re listening…
  10. IFTTT integration. C’mon Amazon, IFTTT say they’re waiting for you do to something. This unlocks millions of possibilities.
  11. Add things to my Amazon Wish List e.g. “Alexa, add a Raspberry Pi to my Amazon wish list” only adds it to my (local) shopping list.
  12. Remove things from todo or shopping lists by voice. Also, email me my lists.
  13. Custom volume schedules. In the morning I want Alexa to be nice and quiet, in the evening I want her volume to be a lot higher. Perhaps what I really need is her to automatically adjust her volume based on the ambient noise. After all she’s listening all the time anyway.
  14. Proactive notification. I realise it would be annoying if any skill could push notifications to my Alexa (I don’t want random ads being spoken in my house) but I’d like to be able to whitelist some apps so I can get alerts at certain times of day from specific apps (e.g. order status on ordered food, package tracking, breaking news, birthday reminders).
  15. I want a big Echo with a screen for my kitchen too.

I realise many of these are about integrating outside of the Amazon ecosystem which is perhaps why they’ve been reluctant to do so. But with Google Home, an MS and Apple assistants turning up soon the winner is likely to be the most useful all round. At the moment that’s Alexa, but by being more open to integrations it’ll be hard to beat.

What do you want Alexa to be able to do?

%d bloggers like this: