Node-red-contrib-telegrambot send message on event not on request?

Hi again. I'm playing around with "node-red-contrib-telegrambot". I'm able to receive messages from my bot on a "comand" e.g. /help.
But what I want is that my bot sends me a message on a certain event. e.g. my my door bell rings.

What I've done so far.

  • "Intercept" my 443Mhz door bell and store the event in a global.var (global.set...)
  • When I "ask" my bot a comand. He replies with this variable. (When was the last time the door bell rings -> reply = 2020-01-14 12:00:00

My question is now how to use the bot to send immediately a telegram when someone press the door bell button?

I appreciated any advise.

Kajoty

You can send it any time. i have a flow watching some sensors. How I do it is: the sensors store their values in a global. On nother flow I runn a watchdog. An inject that runs every minute that checks to see if any of the sensors are out of their range. If they are A message is sent to my telegrambot.

the key is you have to have the chatID of your bot. You put yourtext into msg.payload.content, set msg.payload.type to 'message' and set msg.payload.chatId to your chatted. Then you can pass that to the Telegram Sender node

I increasingly do it all through MQTT.

My device inputs are in their own set of flows that normalise the data and send out suitable MQTT topics.

I have a standard flow that listens on a specific topic, reformats the incoming data then outputs to the appropriate Telegram bot (I have several).

Then I have other flows like my "warning" or notification flows that listen for an appropriate device input and create a new MQTT output on the telegram topic.

Hardware/WiFi inputs --> Normalisation function nodess --> MQTT: 'DEVICES/<id>'

MQTT: 'TELEGRAM/<botid>' --> Reformat function node --> Telegram node

MQTT: 'DEVICES/<specificId>' --> Check data (pass on if needed) --> MQTT: 'TELEGRAM/<botid>'

Keeping things decoupled this way makes it much easier to maintain in the longer term.