Skip to content

Alexa TTS using Node-RED – How-To

Alexa TTS - How-To using Node-Red

If you want to tame your Alexa using graphical interface and TTS (text to speech) – this video is for you.

In this article I will show you how you can easily interact with the Alexa APIs. We will play a little bit with TTS & SSML. Don’t worry no coding skills are required.

If you don’t want to read then watch the video below!

SSML is a markup language that provides a standard way to mark up text for the generation of synthetic speech. The Alexa Skills Kit supports a subset of the tags defined in the SSML specification.

For example:
You may want a longer pause within the speech, or you may want a string of digits to be read as a standard telephone number or maybe you want to make Alexa to whisper like in the beginning of the video and so on so on.

Requirements:

The things that you need to complete this How-To are:

  1. Working Node-Red installation or Docker client
  2. Alexa device – Link
  3. Comment and share this article in your favourite social media (just kidding)

If you already have working Node-RED you can skip the “Steps with Docker” and go straight to “Steps in Node-RED” header.

Steps with Docker

After successful installation of the Docker client open a terminal/console/command prompt (whatever you like to name it).

To run Node-RED in Docker just type the following and don’t forget the -p 3456:3456 option, because it is very important for the Alexa API authentication:

docker run -it -p 1880:1880 -p 3456:3456 --name mynodered nodered/node-red

After successful execution of the above command you should have something similar in the console.

Successful start of Node-RED within Docker
Successful start of Node-RED within Docker

Now you can open the URL http://127.0.0.1:1880 (or whatever your IP and port is) in a browser. If you see the Node-RED dashboard you can continue happily ahead.

Steps in Node-RED

Open the “Manage palette” from the Node-RED menu in the upper right corner. In “Install” tab search for the following modules/plugins and install them:

  • node-red-dashboard – This module provides a set of nodes in Node-RED to quickly create a live data dashboard. If you wish to learn more, check the GitHub page of the project.
  • node-red-contrib-alexa-remote2 – which is node-red nodes for interacting with Alexa. Again If you wish to learn more, this is the GitHub page of the project.

Go to this page and copy one of the examples let’s say the 1. Alexa Speak Dashboard is a good for a start – link

Import the example using the Node-RED menu by pasting the copied text there and by click on the “import” button.

Import Menu in the Node-RED UI
Import Menu in the Node-RED UI

Double click on the nodes with the red triangle in their upper right corner

Alexa TTS example in Node-RED
Alexa TTS example in Node-RED

Click on the pencil button next to the “Add new alexa-remote-account…” label and…

Be careful here from this configuration more or less depends your success with enabling of the Alexa Text-To-Speach.

Adding new Alexa Account config node
Adding new Alexa Account config node

You want to double check the following things:

This IP field should be the IP where the Node-RED is installed. This maybe is the localhost or maybe it is different IP. If it’s different change it.

The Port should match the port in the Docker command. Remember the “-p 3456:3456” option. Most of the time you shouldn’t have to change this, so you can leave it like that.

File Path is the place where you should type something/anything, meaningful to you like “authFile”. The plugin will create a file with that name and inside the file, it will store your encrypted Amazon credentials. This is needed because otherwise it will ask you to re-login every time you re-deploy your Node-RED flow.

Service Host and Page

Then you want to change Service Host and Page depending of your location and the table below.

Have in mind that there are some cases when everything seems to be OK, there is no errors anywhere, but Alexa don’t want to speak at all. And the reason for this on all of the cases was the Service Host and Page.

Some nice guys from India manage to make this work by typing alexa.amazon.it and amazon.it as their Service Host and Page. And it worked for some reason. So if you face similar issue try change them one by one.

Service Host Page Language
USApitangui.amazon.comamazon.com en-US
UKalexa.amazon.co.ukamazon.co.uk en-UK
GERlayla.amazon.deamazon.de de-DE
ITAalexa.amazon.itamazon.it it-IT
AUSalexa.amazon.com.auamazon.com.au en-US

After you change the above things hit the “Deploy” button and if there is no errors, you should see something similar:

Successfully deployed flow asking to open a new URL
Successfully deployed flow asking to open a new URL

Open a new browser/tab and type the localhost:3456 or Whatever_your_IP_is:3456. Now you should see the amazon alexa sign-in page. And you should enter your Amazon credentials.

After you do that you will see a welcoming green ready under your Alexa nodes like this

green + ready = beautiful
green + ready = beautiful

Testing the Alexa TTS in the Node-RED dashboard

And the final and most fun part is to test our creation. Go to your Node-RED dashboard by either typing the http://localhost:1880/ui or by clicking the following buttons:

Open the Node-RED dashboard from the Node-RED menu
Open the Node-RED dashboard from the Node-RED menu

You should see something like this at the end.

Node-RED Alexa TTS dashboard
Node-RED Alexa TTS dashboard

Click on the blue refresh button and choose your Alexa device. In the text field below enter your text that you want Alexa to speak – like “Subscribe for the Kiril’s newsletter” and press the SPEAK button.

Question of the day

For what do you plan to use Alexa’s text to speech? Let me know your answers in the comments. Also let me know if you have any questions.

I’m really interested about what kind of clever ideas and routines you will create using TTS.

Support my work

Check my other post about Alexa, Node-Red & MQTT on this link

Furthermore feel free to add me on Twitter by search for this username – KPeyanski

I post there pretty much daily.

I really hope that you find this information useful and wish you good luck with your TTS enabled Alexa.

Thank you, stay safe and see you next time.

52 thoughts on “Alexa TTS using Node-RED – How-To”

    1. Hey Ravi, check the comments under the video from Achyuth Kassa. He had the same problem and now he found that if he change the configuration to “alexa.amazon.it amazon.it it-IT” everything works fine. Let me know what happened. Good luck.

  1. if we want to build speech to text then what we have to do can you help me out. so the requirement is like if we will say anything to alexa (echo dot 3rd generation) then it has to write it in plain text form. can you help me out with this.

  2. I have followed your tutorial and linked my Google login.
    However when I try to bring up the Dashboard I am challenged for a password.
    My Home Assistant and Node-Red are both running on the following IP 192.168.1.12
    When I click on the Dashboard the URL is 192.168.1.12:1880

    1. Send me some more info like screens of your configuration and the dashboard password dialog that is showing to understand this. You can use my Discord server.

  3. Great tutorial Kiril! I’ve managed to get it working!
    I’m no coder, but I am a magpie that can copy and change bits and learn from there – are you able to point me to any examples (or make a video…..) that would include how to have alexa read some MQTT data?

  4. Hello,

    I followed your youtube video und have a problem with the first example:

    In node-RED everthing looks fine. The credentials working and the green button “success” is below the node “GET ECHO DEVICE” and “Routine Speak”. I can choose my devices in the dashboard and can send some text (ic can see that, because the success button below “Routine Speak” say “sending” and went then back to success. But I can hear nothing and there is no error message in the debug window when I am sending text
    Do you konow what the problem could be?

    1. Hi Volkmar and welcome. It seems that this is a known problem 🙂 Check carefully the “Service Host and Page” section of the article. In general you have to change Service Host, Page and Language with the correct values for you. There is a table in the article there with all possible values. Try them all one by one, until you make it run. Good luck.

      1. Thanks a lot Kiril! The german settings for “Service Host and Page” was the right for me – now it works 🙂

        Thank you very much for sharing your knowledge!

  5. My Node-Red runs on the Raspberry with the iP 192.168.1.45
    But no matter which path I enter, cookies are not saved. What is your advice?

  6. Hey Kiril really amazing work, thanks a million!! i am trying now to implemented with my Fibaro HC2 to set up a complete alarm and notification center, i struggle a bit at the beginning because of the host and the page, since i am from Spain and my Alexa speaks spanish, for the Spanish community out there, I had to modify to Host: alexa.amazon.es and Page: amazon.es, important not to put the http:// otherwise it will not work.
    Now i have a question for you, will it be possible in any way to make alexa reproduce a mp3 tone? i would like to implement it with my door sensors and i want to make a sound everytime the door opens.
    Thanks a lot and once again impressive job!!

  7. Hi Kiril, I have a problem, when I set the Italy option, it says ready and when I send TTS from the dashboard it says success, but I can hear nothing.
    I tried to change the service host, the page and the language, but the only works is italian, I cannot change. Can you help me

  8. Is this authentication mode (proxy) safe? We need to provide Amazon username, password, and authentication token. Can my credentials be used by someone to access my account?

  9. Great tutorial!
    That’s what I am looking for. But I have a problem with the signin-process on amazon. Whenever I open the IP-address and enter my Amazon account info, it says that I have to use a valid e-mail address. But my address is valid – it works on my normal amazon page. Do you have any idea, what could be wrong? I am using the german site. Thank!

    Regards,
    Andreas

  10. Thank you for your tutorial
    I have a problem.I am using node-red in hassio.io.which was installed as a plugin, the port is auto setted 80:1880, the node-red page was accessed as a frame in home assistant, so I can not modify the port to 3456, Do you have any idee
    thanks

    1. If I understand correctly, you want to change the working port of Node-RED from 1880 to 3456 and that is NOT needed at all. Just open the IP where your Home Assistant and Node-RED is installed and add the 3456 port. http://YOUR_HOME_ASSISTANT_IP:3456 .I’m also using Node-RED as Home Assistant add-on and opening the 3456 is working without any issues. Good luck and let me know what happened.

  11. hey, kiril, this is a great tutorial. thank you. but honestly I followed your instruction w/o any success by the ip/1880/ui. there are no devices shown. when I double check my account in amazon, all of my devices were visible. any idea, why the devices is not shown in ui under device selection. I also hit the update/refresg button for the devices w/o any succes..
    thanks for your suppport in advance..

    stay safe

    1. Hi sezer, did you successfully open the address YOUR_DEVICE_IP:3456 and did you receive the following message “Amazon Alexa Cookie successfully retrieved. You can close the browser.” after you login with your amazon credentials?

      1. yes, i did and the message “Amazon Alexa Cookie successfully retrieved. You can close the browser.” was also visible to me after my login with my amazon credentials. when I open the address my device:1880/ui, I can see the site but device field is showing ” select option” if I hit the arrow, there is not any device listet at all. I have 4 echo’s in different floors and rooms to be honest
        i appreciate your supprt

          1. service host and page?? this were already been changed to GER layla.amazon.de amazon.de

  12. I keep having to resubmit my Amazon Alexa cookie. It requests it nearly once a day or so, making my Node Red flows useless. Am I doing something wrong? Sometimes I access Home Assistant through my local 192.x.x.x address, and other times through the nabucasa cloud address.

    Thanks for creating this!

    1. Try to type any value (filename) in File Path field inside the nodes where you configure the Alexa. This will store your encrypted Amazon credentials in that file.

  13. yes. but when I open ip/1880/ui. there are no devices shown.when I hit the arrow closed to the s”elect option” there is empty

  14. Seem’s like you’re pretty active here. Was able to get it working no problem. Is there a way to due this within a flow? So that is can be setup statically and trigger by something in HA?

    1. You can try the HA <-> NR integration. You can do a lot of things there for example a NR flow that check if sensor state in HA is changed say something using TTS

      1. Cheers! I have it working flawlessly. Really just using it to have it speak to me when I trigger something. Here is a quick NodeRed flow for checking if the auth is still valid.

        [{“id”:”6eef2382.683d4c”,”type”:”inject”,”z”:”38eef358.45bfcc”,”name”:”12 hours”,”props”:[{“p”:”payload”},{“p”:”topic”,”vt”:”str”}],”repeat”:”43200″,”crontab”:””,”once”:false,”onceDelay”:0.1,”topic”:””,”payload”:””,”payloadType”:”date”,”x”:180,”y”:2280,”wires”:[[“511bb67b.e39398″,”3c6886d7.092eba”]]},{“id”:”511bb67b.e39398″,”type”:”trigger”,”z”:”38eef358.45bfcc”,”name”:”5sec”,”op1″:””,”op2″:””,”op1type”:”nul”,”op2type”:”payl”,”duration”:”5″,”extend”:false,”overrideDelay”:false,”units”:”s”,”reset”:””,”bytopic”:”all”,”topic”:”topic”,”outputs”:1,”x”:370,”y”:2220,”wires”:[[“26ef416.aae52be”]]},{“id”:”3c6886d7.092eba”,”type”:”alexa-remote-other”,”z”:”38eef358.45bfcc”,”name”:”AuthCheck”,”account”:”6606bd1d.0eed84″,”config”:{“option”:”checkAuthentication”},”x”:350,”y”:2280,”wires”:[[“651d0ab.4324ff4”]]},{“id”:”26ef416.aae52be”,”type”:”api-call-service”,”z”:”38eef358.45bfcc”,”name”:”Notify P: Fix Auth”,”server”:”fe3c14cb.872068″,”version”:1,”debugenabled”:false,”service_domain”:”notify”,”service”:”mobile_app_patrick_iphone11″,”entityId”:””,”data”:”{\”message\”:\”Node-Red: Fix Alexa Cookie!\”,\”data\”:{\”push\”:{\”sound\”:\”warsaw.caf\”}}}”,”dataType”:”json”,”mergecontext”:””,”output_location”:””,”output_location_type”:”none”,”mustacheAltTags”:false,”x”:550,”y”:2220,”wires”:[[]]},{“id”:”651d0ab.4324ff4″,”type”:”change”,”z”:”38eef358.45bfcc”,”name”:””,”rules”:[{“t”:”set”,”p”:”reset”,”pt”:”msg”,”to”:”true”,”tot”:”bool”}],”action”:””,”property”:””,”from”:””,”to”:””,”reg”:false,”x”:540,”y”:2280,”wires”:[[“511bb67b.e39398”]]},{“id”:”6606bd1d.0eed84″,”type”:”alexa-remote-account”,”name”:””,”authMethod”:”proxy”,”proxyOwnIp”:”192.168.1.182″,”proxyPort”:”3456″,”cookieFile”:”authFile”,”refreshInterval”:””,”alexaServiceHost”:”pitangui.amazon.com”,”amazonPage”:”amazon.com”,”acceptLanguage”:”en-US”,”userAgent”:””,”useWsMqtt”:”on”,”autoInit”:”on”},{“id”:”fe3c14cb.872068″,”type”:”server”,”name”:”Home Assistant”,”legacy”:false,”addon”:true,”rejectUnauthorizedCerts”:true,”ha_boolean”:”y|yes|true|on|home|open”,”connectionDelay”:true,”cacheJson”:true}]

  15. I seem to be too dumb for this. Trysing since hour snow to trigger Alexa by voice to do something as simple as switching a device on.
    I get what you did here and all, but the trigger to uses Alexa with voice I don’t seem to grasp 🙁

  16. Hi great tutorial, I have been using this for about 6 months now and it is a really useful collection of nodes. the problem i have is that it stops working after a couple of days. My fix for this is to edit the alexa config node, change anything in there, i usually change the port from 3456 to somthing random. I then Deploy, and, obviosley it dosn’t work and comes up with an error msg. I then edit the config again (correct the Wrong port # ) re-deploy and it works again. It has always done this. Maybe it is when the DHCP Lease is renewed for alexa. I tried reserving the ip adresses for my alexa’s, but this makes alexa fall of the network completley, they only seem to work on DHCP. I guess amazon wants it to be able to jump around your network spying ??

    1. Thanks Chris for sharing your experience. Unfortunately you have to re-login again from time to time. I guess this is the price that we have to pay for not using official integrations, but I think at the end of the day it is worth the hassle.

  17. this is what I was looking for! THANKS! Do you know when the token need to be refreshed? Or, better, if Internet connection is required after the first initialising ? I see it send an input every day at 12:00 but I’m figuring out to use it also without any internet connectivity thanks again

    1. The token needs to refreshed from time to time, but I cannot find the pattern I don’t know about the Internet connection if you manage to find something interesting please share it here 🙂 Good luck and enjoy!

  18. Kiril, what a great stuff!
    Working as should. Just wondering how can I use that from command line ?
    To include it into some nice home automation scripts.

    Thanks

    1. Probably it’s possible, but I never done this before and I don’t know how can be done. Do you have other Node-RED flow that you can already control with scripts?

  19. No I don’t have any flow which I can control via script. Actually this is the first time I came close to node-red stuff. I am wondering what is the practical use of that. For me it would be some possibility to use it in my home automation scripts.

    1. Exactly, but the home automation can be done inside Node-RED with the flows, and these flows can be exported/imported, you can enable version control of the code and you can import multiple different palettes for almost anything. Feel free to check my other Node-RED articles/videos as well.

  20. Hi Kiril,
    great work!

    I already googelt for my question but did not find anything useful, so I hope you are the man!
    I have Alexa connected via the node red cloud to my node red on raspberrypi to control my Yamaha receiver. I can switch it on and off by telling Alexaswitch receiver on/off and by referencing to the msg.command´s

    msg.command == “TurnOn”
    msg.command == “TurnOff”

    But where is a list of all these other commands that I can use in the functions nodes?
    I want to tell Alexa switch it on “quiet” and set the volume to x db or say “alexa mute the receiver”, but what is the command from Alexa and instead of “TurnOn” as command I get “Mute” as command to process in Node Red?

    Thank you very much for your support,
    Björn

  21. Hi , i set up my node -red system as described and integrated a Shelly one button into alexa such that pressing the button ( acting as a doorbell ) announces that there is someone at the door . Works well apart from one problem . I have five alexa devices, four echo dots and an echo studio. I can make three announce , but one other and the echo studio refuse to work. They are all in the same house and in the same alexa account so I would expect they are all registered to the same service. I have tried other amazon server addresses but no joy . Is this a problem that some generations ( or models) of echo dot , echo studio will just not work with this ?

  22. Thanks! I use a “kegbot” system which tracks my beer keg volumes. I used this tutorial to take a webhook from kegbot, parse the username and beer name from the payload and send to Alexa to say “enjoy (beer name) (username)” 🙂

  23. Hi Kiril,
    Thank you for this tuto; I however face the problem that I am not able to access the credential page, it keep saying “impossible to connect” on my IP_ADDRESS:3456, any idea?
    Cheers from France

Leave a Reply

Your email address will not be published. Required fields are marked *