Personalize Telegram message with entity_id name


I'm using Home Assistant in conjunction with NodeRed. I have the following automation in place that sends a Telegram alert every time opens a blind (I have 4 blinds in the living room). The

The problem is don't know how to personalize the generic message I have right now ("Opening living room blinds") by including the name of the blind ("Opening living room blind 1/2/3/4").


How can I pass the name (entity_id) of the blind to the Telegram node and include it in the message?

Thanks a lot.

The way I do it is to use a function or change node to change the payload, adding the data you want to the text string to be sent. You can also use simplistic HTML or Markdown as well but you can only do simple things like bold and italics.

Here are some example messages from one of my bots:

The bold titles are actually part of the payload.

1 Like

Thanks, that function node seems like the way to go. Would you mind sharing some code examples for that node?

I'll see what I can do, it is a collection of nodes and I make the telegram part a common target node by using lots of link nodes. But I'll see what I can extract.

The problem I have is that all the information (I get this with a debug node) that I can see in the output of "Living room blind 1 - OPEN" is the following, but friendly name is not listed there:


payload: object

domain: "cover"

service: "open_cover"

data: object

entity_id: "switch.sonoff_ch4_1"

_msgid: "f910e57.eb50718"

I tried getting the friendly name at the output of this node with "data.attributes.friendly_name" but is not working.

In the debug node you should be able to click on a small arrow to “open” the ones that say object to see the nested value.

(see the page on working with messages in the documentation)

That was exactly mi issue, that info was not included in the output (even if I open/display the whole output).

I solved it with:

And this the content of the function node:

msg.payload = {}
var my_friendly_name =;
msg.payload.chatId = MY_ID
msg.payload.type = "message"
msg.payload.content = "Opening: " + my_friendly_name
return msg;

Note that I needed to use the "Telegram Sender" node. As the one I was using (Notify) was not capable of injecting a custom message. It needed to be defined as a text/string in the node itself.

Here is an example function node:

 * Get all latest humidities and save to global var for replay.
 * WARNING: Requires Node.JS v8+

let currentHumidities = global.get('currentHumidities') || {}

let payload = ''
let locns = Object.keys(currentHumidities).sort()

locns.forEach(function(locn) {
    let h = Math.round(currentHumidities[locn]).toString().padStart(3)
    payload += `\`${locn.padEnd(15)}: ${h}\`
` // Note the newline, also note text is wrapped in `` as output is markdown - this makes the text fixed width

msg.payload.content = "*Current Humidities are*:\n" + payload

msg.payload.options = { "parse_mode": "Markdown" }

msg.topic = 'TELEGRAM/myBOT/Current_House_Humidities'

return msg;

// EOF

Note the requirement for at least Node.js v8 due to back-ticks. Also note the embeded markdown.