Category Archives: Amazon

More Alexa Marvels

Some of you may recall that in the dim and distant past, Aidan and I wrote a SKILL for Amazon’s Alexa – which let us do anything by simply passing the speech back to Node-Red… and we could sent text as speech to Alexa. Well, that relied on SSL port access and writing skills and… we’re still waiting for something easier and so without effort, that arbitrary response is still  a little way off, but..

If you want REAL EASY  - read on. (updated 13/10/2017)

Continue reading More Alexa Marvels


Amazon and the UK

I thought you might like to see a communication with Amazon and my responses.. I am pretty annoyed as it is not the first time an American company has launch stuff around the world – keen to get sales going but not so keen to provide international customers with the tools they need.

So - I’ve spent some time working on the Amazon Echo product and had some issues along the way. Here’s one reason – I wonder if American companies are even remotely aware of how ANNOYING this is? And all of it would have been so easy to avoid just by better communications.

Amazon: Thank you for contacting us. I understand that you have a couple questions. First that you're being referred to the Alexa skills store to find a particular Alexa skill, but it cannot be found. Additionally, you're having some trouble testing your own flash briefing skill. I can certainly help look into both of these issues today.

1. AnyMote Skill

It sounds like the skill you may be referring to is "AnyMote Smart Remote" made by AB Mobile. If that's the case, then yes it is currently only available in the US Alexa skills store, which would explain why you may be unable to find it if you're located in the UK, and thus signed into the UK Alexa skills store.

Peter: Thank you for this - in the meantime I've heard from Anymote - they claim they put in the Skill for the UK Amazon ages ago and were less than excited by the time it Is taking Amazon to process this - you might want to investigate - when something exciting is launched the LAST thing you presumably want to do is cheese off developers adding value to your product!

Amazon:  2. Flash Briefing Skill

Similarly, flash briefing skills are only available in the "English (U.S.)" language, which as far as Alexa is concerned, is a separate language from "English (U.K.)". In order for a skill be accessible on a given device, that device must be in the same language as the skill, and available in the country you're physically located in.

In this case then, your own flash briefing skill is inaccessible on your Echo device because the Echo device in question is signed into the English UK marketplace, and using the English UK language, whereas the flash briefing skill is in English US, which is currently the only available option for flash briefing skills.

Peter: So why are you doing this? Deliberately (so it would appear) disadvantaging British users and developers? In both cases what you seem to be saying is - had we been American we'd be fine. WHY don't you have a British Flash briefing skill? The link you have provided explains what you've told me - thank you - but it does not explain why we are being disadvantaged in the UK?

And if I cannot develop and test a Skill because it won't work in the UK, why on EARTH does Amazon let me go through the WHOLE process of putting the skill into the forms on Amazon UK when you know fine well it won't work?

I really would appreciate some feedback here - I write a blog and am recommending people to use Echo - having developed a general skill here which does work but which causes issues because of Amazon's absolute insistence on using port 443 for SSL ...

Should I be telling British followers to wait for the Google unit because Amazon are not interested in the UK at this time?

Amazon: For more information on international skill distribution and availability, please see the help article below:


Alexa Enlightenment

Last updated November 16, 2016: In a recent blog entry I told you how we’d been playing with Amazon Echo (Alexa) and got it working. Well, nearly. It turns out that what SEEMS obvious in the system is not all it seems - but read on as we've had success.

What is Alexa?

Actually the device is called an Amazon Echo – or for the cheap version and Amazon Dot. It is a box requiring power and WIFI that you can talk to and which will control things. It can automatically discover certain (and often expensive) commercial devices, it can play music, it can answer questions, set diary appointments, make shopping lists – all by voice. And with a little effort can talk to Node-Red to open up a whole new world of DIY possibilities.

Listening for specific words

For example in the Amazon setup pages, you can define variables that will only accept a certain amount of options – so for example – you might say “Alexa, tell computer to turn kitchen lights on” where “lights” could be, say, light, lights or heater.

And that’s fine – but you can’t TRUST that. the word “flights” works equally well and Amazon makes it clear in their documentation that you must do your own tests – any similar valid word in the dictionary could have been accepted (which seems utter madness to me but there you go). Indeed when we tested this – we found all sorts of irregularities – there is no way to say “accept ONLY these words”. And, if you say something that is not at all acceptable, the system will wait to time out – and that takes several seconds – which would annoy the hell out of the spouse. So – if you’re going to have to do your own checks anyway, we reasoned you may as well just try to get the basic words out of the units into Node-Red and “do your own thing”. To be clear then, the Amazon unit is no-where near perfect at word recognition and you have to consider that when designing a solution. I wonder if Google will be better.

Wemo Emulator

A slight diversion here: If ALL you want to do is turn things on and off with Alexa and Node-Red – you COULD just ignore the rest of this article and go grab node-red-contrib-wemo-emulator or read other posts here describing my modifications to FAUXMO.


No – REALLY – drop it in – give it a name – like Orange – and define topics and payloads (which might go off to, say, MQTT or may be used to trigger direct port control on a Raspberry Pi or similar) for each of the two commands ON and OFF. Tell your Alexa to go looking for devices – it will find orange – and THAT IS IT – no HTTPS, no NOTHING. It really doesn’t get any easier.  But only ON and OFF which is a bit restrictive - and for heaven's sake don't use the word "shed".

How about controlling your TV. Well, the Anymote Smart controller for Android will talk to Alexa and then hence control stuff by infra-red  – except I can’t get it to talk to Alexa. I’ve written off to the guys at Anymote and will report back. But that takes care of all sorts of Infra-Red stuff as long as you leave your phone on!  Not ideal really.

The Bigger Picture

And now – back to the bigger picture!

Before Alexa, all Aidan and I wanted was something that would listen to requests and then fire speech out so we could handle it ourselves in Node-Red – and that is exactly what we have now achieved. Some will shrink in horror at this having already done it another way – but it looks to us like a great general way forward provided you’re happy with writing your own simple,  high level code to handle a sentence like “kitchen lights on” which could be as simple as a string comparison.


What we’ve done here – is to simple make Alexa collect up to 15 words (arbitrary number) after “ask computer to” – where “computer” is whatever word you want to be (the “skill”) and put them in an array, that function above, called “Alexa” does all of this and strips out words like “eh” “and”, “please” etc. – and you can add more exclusions.  If you forget to actually say anything – the second output of the Alexa function handles it all for you automatically.

So in USER FUNCTION – you get an array – msg.word – with up to 15 lower case words – with the rubbish stripped out. You also get msg.combined, a simple string with everything in one string. If your requirements are simple – the latter might be the way to go.

If you merely want to have Alexa repeat the salient points of what you said so that “Alexa tell the computer to turn the lights on” – the output will be “you said: lights on”

msg.payload = "You said. " + msg.combined;
return msg;

Alexa tell the computer to turn the lights on”

So above, Alexa reads the words in purple and passes on the rest. The simple Node-Red Alexa function strips out the words in red – and passes on the remainder in both an array of words and a simple string.

So clearly you might want that USER function to have outputs for MQTT and EMAIL and whatever other stuff to control your kit – that, of course, is easy and up to you. If you have 2 outputs from the function (set the number of outputs at the bottom) you can write to both at once – or separately by returning an array of messages -  or just one and a null etc. When you send a null – nothing goes out.

Now – I don’t want to go TOO heavily into this because simply string comparisons is probably not the way to go for any kind of sizeable setup… but here is something I’ve used as a test and it absolutely works a treat.


The code in the user function (note the extra output) is trivial to say the least.

var msg2 = {};
switch (msg.combined)
    case "office lights on" : 
            msg.payload="The office lights are now active";
    case "office lights off" : 
            msg.payload="The office lights are now off";
    case "thank you" : msg.payload="No problem, to be sure."; break;
    default : msg.payload="You said: " + msg.combined;break;
return [msg,null];

In the example above, I have the function react to “Alexa tell the computer to turn office lights on” by sending an ON command via MQTT to one of my ESP8266 boards. Off has a similar effect, different parameter. The final command it just a bit of fun.

Really – so to get all of this fun, you have to set up your SSL (which I found incredibly painful but in retrospect it was dead easy – another of life’s hurdles out of the way) so that Amazon’s servers can talk to a secure connection (your Raspberry Pi or whatever you are using – FriendlyArm Neo or similar would be just as good running Debian), you need to update some stuff into Amazon’s site – and from there on you never touch the Amazon site again –which is of course the point really -  you only have to concern yourself with your USER FUNCTION in the cosy and quick-to-alter Node-Red environment. What you do with that is up to you.  In my case I’ll add another output to go to MQTT and whatever comes in is processed and maybe does something – any message in msg.payload (you HAVE to send something back) is spoken by Alexa when you’re done. It really doesn’t get a lot easier.

In a really trivial case you might, with TWO outputs,  (the first should be used to return a message;


if (msg.combined==”lights on”)
msg.payload=”Ok, light is on”; node.send([msg,null]);
msg.topic=”kitchen/toesp”; msg.payload=”{out0:1}”; node.send([null,msg]);

Ok, I know, create another object and send them both out at once – I’m trying to keep this simple.

But of course, in reality, you’ll be likely to do FAR more than this and hence having the separate words in an array is useful.

So - on Amazon - you need an intent!

  "intents": [
          {"name": "wa", "type": "LITERAL"},
          {"name": "wb", "type": "LITERAL"},
          {"name": "wc", "type": "LITERAL"},
          {"name": "wd", "type": "LITERAL"},
          {"name": "we", "type": "LITERAL"},
          {"name": "wf", "type": "LITERAL"},
          {"name": "wg", "type": "LITERAL"},
          {"name": "wh", "type": "LITERAL"},
          {"name": "wi", "type": "LITERAL"},
          {"name": "wj", "type": "LITERAL"},
          {"name": "wk", "type": "LITERAL"},
          {"name": "wl", "type": "LITERAL"},
          {"name": "wm", "type": "LITERAL"},
          {"name": "wn", "type": "LITERAL"},
          {"name": "wo", "type": "LITERAL"}

and a "sample utterance"


All we’re doing here is telling Amazon, for the “intent” “computer” – to collect up words and fire them off. And that's it for the Amazon end apart from the usual details they need about you and the https address of your website (the node-red exposed point).

As for Node-Red itself - the example above:

We have an http node which has nothing more than POST and “/echo” as the URL - then our ALEXA function contains the following - it may well be far from perfect but for now it works.

var doStuff = {payload: msg.payload.length};

switch (msg.payload.request.type)
    case "IntentRequest":
    if (   === "inputIntent")
        var word = [];
        word[0] = msg.payload.request.intent.slots.wa.value;
        word[1] = msg.payload.request.intent.slots.wb.value;
        word[2] = msg.payload.request.intent.slots.wc.value;
        word[3] = msg.payload.request.intent.slots.wd.value;
        word[4] = msg.payload.request.intent.slots.we.value;
        word[5] =;
        word[6] = msg.payload.request.intent.slots.wg.value;
        word[7] = msg.payload.request.intent.slots.wh.value;
        word[8] = msg.payload.request.intent.slots.wi.value;
        word[9] = msg.payload.request.intent.slots.wj.value;
        word[10] = msg.payload.request.intent.slots.wk.value;
        word[11] = msg.payload.request.intent.slots.wl.value;
        word[12] = msg.payload.request.intent.slots.wm.value;
        word[13] = msg.payload.request.intent.slots.wn.value;
        word[14] = msg.payload.request.intent.slots.wo.value;
        var thisone =0, processed = 0, total = word.length;
        for (;;)
            var nxt = "";
            switch (word[thisone])
                case "cancel" :
                        msg.payload = "";
                        return [null, msg];
                case undefined:
                case "the":    
                case "to":
                case "thanks":
                case "thank":
                case "and":
                case "turn":
                case "a":
                case "please":
                case "you":
                case "er":
                case "erm":
            if (++processed >= total)
        msg.topic = "";
        msg.payload = "OK";
        doStuff.word = word;
        msg.word = word;
        for (a = 0; a < word.length; a++)
            msg.combined += word[a] + " ";    
    return [msg, null];

    case "LaunchRequest":
    msg.payload = "You need help";
    return [null, msg];
    case "SessionEndedRequest":
    msg.payload = "Session Ended";
    return [null, msg];
    msg.payload = "Unrecognised Intent";
    return [null, msg];

Note I've added a check for the word "cancel" which simply returns nothing, immediately. This is a vital addition as sometimes you just talk gibberish and want to get out of it!

The format response function looks like this…


The other blocks don’t have anything in them – other than the user function in which you can make use of msg.combined and msg.word.  When you are done be sure to send the message out – payload containing text of your choice – as Amazon does need a return value even if your text is blank.


Set up an Amazon account – get PRIME if you want their music – if you’re rich get a Spotify account as the Amazon music selection is naff.

Get HTTPS so the end point of your Node-Red page (no real page exists) in my case

That domain or subdomain needs to point to your building – and your router should redirect port 443 (ssl) traffic to port 1880 on your PI or whatever you are using. Why 443 - isn't that a pain for routers which have SSL management and VPN - yes it is - you have to move those to another port. WHY Amazon absolutely insist on port 443 for SSL I don't know - because any port will work but they won't accept them - please by all means do take it up with them.

If you have passwords set up on your Node-Red and your Node-Red UI (which I do) you’ll have to pass them in the  Amazon website string – and I recommend you do this as clearly you don’t want any old Tom, Dick or Harry logging into your Node-Red

Once they are set up is a matter of going to the Amazon developer site with your account – the Alexa tab, setting up s skill including letting it know about your URL – filling in the bits above – and soon thereafter your DOT or ECHO or whatever you are using should be sending text over to you – to do whatever you want with.

Clearly, this will develop – splitting text up into words like this is useless for email addresses – so “Alexa tell the computer to send an email to” is simply not going to work – and as for “Aidan” – it makes a complete mess of that Smile

For reference – we made up some notes from our efforts to get an SSL certificate – if you have proven, better ways that cost less and don’t involve re-signing on every now and then as some freebies do – and which you know Amazon will accept as genuine – by all means give us blow by blow info. If you have a better, more complete, simpler description – please do let us know.

From our notes on setting up SSL – https – which may or may not be useful…

You need a trusted certificate to work with Alexa if you want it to talk to your Node-Red setup. Aidan has emailed the Amazon developer guys and eventually got a reply to say they had an issue with self-generated certificates, now resolved - sadly my router setup appears ot have an issue with them and so I can't test this (the router setup in Spain simply WILL not pass through port 443 to an internal unit).

With Node-Red typically you would have separate username and password for external access - this can be re-used with https: and the https: url can bypass the username and password requirement which means you can continue to use UI (dashboard externally).

Obtain SSL from – in our case,

So, the procedure is to pay your money and then use openssl to generate a certificate request (.csr) file.

openssl req -out -new -newkey rsa:2048 -nodes -keyout

Enter all the details that are asked for, but when it comes to the ‘Common Name (e.g.server FQDN or YOUR name)’ bit, you must put in the domain name of your server (without the ‘www’ as you get that anyway), so enter ‘’ into the ‘common name’ section and you will be verified for and

Before you start the above process, make sure that you can access your Pi (or whatever) externally using your domain name to avoid unnecessary delays.

When you have your .csr, then edit it and cut and paste the full certificate request into the request box when it asks for a certificate request.

It will then generate a small text file for you to place in the www/html root of your Pi. Make sure that you can access it externally by cutting and pasting the file name into a web browser, such as (or whatever the file name is). When you enter that into a browser, you should see the contents of the file appear.

When you’re happy that works, then click continue on and it will verify your website and generate your certificate and bundle which you can then get by clicking ‘download’ to get a zip file.

Store this all safely (including the private key file  that you generated with the .csr file) – i.e. make a backup!

You can use a subdomain - so that if you use for something else you can have for Alexa and Node-Red (verified – I am using a “things” subdomain without issue while my basic root www address is going elsewhere).

Using advanced DNS or similar function with your provider, point to your site. In your router, take 443 and point to the 1880 port of your node-red Pi.

We checked and you definitely can’t use anything other than port 443.

Temporarily route port 80 (website in our case) to Pi - as you'll be asked to dump a file in the root folder for verification..... once complete this can be restored to whatever you were using it for in the first place.

Some files need to go into a folder i.e. /home/pi/ssl (our choice) and your info set up in node-red settings.js needs to know where they are...

Need to setup certificate in settings.js (https://... And uncomment ‘fs=’ …etc.

NOTE: I’ve just had to move the lot from one Pi to another – because I messed up the installation of the Pi and had no ports to play with. I can confirm – ALL that is needed is to move the certificate files (in any old directory) to the new Pi and make changes to the Node-Red settings file – uncommenting FS and adding two lines for the certificates - that’s it – all up and running – this is no-where near as complicated as I initially thought it would be.

Also, if your certificate isn’t from a root CA then you need to copy your base certificate into the certificate chain, mainly because node-red doesn’t give you any option to use a certificate bundle file. i.e. edit your .crt file, copy the contents and paste to the top of the ‘’ file -  this will add your certificate to the chain file.

Use SSL CHECKER  to check validity

Make sure that the certificate is verified all the way up to the issuing root Certificate Authority or Amazon will reject it

When all working - put your port 80 to where it was. After everything works - reboot your router to be sure.

And if I have not said it before – Amazon’s music library is SHITE!


Alexa Node Red and SSL

The DOTIt’s running. I’m very chuffed. Yesterday I picked up my Amazon Dot – which is basically the big ECHO unit without the big speaker – it has a little one instead.

What is Alexa?

Before I go any further – let me backtrack for those who’ve been in – well, a cave or something – what the hell is Alexa? Ok, you’ve seen SIRI and OK GOOGLE etc. and probably talked to one or the other. Well, this is better. A LOT better. This is the fore-runner of the companion you’ll be talking to when you get old!

So the Amazon Echo is a tall, round black box with a speaker that plugs into the wall, hooks into your WIFI and you talk to it and it talks back. The Dot is the same thing, third the price – without the big speaker. It has a small speaker and you can plug another speaker into it or hook to a Bluetooth speaker. For my money, the Dot is the best buy.

How much?

So far so good. But why would you spend £45 on that?

The ECHOThe Dot unit has a microphone “array” – all you need to know is that when it is blasting music – it can still hear you! If you happen to have an Amazon Prime account or a full Spotify account – you can say things like “Alexa, play some Pink Floyd”. Now that might not seem like much – but trust me – this is going to be a party trick for MONTHS. No you can’t play your own stuff – well, that’s probably  not strictly true – depends how clever you are.

Ok, so we have a talking, listening music centre? Is that it? HELL NO!!! Alexa can handle everything including  “what is the meaning of life”. But also – “Alexa – add beans to my shopping list” – and variations (you can get the list of on the somewhat lacklustre APP) – alarm clock, timer – the list goes on.

But where it gets really exciting and frustrating at the same time is when you realise you can attach it to NODE-RED and have it control your house – securely. Where’s the frustrating bit? The HTTPS: bit… it won’t work without it (don’t even DREAM of mentioning certain sites that only work in America or those who are still talking about deprecated code). Well, the good news is that today we tackled this and cracked it and we have this now working in Node-Red without any special libraries and when you see it you’ll immediately realise the fantastic potential – heating, lighting, security, kettle boiling and other important items – all within grasp. Take a Raspberry Pi and a speaker amp and a microphone array and a power supply and a case and spend £60+ or just buy the DOT at £45 !!! The alternatives simply are not worth it as far as I can see.

No – not easy at first – which is why Aidan and I plan to sit down to document the lot. In reality – it should be possible to reduce the whole procedure to half an hour and the cost to a few quid a year. Right now I have everything in front of me and it is merely down to some trivial coding to get my various heating systems, lighting systems and the rest on voice control. My next job after writing this preliminary blog – is to order another DOT.

But I can do this for free?

There are countless stories of alternatives out there. I'll just ignore any hardware solutions that don't use special microphones – and when I asked SEED about the apparent fact that their solution plus microphone board come to MORE than the Amazon product – I didn’t get as much as a reply. As for free SSL? Show me a free SSL that does not require constant renewal, that works with subdomains (, which has been proven to work with Amazon's system (please DO) and which doesn’t rely specifically on one machine like a Pi - until then - a REALLY cheap SSL seems a reasonable way forward and despite the sweat at the very thought of it, obtaining and using the certificates was actually quite easy.

Is code needed?

I've seen solutions requiring java and other languages - I wanted to do everything in Node-Red - i.e. generally visually - and this is what we have done. No compiling, no special requirements - just Node-Red and some nodes and functions. There is absolutely no requirement to be using a Raspberry Pi here.

We spent a lot of time yesterday getting to grips with terms like “intent” – I don’t know why people keep coming up with new terms… and initially we were looking at various “intents” but I’m half-convinced you only need one or two and the rest can be done in Node-Red.  I won’t go into the image below – it won’t look like this when we’re done – but if you ignore that “status report” you pretty much have the basics – I can turn a light on an off already via MQTT (but the actual mechanism is irrelevant – I just happy to use MQTT for everything – all my little ESP8266 boards run MQTT ultra-reliably.tmpE39A

So the basic idea is simple enough – in order not to confuse your home control with other stuff, you can hand control over to your stuff using what I would call a keyword… so  “Alexa – ask XXX” or “Alexa – tell XXX” – which seem to do the same thing…  where XXX is your chosen word or phrase. I’m going to call my controller “Charlie” because “controller” sounds too geeky and if you use “house” then when video Skyping your friends with the same keyword you’ll chance to mess up their heating Smile

So (and you can add irrelevant words like please and thanks and to etc…. but I won’t) – I’m thinking – “Alexa ask Charlie location device action”  - for example “kitchen heating up”, “bathroom lights off”, “office heating status” etc…. others may do things a different way but that works for me with the minimum number of words.

When implemented – I’ll be back! But to be clear – this is working NOW, completely reliably and there is no chance the idea above is not going to work.  However today the BT man is coming over to fix our rotten broadband and I’m sure he’ll want to turn it on and off.

About the only down side up to now – is the ATROCIOUS Amazon music library which is as much use as an Ashtray on a motorbike. No AC/DC – WHAT!!!!?!?!?!?!?!? Clearly if not on a budget – Spotify must be worth the investment.

Alexa – play “I’m not in love”


Update Monday: We’ve spent the entire day on this – and that flow up there is out of the window – it turns out that all is not perfect in the standard way to handle Alexa – for example you would thing that by defining a range of words that are acceptable, no other words could creep in there – but in fact if you read the Amazon docs – they can. So for “light” you could end up with “flight” – so for all that range checking you STILL need to do your own checks.

We’ve taken a different approach. I’ll soon present some Node-Red code… that will do this. “Alexa tell the computer to turn the kitchen lights on” – the relevant bits of this are “turn the kitchen lights on” – and by the time you remove irrelevant words you are down to “kitchen lights on” – out block for Node-Red will do exactly that, return a cleaned up array of up to 15 words. What you do with them is entirely up to you. No chance of getting words wrong and have Alexa sit and time out. This is all working now – but it is also very late at night. The beauty of doing your own thing is that you can do things Alexa might balk at..

“Alexa tell the computer to turn the kitchen lights off and heating down”


So you end up with “kitchen lights off heating down”

Look through a series of acceptable locations, if none, bomb out otherwise look at a series of units – got it…. next parameter is what you want to do. Next parameter is location – but if not found – use the last one – then a device – then status.  In one instruction you might be able to control 3 or 4 items!

I can’t wait to get started – no matter what we add – more messing with the Amazon site!


A Quickie on Itead and CE

I recall a couple of questions in earlier blogs about Itead (Sonoff) and CE. Well, they’ve just written to me to confirm that “CE marking on Sonoff products does mean Conformity European, not China Export.” which should set some minds at ease – they also sent me the test reports.

I’m sitting on a Sonoff Dual, a Sonoff POW and a Sonoff TH16 here. Right now my Amazon DOT has turned up – I’ve just got it hooked into their music system and having great fun – next step is to figure out how to get a cheap SSL certificate running on the Pi so I can use the Node-Red-Contrib-Alexa – that will likely happen tomorrow – THEN I’ll get around to dismantling these Sonoff units and let you know a little more about them.