Send mqtt message to telegram

Hello,

An "mqtt In Node" receives different messages from an MQTT topic.

example:
{"topic":"test/topic_1","payload":"test message 1","qos":0,"retain":false,"_msgid":"90dd8faa.79f8e"}
{"topic":"test/topic_1","payload":"test message 2","qos":0,"retain":false,"_msgid":"7d6b3fe3.e7e8d"}
...

I want to send this message to the "Telegram sender Node". What do I have to write in my "function node" for this to work?

let payload = {"chatId":*********,
type:"message",
content:"---the message should be here---"};
return{payload};

Thank you for your help,

A function node is not needed a template node would do the job
e.g.

[{"id":"4b9c66a1.6cc778","type":"inject","z":"9b3f9f31.c45298","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"test message","payloadType":"str","x":190,"y":2140,"wires":[["ea63aa67.c972f"]]},{"id":"ea63aa67.c972f","type":"template","z":"9b3f9f31.c45298","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\"chatId\": 123456,\n\"type\":\"message\",\n\"content\":\"{{payload}}\"}","output":"json","x":380,"y":2140,"wires":[["9e00d0a7.d5ccf"]]},{"id":"9e00d0a7.d5ccf","type":"debug","z":"9b3f9f31.c45298","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":580,"y":2140,"wires":[]}]

good evening,

Thanks for your help, it works very well!

Do you know how I can also send the topic name to telgram? Unfortunately, my example doesn't work.

{"chatId": 123456,
"type":"message",
"content":"{{payload}}"
"content":"{{topic}}"
}
{"chatId": 123456,
"type":"message",
"content":"{{payload}}\n{{topic}}"}

"\ n" shares the payload?
Thanks, that helped.

Slash in the topic name (mqtt**/**topic) is represented as Unicode in Telegram, but it doesn't matter. :wink:

thanks