How to put the message payload into the tts service in node red?


I’m trying to use the tts service in node red. I want to add the msg.payload as the “message”, but seem to get it wrong in the json code. Right now, I have this:

{  "message":"{{payload.message}}" }

This seems to work, but the speaker doesn’t really say anything when I put an inject node in front of it.


Did you in the above example route the text you want the message to say into “msg.payload.message”?
Can you maybe share the flow? Makes it easier to debug.

If it looks similar to this:image
then give this a try:

{  "message":"{{message}}" }
1 Like

Ow. I didn’t know that was needed. I think I know how it’s done, by searching for the solution for this problem. I’ll try it out as soon as I find the time. Thanks in advance

Hi again,

I tried this, but it didn’t work, here is the flow.

[{"id":"7d7e0d30.f496e4","type":"api-call-service","z":"c1a307c9.6c0d98","name":"","server":"6ab5feac.b916d","version":1,"debugenabled":false,"service_domain":"tts","service":"google_translate_say","entityId":"media_player.kitchen_speaker","data":"{\"message\":\"{{payload.message}}\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":940,"y":220,"wires":[[]]},{"id":"19466f10.db6891","type":"inject","z":"c1a307c9.6c0d98","name":"","props":[{"p":"payload"},{"p":"message","v":"testing","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"test ","payloadType":"str","x":730,"y":220,"wires":[["7d7e0d30.f496e4"]]},{"id":"6ab5feac.b916d","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

thats maybe because in your flow its still the same as before. You are querying for this:

{  "message":"{{payload.message}}" }

instead of:

{  "message":"{{message}}" }

Here is the howto for mustache templates:

Important is the first sentence:

When using templates the top level is a property of the message object: msg.payload would be {{payload}}

1 Like

That’s it. Thanks