scraton / node-red-contrib-telegrambot-home

Useful Node RED nodes for connecting your home to Telegram.
MIT License
28 stars 11 forks source link

I cannot send a message with a defined chatID in the build payload #33

Closed erizivak closed 2 years ago

erizivak commented 3 years ago

HI, I'm using your telegram's bot to send a telegram message when a new event is received from a topic, for that propose, I use the following code: var chat = global.get('ChatID') msg.telegram={} msg.telegram.chat={} msg.telegram.chat.id=chat msg.method="sendMessage"; msg.payload = { text:msg.telegram }; return msg; image

The payload box is not showing any issue but is not sending the message to the user. Flow: image

scraton commented 2 years ago

Hi there! You need to pass the chat_id parameter as part of msg.payload, not in msg.telegram. So it should probably look something like this:

var chat = global.get('ChatID');

msg.method = "sendMessage";
msg.payload = {
  chat_id: chat,
  text: "Hello, world!",
};

return msg;

Let me know if that helps solve your issue! Feel free to re-open if it doesn't.

erizivak commented 1 year ago

Hi @scraton The correct payload should be:

var chat = global.get('ChatID'); msg.method = "sendMessage"; msg.payload = { text: "Hello, world!", }; msg.telegram ={}; msg.telegram.chat ={}; msg.telegram.chat.id= 7373910; return msg;

With this change, the workflow is working

erizivak commented 1 year ago

To solve this 'issue' you need to modify the following files:

I hope this helps you