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!


45 thoughts on “Alexa Node Red and SSL

  1. Hi

    Thanks for all the node-red posts. I recently came across a simple way to talk to node-red over SSL and it’s called dataplicity. It only works on a raspberrypi, but once installed, you have access to your pi terminal as well as give node-red SSL endpoints you can reach from anywhere, including Alexa.

    Hope someone finds the info useful.

    1. Thanks for that – on a PC I use WinSCP – and can talk to my Pi and other boards by an FTP style interface or Kitty terminal.

  2. Hi. I have all of this working now and love it. Thanks. Just ahead of buying some Philips Hue gear to go with Alexa, does anyone know if ha-bridge or one of the hue bridge emulators will work with the Philips motion sensor as well as the bulbs? If I can save money not buying the bridge (plenty of Pi’s I can use instead) then that would be good. Ultimately I’d like the motion sensor to communicate via Node Red which does everything else for me via multiple sensors, Sonoffs, Nest etc. Cheers, Don

  3. Hi all, just a small thing on the SSL.
    If you have a webserver which is already running SSL, then I use the below .php to bounce Amazon through to my (non-ssl, internal) node-red. I named it ‘echo.php’, and placed it on the existing server, then told Amazon the URL, and off we went.
    It could easily be improved to parse ‘$body’ and reject stuff which is not tagged up with your Amazon account….

    $url = “”;
    $body = file_get_contents(‘php://input’);
    $ch = curl_init($url);

    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $response = curl_exec($ch);

    if (!isset($response))
    return null;
    echo $response;

    And one more thing, ‘LITERAL’ seems to be depreciated in the Alexa SDK, but you can create a ‘custom slot type’ which basically does the same thing. The slot types seem to be there to ‘hint’ to amazon what to expect in terms of words, but amazon will still give you words even if they are not listed.


  4. Hi. Thanks to your blog I’m up and running with Alexa and node red. She’s doing all sorts of on/off task for me BUT I cannot for the life of me work out how to pass a value back to Alexa to read out via the “Format Response” node. Can someone please help me with the syntax? Pete, you mention your “Status Report” function above. Is that what I’m looking for? Thanks, Don

    1. Just put it into the msg.payload and pass that to a template node and put this in it..

      “version”: “1.0”,
      “response”: {
      “outputSpeech”: {
      “type”: “PlainText”,
      “text”: “{{payload}}”
      “shouldEndSession”: true

      Then passed that to a JSON node (with nothing in it) and out to the HTTP response.

  5. i’ve been making a new skill for alexa and have been trying to add https to my node red installation tonight and make an SSL certificate without success grrr. Has anyone seen a walkthtough for numpties yet? Cheers, Don

  6. Hi there, It looks to me like you are trying to access your server from the local lan, you will need to give the address of your router and port forward your ports onto the raspberry pi. I hope that helps and i havnt confused you even more lol

  7. Trying to get Amazon dot to talk to node red. Followed the blog and notes on setting up ssl. I bought a new domain name to go along with the others I have owned for ages, and never done anything with! Anyway got a new one ( and followed the notes on getting a certificate, after a lot of too and fro’ in with help lines. As kept saying they couldn’t see my pi. Yet every time I typed in my browser There was pete’s “Type on Screen (template)” running on my pi. I also could also see text file that was in the www/html root. So I thought all was well and my pi was accessible from the internet. Never thought to go to a neighbours and check it from there. (no phone signal where I live). I had gone to the control panel of my domain provider (names co) and edited DNS Administration changing the www and the blank ‘A’ records to (my Rpi’s ip). It was at this point I thought I was flying as when I typed my domain name into a browser up came the pi. I should of known it couldn’t be that simple. So I still can’t access pi externally! Spent the whole day reading and googling and am now even more confused. The people from ssls told me it’s something to do with 192.168.x.x being class C ip. I have tried putting my isp ip in there, but thought, it isn’t static, so even if it did work, it wouldn’t be for long. I do have in my inbox the zip file for the certificate!, didn’t want to do anything with it, until I could get external access to pi. Is there a simple walk through on how to get node red accessible externally?

  8. Hello Peter.

    I just wanted to point out that you can upload your own music to Amazon music and the Echo will play it.

      1. try and see… for example, google music analyzes local files, and if it has remote files already, it just copies them in your archive, without actual upload… and that’s even better, because if you have low bitrate mp3, you get 320kbps when online 😀

    1. I’m pretty sure the answer to your question Mike is YES – I’m certainly not pushing those people who we found by accident other than it’s only costing £9 fo 3 years…more than happy to hear of Amazon success stories with other providers.

  9. Hi Peter, you work and experiment is just great… Pity a big portion of potential users (like me) are cut out from all this technology just because Amazon has no (clear) plans to onboard other languages than English 🙁
    This is why I like Ivona (but there I miss a good hardware) and I would like to order ReSpeaker to experiment myself as it claims to support more languages than Echo/Alexa does

    1. Hi Giovanni

      I understand Alexa also handles German but yes it is a shame they don’t do other languages.

      I’m disappointed with Seeed. Their microphone array when added to ReSpeaker costs more than the Dot complete. I asked about this and have not even had a reply.

      I had high hopes for Google – as their speech recognition is great – but then they changed the terms of the licence – which is why I went looking for and found Ivona for speech playback which I still use and which is excellent.

  10. Looking forward to find out how to get SSL up and running. I’ve tried a few times and failed.

    Really want more than just ON OFF via the HABRIDGE I have at present.

  11. Wow! This really takes things to a new level. I’m really impressed with this Pete. It’ll be a while before I’m up to this level of functionality but I’m really enjoying the blog and experimenting with ESP8266s and your code. Thanks!

  12. about the “house” command, i remember the pranks about people naming themselves as “xbox turn off”, then going in front of other people that eventually said “xbox turn off go away”, and then their xbox, well… turned off 😀

  13. Peter, as mentioned in a previous article – I have Alexa talking to my home system (using SSL proxy) based on node-red. I have it reading out statuses of sensors (“Alexa, ask the heating/water/house for a status”) – as well as actions (“Alexa, tell the house that I am going to bed” – it replies ” I will turn the lights (Phillips Hue) out in 5 Minutes”.

    Look also for the wemo-emulator node for node red…

    1. its using a lets encrypt certificate… Also you can use a free (30 day) account on IBM Bluemix which has ssl enabled foc

      1. Not really into free accounts that then turn commercial… that’s why I went for the cheap commercial SSL – no surprises – just £9 every 3 years… but happy to look at free options without catches that are “trusted”.

  14. Problem is – Amazon won’t accept the freebies – without sending them some file or other – which then doesn’t work. For £3 a year it isn’t worth spending time on. Now if anyone has DONE this and it WORKS with Echo and they’ve documented it I will be more than happy to be proven wrong!

  15. I have been using ha-bridge to bridge Alexa to node-red. Good thing is you don’t need ssl as it pretends to be a hue.

    Its been in use now for 6 months and has been flawless. I was thinking of rewriting it in node as its currently in Java.

    1. Hi Stephen – did that at first – but pretending to be a hue light does not work for a wide range of devices… “turn heating up” “give heating status” etc?? I wanted full control – and that seems to be what we have – though still in the middle of the learning curve of how to use various built-ins. The code for this will all be visual – in Node-Red… for simplicity. But thanks for the link – different folk will have different requirements.

      1. No problem, at the moment my node-red pi exposes some rest endpoints that the ha Bridge forwards request too. Admittedly I only have milights and a nest hooked up so simpler use case I guess.

    1. And therefore no good right now for the majority of people 🙂 I spend a lot of time with Google and eventually they withdrew free access to the API – won’t make that mistake again. And there is more to this – the Amazon system for all it’s flaws (excessive focus on Amazon) works – the solutions with “oh, get a Pi, stick a microphone on” – miss the point – microphones are generally useless. I can blast rock music and this DOT device still hears me clearly. If you want the wife or girlfriend to take this seriously – it has to look great, operate flawlessly and preferably not have wires. For now, I think this is the way to go.

      1. anyway, DOT is available only for shipment to UK addresses, so nothing i can do about it… i know it’s english only, that can be ok… i don’t know if, even if i find a way to order it from UK, can be used in other states without VPN or such… anybody has info about this?
        and, are there in UK services the allow local delivery and then send them elswhere, like the many existing in USA?

        1. Not sue about where to PURCHASE but you can USE them anywhere. My friend Aidan introduced me to his Echo unit in a hotel in the back end of no-where in Spain!

  16. Hi Pete,

    Looking forward to it.

    I’ve been using LetsEncrypt for free SSL on PI. I use it for Nodered and Smokeping.

    It’s easy to configure and only needs to be rerun every 90 days.



Comments are closed.