What is a good way for sending messages between Node-Red and your smart phone also in case the smartphone is not connected to your LAN?

There is also the simpler (to me) node-red-contrib-telegrambot - with less nodes :-).... but also probably less capability.

Certainly less capabilities - but will you ever use them? You can do pretty much everything with telegrambot. Rivescript was the capability I used in nodebot that I wished for but that is also now possible using the contrib-rivescript node:

2 Likes

Hi there

After spending some time finding out the limitations of telegram bots not being able to talk to each other, I wanted to share my solution. So this way Node Red can send messages to my phone, and my phone can send automated messages (no human interaction) back to node red without VPN or exposed node red:

My problem was:

I wanted to realize a presence detection for Node Red. I only have Node Red running on a Raspberry Pi. I tried all kind of different things like Unifi Controller (very buggy), Tasker (if WiFi connected and also near WiFI) and HTTP Request via local area network to node red (very buggy because of WiFi connection problems)...I don't want to do presence detection via Bluetooth ether, because it's also depending on wireless signal, and these technologies get disconnected all the time. I'm also working with PIR Sensors, but when there is no movement (me sleeping), there is no detection...I was thinking about messages that don't depend on local area network...or VPN...or risky exposing of node red to the the internet...

So I endet up with Tasker / Autolocation / Autonotification / Remote Bot for Telegram & Viber to Node Red with node-red-contrib-telegrambot.

So basically my Phone is doing the presence detection and then sends a message to telegram which is then received by the telegrambot-receiver Node on node red. Because I wanted this to be automated on my phone I had to us a Telegram Bot with Tasker. But as said, this bot is not able to talk to other bots (integration on Node Red).

So here is how I do it at the moment, still testing, but for now it works great:

Tasker Profile with Autolocation Plugin, detecting if I'm in or out of a 300 Meter Radius of my home, this is running on my phone I always have with me. When in or out of that geofence, one message (Text "Home" or "Away") gets sent with the corresponding task of the Profile via the Tasker Plugin Remote Bot for Telegram & Viber to the bot chat. So the Bot in Node Red receiver node is the same bot as within the Tasker Remote Bot Plugin. Node Red Receiver node is now not able to see the message (no bot to bot talking, even if it is the same bot). But I do get this message on a separate Android Phone at home which is running the same Telegram account and has Tasker and the Plugin AutoNotification installed. So there a notification with the possibility to answer directly within that notification pop up. Tasker and AutoNotification can see and answer that message. If the Text is from Telegram and is "Home" one profile of Tasker kicks in, which answers to the same bot with the reply of "Home". Because this text is sent with Tasker and AutoNotification and not from a bot, the bot is now able to see the message. Which means, I now receive the text "Home" from Tasker and AutoNotification from the separat phone on my Node red receiver Node. From there I can work with the payload "Home" or "Away". Because the Bot-Chat is not public and only accessible with the Token, I think it is pretty safe. Maybe I get to learn a different opinion here :wink:

I still have one annoying thing to solve: because the answer from Tasker and AutoNotification is going to bot, the bot answers with a message, saying that it is not understanding what I want from it. This message then pops up on telegram on all devices with the same telegram account. So I tried multiple ways around it, but could not find a solution yet:
I tried to ad the bot as an admin to a privat group chat, so that the original message goes to this chat. But then the notification I get on the separat phone running Tasker and AutoNotification does not have the option to answer directly within the notification. So AutoNotification can see the text from the bot, but is not able to answer.
I also tried to click away the last notification (the bot not understanding my text) via Tasker and AutoInput, but this is only possible, when screed is on and not locked.

So this is it. I know, It's a loooong workaround and quiet complicated. But it works for me. Maybe this is some help for other users...I do presence detection this way. But you could use this way to do other things with it.

1 Like