Well the problem is that your string contains underscores _ which are interpreted as markdown control characters.
Text between two undersores is written in italic style.
But as your string only contains 3 underscores the third underscore confuses the parser as it thinks that you forgot the closing one (the 4th).
The error message indicates that at position 25 some formatting starts without a matching _ before the end of the string.
zalkerbos_cms_ketelhuis_1 overdue for 5 days!
I added an underscore and now the message is sent. Though that is obviously not what you wanted to achieve
Well, if it is only the underscore you can escape it as follows:
var str = msg.topic.replace(/_/g, "\\_");
msg.payload = {
chatId: 123,
type: "message",
content: str,
options: {
parse_mode: "Markdown"
}
}
return msg;
I passed your string using an inject node therefore msg.topic contains the relevant string.
Here is a short flow
[{"id":"ba1931f2.6acf9","type":"telegram sender","z":"c513a2fb.133e3","name":"","bot":"19f02f8b.fa0c5","x":630,"y":80,"wires":[]},{"id":"fef80bb2.c2c278","type":"inject","z":"c513a2fb.133e3","name":"","topic":"zalkerbos_cms_ketelhuis_1 overdue for 5 days!","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":100,"wires":[["f10dd4b3.a198d8"]]},{"id":"f10dd4b3.a198d8","type":"function","z":"c513a2fb.133e3","name":"","func":"var str = msg.topic.replace(//g, "\\");\nmsg.payload = {\n chatId: 138708568,\n type: "message",\n content: str,\n options: { \n parse_mode: "Markdown"\n }\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":100,"wires":[["a432daea.b1a618","ba1931f2.6acf9"]]},{"id":"a432daea.b1a618","type":"debug","z":"c513a2fb.133e3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":470,"y":160,"wires":},{"id":"19f02f8b.fa0c5","type":"telegram bot","z":"c513a2fb.133e3","botname":"Foo","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"","socksusername":"anonymous","sockspassword":"none","bothost":"","localbotport":"","publicbotport":"","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":true}]
Output will look like