[HowTo] Setting up a Telegram Bot for all your Home Automation messages

@phillprice node-red-contrib-chatbot depends on grpc, which is not available/compatible with ARM based systems.

You are trying to install it on a Pi (or similar ARM device). That won’t work. This is not a limitation of the add-on, but a limitation of one of the decencies of node-red-contrib-chatbot.

2 Likes

Thanks @frenck - didn’t think it was a problem with the add on don’t panic. I seem to be able to hook together node-red-contrib-telegrambot in its place :slight_smile:

In that case i’m Interested in your addon config :slight_smile:

Sorry I mean you’re right it’s a raspberry pi. So it’s not an add on problem :slight_smile:

Hey, is someone using chatbot to send videos to telegram?

This is what i have now but its not working

It records my camera, delays the message untill the video is created as mp4 and should send it with telegram. But I always get this error:
"Error: EFATAL: Unsupported Buffer file-type"

It works when i replace the video node with a document node but then i receive a zip file which is quite unhandy. I hope you can help me out :slight_smile:

Having issues with this setup. Can you add more color on how to setup the conversation node? Also you have to add 3 nodes just to send a message?

msg : string[59]

"Inject failed: RangeError: Maximum call stack size exceeded

Keep getting this error.

I can’t seem to get the user id from that url is there anything special I should be doing?

https://api.telegram.org/bot<token>/getUpdates

@jimpower same here, don’t know what the problem could be :thinking:

First of all, you have to send a message to the bot first and then you should have content.
The url https://api.telegram.org/bot<token>/getMe is returning content. :roll_eyes:

Another working option to get the user id is by using a Node-Red Telegram receiver node with a debug node attached to it and check the payloads chatId value.

Why the getUpdates function is not working, beats me…

1 Like

Is that right? Because it is working on every standard install with Raspbian (Node Red is standard preinstalled) where I ever worked with.

Looks to me it is a HassOS related issue. Please correct me if I’m wrong.

Not fully wrong, not correct either.
There are more factors to take into account. HassOS is not one of them, since Hass.io runs everything in containers.

Raspbian is a special kinda thing… So that is not a generic solution in this case.

Another difference, the add-on is based on Alpine Linux (which uses Musl lib instead of GLibc at the core).

@Domoticon there you go, corrected :wink:

1 Like

I get it @frenck. Thanks for the correction :smile:

@frenck, I just discovered your YouTube channel, looking at your 21 if June 2019 stream and now it think I get it!

Can you tell me what Ubuntu version you use for your VM? I want to setup the thing you are talking about, using VirtualBox.
EDIT: Nevermind, I got a working setup now, just by watching what you did! Thank you!

Thank you for all your work. It’s very, very impressive. Ga zo door! :wink:

I just attempted this reading your instructions and found the same issue around the UserId.

There is a userid-bot (@userid_bot) that can be used, might be worth updating the original post?

There are several bots doing that, but I’m reluctant with that. You never know if, and, or how they are (want to) use it.

I found an other solution, when you have to get the user-id without the Telegram Node-Red functions, which looks more secure to me:

  1. Go to the web version of the Telegram messenger with your browser: https://web.telegram.org

  2. Login with your phone number. Your Telegram messenger app on your phone will sent you login-code. Use this code to log in into the Telegram web version.

  3. Select your Saved Messages account.
    FYI: In fact, that is your private Telegram cloud storage.
    If you don’t see that ‘account’ you can enable it, if I remember correctly, by selecting the 3 horizontal stripes icon (left top) in your Telegram phone messenger app and select the saved messages option from the pull down menu. Store a message and the Saved Messages account should show up.

  4. Check the web-browser URL, it will look something like:

https://web.telegram.org/#/im?p=u12345678_9101112131415161718

Your user ID is the number between the im?p=u and the _ character, in the above example 12345678.

In this way you can get all user-IDs of your contacts, by selecting them and check the URL!

P.S. When done, don’t forget to log out from the Telegram web version by selecting the top left 3 horizontal stripes (Options), select Settings, select Log out at the bottom.

1 Like

Hi @Domoticon

I’m trying to use the flows at first post, but I get a strange behaviour

This is my example

and this is how is defined the Telegram Receiver node

This is the Menu node

This is just for test.

When I send the /start command I get the menu twice and if I send the /stop command I don’t get the end mesage, but I still get the menu again.

17

What is strange is that the only debug node where I get the message is # 1 as in the first image, it seems that does not go thru the other ones.

Any suggestion?

Thanks

I am in the same boat here. No matter how i try to send the video i get the same:
“Error: EFATAL: Unsupported Buffer file-type”

EDIT: I managed to get around this issue by using the telegram bot integration into Home Assistant.
I was able to call the “telegram_bot.send_video” service to send the file to the targeted ChatID.

1 - If you use a Telegram Sender node, enable the Track and Pass Through options.

2 - Use for every command a Telegram Sender node and connect the output to all the Command node inputs (loopbacks). This is different from the example in the first posting, but I experienced the same issues/difficulties and that is how I solved it.

3 - In your example, make sure the Telegram Sender node connected, at the end of the /stop command, has disabled the Track and Pass Through options. This to make sure you can exit the Telegram tracking. Be aware if you don’t do this it can be resulting of being stuck in the Telegram tracking loop.

4 - if duplicated commands occur, you could use a trigger node between the command which is duplicated with options set to:
Send: nothing
then: wait for, 1, Seconds, extend delay if new message arrives
then send: the latest msg object
Handling: all messages
FYI, this my noob solution…

Hope this helps.

Can you share an example how you did that?

Thanks @Domoticon

Trying to replicate your flow.
What is the grey node with right arrow? It seems a subflow or what?

The yellow right arrow is a telegram sender node, right? What are the parameters?

03

Thanks

That are Link input and output nodes. I use this to keep the flow ‘shows’ as clean as possible, otherwise it will show all loop-back lines. If you click on it, it will show the connections, if you don’t click it if will not show the connection lines.

You don’t have to use those, it’s just a personal solution I use.

1 Like