windkh / node-red-contrib-telegrambot

Telegram bot nodes for node-red.
Other
266 stars 119 forks source link

What am I missing? #159

Closed jwilleke closed 3 years ago

jwilleke commented 3 years ago

How can the current node red payload be sent as a message?

Why do all your examples show setting the chatid in a function and not using the chatid defined in the senders?

Why does this flow always fail with "msg.payload.chatId is empty"

[ { "id": "ae15cb94.3ca928", "type": "tab", "label": "Flow 3", "disabled": false, "info": "" }, { "id": "cc075fee.49e42", "type": "telegram sender", "z": "ae15cb94.3ca928", "name": "", "bot": "bccf4ea3.3127f", "haserroroutput": true, "outputs": 2, "x": 340, "y": 120, "wires": [[], ["950535ee.9a1c18"]] }, { "id": "950535ee.9a1c18", "type": "debug", "z": "ae15cb94.3ca928", "name": "error", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 530, "y": 120, "wires": [] }, { "id": "6a96ac67.bf3ed4", "type": "inject", "z": "ae15cb94.3ca928", "name": "ping", "props": [{ "p": "payload" }, { "p": "topic", "vt": "str" }], "repeat": "", "crontab": "", "once": false, "onceDelay": "", "topic": "", "payload": "ping", "payloadType": "str", "x": 110, "y": 120, "wires": [["cc075fee.49e42"]] }, { "id": "bccf4ea3.3127f", "type": "telegram bot", "botname": "hassio21bot", "usernames": "nick", "chatids": "1234567890", "baseapiurl": "", "updatemode": "polling", "pollinterval": "300", "usesocks": false, "sockshost": "", "socksport": "6667", "socksusername": "anonymous", "sockspassword": "", "bothost": "", "botpath": "", "localbotport": "8443", "publicbotport": "8443", "privatekey": "", "certificate": "", "useselfsignedcertificate": false, "sslterminated": false, "verboselogging": true } ]

windkh commented 3 years ago

Hi @jwilleke Well, the configuration node is shared across many nodes, senders and receivers. The documentation about the configuration node states:

The usernames and chat ids properties can be used to limit authorization to the bot.

You can send a message like illustrated in the example: https://github.com/windkh/node-red-contrib-telegrambot/blob/master/examples/sendmessagetochat.json

Just explore the example to learn how the nodes can be used. The readme is also a useful resource.

jwilleke commented 3 years ago

So I can not pick up a text message from the payload and sent it without putting in code for each message I want to send? I see no examples where you are not required to use a Function node to send a message. Or am I missing something?

windkh commented 3 years ago

Yes you are right... is this a problem for your use case?

jwilleke commented 3 years ago

I was expecting to be able to pass the payload from a flow into the message. I would think without "code".

I build an array of objects and pull out the "Friendly Name" attribute of each, concatenate to a string and wanted to sent those names as a message.

I have not even seen an example with code that does that. The ping example hardcodes the "ping" message even though it is injected into the flow.

windkh commented 3 years ago

That should be easy to implement using a function node