Not getting Telegram messages that I see on the phone

I am trying to use Telegram to send messages from my phone to Node-Red. An android app is sending messages to the telegram bot I have created. The app is sending the message with the bot token and my chat id. When I open the bot on my phone, I can see those message.
I have also created the flow in node red, a telegram receiver is listening to the messages, but nothing comes through. If I send a message from my Telegram app to the bot, that appears in Node-Red, but what the app sends does not.
I don't see how these messages are different, and why it is getting filtered out in Node-Red. Is it not properly sent from the app? If so, how is it I can see it on the Telegram app. So I am confused.

So you created an application that uses a bot token and it works fine.
Now you created Node-RED flow that uses the very same bot token ?
If this is the case it seems normal to me that it wont work. Same happens when you try to use the same bot token in two different Node-RED instances. The telegram contrib node will indicate pooling error. I believe this is a security from Telegram. Why don´t you create a second bot token for Node-RED, leaving the first one dedicated to your app ?

Hi Andrei,
I don't understand why multiple instances could not connect to the same bot, isn't is the entire point? And why is it that when I type a message from the phone it appears? All I can think of that maybe because the messages coming from the app are being sent by the same chat ID as the chat ID running the Telegram app itself.
How the second bot token will help me? Can multiple tokens created for the same bot? Otherwise it will be two different bots and that kills the point.

I asked myself those questions the first time I created a bot and then again a few more times. Whenever I stop using Telegram for a couple of months or so I forget the basics and have to remind myself things like how to get a chatID for a new bot. Let´s see if we can together cast some light on the subject.

I think of a bot as a software controlled account. The software that controls the account is the one that present to Telegram API the token ID. As I mentioned before i suspect (not entirely sure though) that Telegram API will not allow two software instances to share a bot token. When using Node-RED it will be the software holding the token (stored in the config node).

Well, I can add a bot to my list of contact in Telegram (app or desktop version), so I can invoke the bot to use its "services", In other words, I chat with the bot. The bot can chat with anyone as long as it knows the chatID of the person or the Telegram account name. Bots can be programmed with access lists to block or allow specific chatIDs. An important rule is that a bot will not chat with another bot. Another rule is that a bot will not take the initiative to start a chat with someone.

I currently talk with nearly a dozen of people in Telegram, because they get to know my chatID or account name. I also chat with 4 different bots I have created in Node-RED and eventually I chat with public bots.

Perhaps some use cases may illustrate how using bots is nice.

A couple of months ago I installed a digital screen to monitor the ordering status of customers orders (something like the ones used in fast food restaurants). The IT manager of the store wanted a way to notify users of planned outage and other specific situations. For that purpose I created a Telegram group and invited to this group the users of the system. Whenever Node-RED (bot controller) sends an status report the people in the group are notified.

I tested a second bot that could be used to trigger, via Telegram, the opening of a time limited NGROK session. In this case the second bot would not bother the regular users in the Telegram group.

AFAIK it is not possible multiple tokens for the same bot.

You mentioned you created an android app to chat with a bot. For sure this app knows you chatID, this is why it is able to communicate with your personal account in Telegram. I understand that you created then a Node-RED flow using the same token and it is not working. What happens if you shutdown the android app you create and let only Node-RED using the bot token ?

I hear what you are saying, and it also make sense for me to some extent. But when the app was running and sending messages to the bot, I was also sending messages to the bot from my phone in the Telegram app and those were delivered to Node-Red.
But it still makes sense. I did not write the program myself. Maybe the way the messages are sent is incorrect. I mean to send messages to a bot, you don't need to know the token ID. Token ID is only relevant for the "system" which is managing the bot. Right? So the android app, should rather just reference the bot using the bot name, and not the token ID. Maybe that is the key.

Yes, right indeed.

Exactly.

Additional remarks:
Of course we can have many Telegram users talking to the same bot at the same time. Not an issue at all (otherwise bots would not be useful). What is not possible, my assumption - not fully tested, is that you can not have two systems accessing the API bot with the same token. I should have asked this before: Do you have any evidence that the android app is using the same token used by your Node-RED flow ?

EDIT: only now occured to me that perhaps the android app you are trying to use is not controlling a bot. Maybe it is a Telegram cliente app ? If that is the case then all the considerations I did would not apply, A Telegram client from a 3rd party should behave like the native Telegram app, being able to chat with bots and other regular users.

It is a custom app a friend of mine has created. You can have a look if you understand C#: https://github.com/sellrik/GpsTracker
Anyway, I will keep working on this, I will let you know what I found out experimenting the various functions in the Telegram API.
I am sure it is using the same token, I have entered it myself in the Settings screen of the app.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.