Telegram output with bold text and table

i found out to send telegram text in Bold you have to put them between asterix bold
if i do this in my node i got a syntax error, why?
it is also possible to add some url and a table?

[{"id":"31e1314d.271b4e","type":"function","z":"a31f62e6.bb022","name":"","func":"let payload = {\n\"chatId\":3884myid,\n\"type\":\"message\",\n\"content\": \"Wasserabfluss der Wigger\" +\"\\n\" +\"in Zofingen!\" +\"\\n\"\n**+msg.payload** +\" m³/s\" +\" = \" +msg.payload * 1000 +\" l\"\n+\"\\n\"\n+\"                  ... delay 60min ...\"\n\n};\nreturn {payload};","outputs":1,"noerr":7,"initialize":"","finalize":"","x":300,"y":160,"wires":[[]]}]

Try it like this:

msg.payload = {
"content": `Wasserabfluss der Wigger in Zofingen!\n**${msg.payload}** m³/s = ${msg.payload * 1000} l\n         ... delay 60min ...`
return msg;

You get the errors because the double quotes are in the wrong places.

@bakman2 thanks for your fast feedback.
The ** Give now no error but they are just sendet like this and the telegram is with ** but not bold.
have a nice day

I think there is a bit more needed. The doc says that you'll need to include the optional parse_mode parameter, but that probably is not supported by the node. (I tried with node-red-contrib-telegrambot 7.1.1, but there is newer versions)

Telegram uses single asterisks, but you will need to set the parse_mode to markdown as well.

edit @hotNipi was quicker :stuck_out_tongue:

i do have
node-red-contrib-telegrambot 8.9.6
like this Wigger and Zofingen are bold but can't add the * msg-payload to become bold

[{"id":"ac646cfe.551fd","type":"function","z":"a31f62e6.bb022","name":"","func":"let payload = {\n\"chatId\":3884id,\n\"type\":\"message\",\n\"options\":  {\"parse_mode\": \"Markdown\"},\n\"content\": \"Wasserabfluss der *Wigger*\" +\"\\n\" +\"in *Zofingen!*\" +\"\\n\"\n+msg.payload +\" m³/s\" +\" = \" +msg.payload * 1000 +\" l\"\n+\"\\n\"\n+\"                  ... delay 60min ...\"\n\n};\nreturn {payload};","outputs":1,"noerr":8,"initialize":"","finalize":"","x":320,"y":120,"wires":[[]]}]

Well there are no astericks around it ?

let payload = {
"options":  {"parse_mode": "Markdown"},
"content": "Wasserabfluss der *Wigger*" +"\n" +"in *Zofingen!* \n*"
+msg.payload +"* m³/s" +" = *" +msg.payload * 1000 +"* l"
+" \n                 ... delay 60min ..."

return {payload};
1 Like

The 'parse_mode' via options works :slight_smile:

Try this

"Wasserabfluss der *Wigger*" +"\n" +"in *Zofingen!*" +"\n"
+"*"+msg.payload +"* m³/s" +" = *" +(msg.payload * 1000) +"* l"
+"                  ... delay 60min ..."

EDIT: Eh, now I was slow ...


thank you very much @hotNipi and @bakman2
both works now for me and all loks fine

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.