Node-Red chat integration: Telegram bot
HTML-код
- Опубликовано: 27 авг 2024
- This is a quite long and extensive flow I built for telegram integration. It does a few things just to mention a few:
- Registration of telegram users in the bot (to control who can use the services offered by the bot)
- Receiving and responding to commands as simple words (not /command)
- Handling complex conversation where the bot responds with options as keyboard
- Handling user control where users can only access commands based on their access level
- Sending text, image and voice messages
- Complete framework open for adding new functions
Download the entire flow seen in this video: drive.google.c...
A great video that has given me loads of ideas to expand my current system and use of Telegram.
Thanks for taking the time to create yet another brilliant video.
Thank you for taking the time to discuss your flow and to allow us to import the flows!
I personally always wait for your Node-red videos, they are always so helpful. Many thanks and please keep up the good work! Cheers
Thanks a lot. It has been some time since I made anything new in Node Red, but hopefully there will be more interesting project in the future.
Hálás köszönet a megosztott flow ért és az önzetlen segítségért!
It is great work and it inspires me to make node red more richer than ever. And detail explanation and sharing flow is awesome. Great thanks to you.
excellent video, whenever you upload something related to node-red is very interesting. additionally, thank you for sharing the node-red code to be able to put it into practice and implement great things like this.
Thanks, I hope you can use it for great things.
As always great video - very stimulating and I especially liked the idea of cascading the help message build to make it easily extensible
Thanks, I have seen this help idea somewhere and I wanted to incorporate it. To be honest, I probably only use half of the functions that I developed, so it is good to remind myself what is available.
excellent value as always in your videos, thanks Csongor :)
lots, lots of info, best practices and ideas we can reuse :)
Thanks a lot.
Thank your for your effort to make this video. Really impressive.
This is so impressive and ingeniously implemented. I will try to implement this great process with me too. Many thanks for the great video and the Node Red Flow template.
@Csongor Varga Thanks for sharing this knowledge.
Thanks for sharing!!!
Hi
Csongor Varga,
can you provide me the example of setting telegram webhook in node red
Thanks, this flow is really useful
great work, thank you!
Is there a way to send MORE images (for example from camera) IN ONE telegram MESSAGE? Example notification: "motion on yard detected cam1.jpg cam2.jpg cam3.jpg". I would be grateful if someone sharing flow for this in nodered.
hi. thanks for your video.
i have a query. To which folder shall i save my camera snapshot , so that i can provide the path in the content section in function node going towards the send notification node. i am able to send images through "http:.... " pointing to some image on internet... but am confused how to include the path in the content section for a file saved in my camera snapshot folder
Hello mate, very interesting video! :) One question, at 18:30 your BOT shows some buttons. How to define these buttons?
You can check my code, but these keyboards which are called inline buttons are explained quite well on the node page: flows.nodered.org/node/node-red-contrib-telegrambot. I have to say that is my most favorite feature of Telegram.
Hi
I wrote also a flow, send a picture from my cam when someone is ringing at the door. works correct. But when i deploy a new change or else in NR, the ChatID is empty. so when now someone is at the door, no notification can send... do you know this problem?
Thanks
pat
For all outgoing messages (which is not a response) you have to add the ChatID manually. You should set it on the msg object yourself.
Hi @Csongor Varga,
great video and thanks for making your flow downloadable.
On the BOT registration, if the user at the time of registration shares his contact (with a custom keyboard) it is also possible to store his mobile number and authenticate it considering the real mobile number.
I am not sure. I think Telegram has some services to get the user details like real name and phone number, but I did not look into that.
@@csongorvarga
From what I remember telegram does not share the user's real details unless he does it.
To do this the user must share his contact through "request_contact" and the bot must verify that "msg.contact.user_id" is equal to "msg.chat.id" to be sure that the shared contact is his own and not one of the many in the column.
To use "request_contact" you can create the custom keyboard.
I'd like to add it to your flow, but I don't know where to add it 😅
What Pallets are you using as i have a few undefined. ui_dropdown, voiceRSStts and sqlite.
Thanks
ui_dropdown is part of the dashboard, other you will find if you search for these names, voiceRSStts, sqlite.
Nice
Hi good video, I have a question; how I can put the temperature into my bot in node red?
hi Csongor, trying this flow in my nodered right now... can't understand how to setup the camera part, can't see anything in flow about connecting to rtsp stream url... and it's like some of the LINK nodes are not actually connected to anything...
Yes, that is a completely different flow that I covered in another video.
@@csongorvarga seen that now, thanks, i'll that too :)
Yes, I covered the the NVR part is a separate video and also a completely separate flow. This is why you only see links here.
@@csongorvarga thanks ;)
Hi,
I'm glad I found your video while I was scrolling through your other videos as I got the notification!
Well, idk if you have faced this issue or not, but I have been using my nodered with telegram for 6 to 9months now, but it won't work properly after a while. It won't respond to my messages and won't even give timed replies.
I have to go to nodered and restart the whole nodered or just hit the update button .
Never found out what exactly is the issue. But would like to ask you, if you have also faced the similar issue !
Cheers !
Uh, that is thought. Mine is probably running for the same time, but never had an issue so far. I don't have any recommendations other than keeping NR and the telegram node up-to-date.
Parth, did you find a solution to this? I have the same problem every time I temporarily loose my internet connection. The Telegram nodes just hang until you restart the flows manually. Very frustrating, making an otherwise excellent solution unreliable. It is still exactly the same in the latest version of node red (V 0.20.7) and node-red-contrib-telegrambot (V 5.5.1). Does anyone have a fix ?
I forgot to say EXCELLENT Node Red videos. They are the best node red learning tools in existence. Keep up the good work :-)
Thanks great video
what camera you recommend to rstp -nvr
I can't recommend any to be honest. Most of Chinese cameras support RSTP. I have an old Cotier wired 720p camera. I has been working without any issues for years, but broke a few weeks ago, when I was moving my cables around. The camera is probably still OK, I just need to crimp the LAN cable. Most probably connection issue.
Excuse me, how to install dashboard for management telegram clients? Thank you.
Sorry, what do you mean? Where did you get stuck?
@@csongorvarga My apologies for my bad english, i'm new on Duolingo App : ) At 13 minutes on the video is shown a management interface for Telegram clients. How is this installed?
@@silva1tube It is part of the Node-Red flow. You find the link to the flow in the video description. You need to import that into your Node-Red instance. Of course that means that the components (e.g. Dashboard) are installed.
@@csongorvargathank you very much for your help!
too hard to start y just copy the code and way too many errors
Great video. I can't seem to keep the boot connected. The error is a "polling" error. If I re-deply the flow, then if connects. I'm not sure when it drops as I'm not home all day to watch it. Any ideas?
I had the same issue in the past, but somehow it got resolved and I don't remember the solution. Check this thread, may help: github.com/windkh/node-red-contrib-telegrambot/issues/97
Hi
Csongor Varga,
How to send timeout response when user is not replied anything and can you send me one example for telegram
There is a watchdog node you can configure to send a second message after the last message.
thanks for the tutorial. I'm trying to add text-to-speech and speech-to-text service to the Telegram on Node, how do I go about that?
I think you should use your mobile device to deal with speech-to-text. I have an android phone and I have a mic icon on the keyboard, so I can speak which gets converted to text on the phone. For text-to-speech I have an example in the code. I am using a VoiceRSS node (node-red-contrib-voicerss-tts) which converts any text in msg.payload to an mp3 file. You can pass the mp3 to Telegram as a voice message.
Hi @Csongor Thank you very much for your video, it helped a lot, to understand the bot function. Can you please shar how you generate a screenshot from your rstp stream?
I have a separate video on that. But in short, I am using avconv in a simple Exec command. avconv is a fork of ffmpeg. And it basically captures a single frame from the rstp stream and saves it on a file on the PI. Very simple.
@@csongorvarga thank you for your quick reply, I will check your video first :) thank you for your great videos!
Hi I'm new in node-red and i have a doubt. How can I indicate to the telegram node that the chatId to read are from file of registrations?
You need to write some code in a function node for that. You read the file when node-red starts to e.g. a flow variable, and than when the message comes is you check if the chatid is in the list or not. I am doing the same checking the chatid against a userlist.
@@csongorvarga Thanks for the video, really useful. I created the telegram.json file but is blank. This is the error message: "Unexpected end of JSON input". Could you kindly help me I don't know how to write the function. Thanks and good job
@@Grafichedelmare type /start to your Telegram bot on your phone. That will create the first user and will also overwrite the telegram.json.
Hi @Csongor Varga
, do you have a new version for this?
i want to implement this... maybe you have some updates ? :)
I started working on some message subscription part of the flow, but it is not complete yet. But that adds to the existing flow, there is no major change the this version.
@@csongorvarga Thanks i was able to implement the user system... but i am getting some undefined value ... is there any way we can chat ... not here?
@@aihysp Sure, you can email me on my gmail, first name dot last name at....
@@csongorvarga thanks i will rap all my Q and send thanks!
Thank you very much to have shared this one. This seems on of the best flow and I personally I'm interested a lot in the part to send camera picture to telegram. Unfortunately I'm not an expert with node red and I cannot understand exaclty the flow to do that. I'm able to get the picture on mt tmp folder and I prepared the payload as in your flow with
"msg.payload = {
chatId : msg.telegram.chat.id,
type : "photo",
content : msg.filename,
caption:"Picture from the camera"
};
Seems in debug the message is preparedcorrectly, by the way the image isnot sent to telegram. Idon't see any error, so I'm really not sure if the image is sent or not, but in any case it is not received.
Can you give some more details on this specific part ?
I tested the image send again and it is still working. You code is correct. Two things can go wrong, the chat id is not your chat id or the filename is not correct. Did you check what is the payload that goes out to Telegram?
thank you very much this is amazing. i tried doing something like this, it worked majority of ooo but at some points i could not get the flow to do what i want. like getting an image from the camera, and controlling relays. pls if you can help me out i will be very grateful
Hi Csongor How can we use same bot token and same username for multiple flows
You add the bot token to the token configuration and you can reuse that as many nodes as you want.
I am getting this error if i add bot token in token configuration "ETELEGRAM: 409 Conflict: terminated by other getUpdates request; make sure that only one bot instance is running"
@@kishorekumarreddyramireddy8373 I am not sure what to say. I do the same thing. I have multiple telegram nodes around my flows, I set up the configuration ones, and I select the same configuration on all the other nodes.
Hi songor, I found your vide very intresting and full of idea to work on. But I'm newbe on NR and I'm unable to run your after localizing. First of all I sent a telegrram msg to be registered, but I alway am unathorized and I don't know how to move forward. I also tried to run the UI but the system is asking me user and pass. can you gime suggestion to fix it? thanks.
Uh, so you have created your own bot, right? If so, you need to type /register that will create you as a telegram user in the flow. Than you go to the UI and edit that user, give it access level and enabled it. If you have set user and pass on the UI, it must be the same user and password than the editor. But that was not done by my flow.
@@csongorvarga I made a mistake... It's all about reading the docs. I cheched the Node-Red configuration and during the installation I defined a USER&PASS I forgot. Now I can acces to the UI but your flow is complex and I have to spend time to personalize.
Sadly Telegrambot is useless. The polling fails with an error.
My flow is showing polling error, but still everything works fine. Messages are going back and forth without any issues. You can read about the problem here: github.com/windkh/node-red-contrib-telegrambot/issues/97
Hi, thanks for the video! Would you be able to advise if there a fix to Telegram unable to send local photo from content:"/config/www/tmp/camera.jpg"? Thanks
Interesting... is there any specific error message? And the obvious questions: does the file exists in this folder? Also I am thinking if for any reason Telegram has no access to this file? Can you check if the user node-red is running on has access? Check and see if you can send a photo from the node-red folder, if that is working, it is likely an access issue.
@@csongorvarga it has always been working followed your video but recently it won't send photo anymore. Error is Caught exception in sender node:
Error: ETELEGRAM: 400 Bad Request: invalid file HTTP URL specified: URL host is empty
when processing message:
{"_msgid":"071793268caf49f1","payload":{"chatId":"1234567","type":"photo","content":"/config/www/tmp/g4doorbellpro.jpg","caption":"This is the image caption","options":{"caption":"This is the image caption","chat_id":"1234567","photo":"/config/www/tmp/g4doorbellpro.jpg"}},"topic":""} If I replace local path to a valid ipaddress/image.jpg it works just fine. Thanks.
Hey@@csongorvarga you are so right, by changing the video capture destination to media folder fixed the error for now. Thanks.