Node RED bot

953 views
Skip to first unread message

Electronic Playground

unread,
Mar 1, 2018, 1:18:08 PM3/1/18
to Node-RED
Hey guys. Anyone interested in a tutorial for building a chatbot using Node RED, Dialogflow and Telegram? I'm thinking about making it for a while (would help me develop some skills, and help some people understand usage of several nodes) but I lack motivation. It will show how you can command appliances and query sensors using the technologies mentioned. Let me know what you think about this.

Paul Reed

unread,
Mar 1, 2018, 5:32:38 PM3/1/18
to Node-RED
I'd certainly be interested.
I'm currently using google-action & ecolect nodes, which work fine for basic stuff, but high coding skills are needed for doing anything more advanced (higher than mine!).

Paul

Bart Butenaers

unread,
Mar 1, 2018, 6:04:03 PM3/1/18
to Node-RED
Hey E.P.,

I would appreciate if you could create a tutorial !!!
Some time ago I have posted a question on this forum about Telegram and Node-Red.
Got some good feedback from a series of people, but unfortunately I didn't manage to get it working.
So I gave up after a couple of evenings trying ;-(

Thanks in advance!
Bart

Electronic Playground

unread,
Mar 2, 2018, 2:43:22 AM3/2/18
to node...@googlegroups.com
Thanks for your responses, guys. I will spend some time during the weekend on this. I will post a couple of links here (a blog post and a github repo) once i have enough content to get you started. I would make a video but i think would take me longer as i don't have editing skills. 
Any feedback will be appreciated and I'll try to help if you meet difficulties along the road. Btw, telegram  bots are pretty neat. I recently implemented a remote control for my TV with a telegram node (+arduino with IR and a python script). :)

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/HQ33wVs0zxs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/4bc19313-21ae-4105-a9cd-77fff536df1c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bart Butenaers

unread,
Mar 2, 2018, 3:17:00 AM3/2/18
to Node-RED
Morning E.P.,

You will regret the day that you have asked me to post feedback ;-)

The Telegram setup/architecture was a complete mysterie to me.  Had been reading articles about it, but the setup/architecture and the interaction with my Node-Red flow never became clear.  So it would be great if you could add some overview picture, where we could see the whole path.  Something like this (but more detailed, like the bots themselves on the servers, etc ...) :

Then it is easier to understand the detailed steps from your tutorial, to understand the entire 'picture'.


Looking forward to your tutorial !!!!!!!!
Bart

David Dempster

unread,
Mar 2, 2018, 4:49:45 AM3/2/18
to Node-RED
Can I add my thumbs-up for a tutorial.

Node-Red-Bot chatbot doesn't seem to like coexisting with the Telegram node

Cheers from David

Electronic Playground

unread,
Mar 2, 2018, 5:50:28 AM3/2/18
to node...@googlegroups.com
Just a short description of the architecture (picture later :) ):

Will use only telegram send/receive nodes.

Telegram receive will send the message to Dialogflow node for NLP (natural language processing). The result is then interpreted inside node red via some basic nodes (switch node, function nodes, maybe mqtt for actuators).

Some text answer (either from dialogflow or created in node red) is sent back to telegram via telegram send node.
Glad i got your interrest. I don't expect an easy audience :)

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/HQ33wVs0zxs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Julian Knight

unread,
Mar 2, 2018, 4:09:38 PM3/2/18
to Node-RED
Chatbot is a bit of a monster. The telegram node is a lot easier to use in most cases. In fact, I'm just trying to reinstall the chatbot nodes as they seem to have moved on a fair bit since last I looked.

The thing I liked about chatbot was the Rivescript integration which can very much simplify conversational interfaces.

I have had both installed on the same NR instance though without issue. I'll let you know if I have problems when I reinstall. I'm just stuck with another node, node-red-contrib-auth, which - it turns out - installs an old version of node-red itself as a dependency!

I've been using Telegram bots for a long time now so feel free to reach out if you get stuck. My last update with Telegram was to create a command interface for my lighting.

Telegram has about the easiest bot API I've come across though the structure of the messages does take a bit of head scratching to understand. It doubtless hasn't got any easier with all the new features they've added. The telegram node is probably the easiest to install and the instructions should see you as far as doing something really simple but you will then hit a fairly steep learning curve to do anything like a lighting control. Especially if you want to do a conversation interface. It is fiddly and the interactions don't always work the way you might expect. So build it up a small piece at a time with lots of debug statements so that you can see what data is actually coming through.

Julian Knight

unread,
Mar 2, 2018, 5:08:36 PM3/2/18
to Node-RED
Just tried chatbot again and I can't get it to work at all now. I've raised an issue.

Paul Reed

unread,
Mar 17, 2018, 8:49:36 AM3/17/18
to Node-RED
How's the tutorial coming along...

Paul

Electronic Playground

unread,
Mar 17, 2018, 11:42:22 AM3/17/18
to node...@googlegroups.com
Hi Paul, I implemented the first part (connect telegram node, Dialogflow node and respond to telegram chat with "small talk" from Dialogflow). I have screenshots with the steps and a basic architecture diagram. I'm thinking to add the first steps as a "telegram bot" blog post and continue with a second post where I will show how to connect more Node RED actions to interact with, using telegram (start camera, get sensor readings, command some appliance). I'm thinking to publish the first part I was talking about by tomorrow evening.

Thanks for your interest!
Florin

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/HQ33wVs0zxs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Electronic Playground

unread,
Mar 19, 2018, 1:32:57 PM3/19/18
to node...@googlegroups.com
Hi guys.

Below is the link to the telegram bot tutorial. It's still in progress and I will continue updating it in the next days, as my schedule allows..




On Sat, Mar 17, 2018, 17:42 Electronic Playground <electronicp...@gmail.com> wrote:
Hi Paul, I implemented the first part (connect telegram node, Dialogflow node and respond to telegram chat with "small talk" from Dialogflow). I have screenshots with the steps and a basic architecture diagram. I'm thinking to add the first steps as a "telegram bot" blog post and continue with a second post where I will show how to connect more Node RED actions to interact with, using telegram (start camera, get sensor readings, command some appliance). I'm thinking to publish the first part I was talking about by tomorrow evening.

Thanks for your interest!
Florin
On Sat, Mar 17, 2018 at 2:49 PM, Paul Reed <paul...@gmail.com> wrote:
How's the tutorial coming along...

Paul

On Thursday, 1 March 2018 18:18:08 UTC, Electronic Playground wrote:
Hey guys. Anyone interested in a tutorial for building a chatbot using Node RED, Dialogflow and Telegram? I'm thinking about making it for a while (would help me develop some skills, and help some people understand usage of several nodes) but I lack motivation. It will show how you can command appliances and query sensors using the technologies mentioned. Let me know what you think about this.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/HQ33wVs0zxs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.

Bart Butenaers

unread,
Mar 21, 2018, 6:29:21 PM3/21/18
to Node-RED
Evening EP,

When you have time to update the tutorial, could you please add some extra detail steps?
For example some of the stuff that Julian added to my discussion:
  • Where to sign up for an account.  
  • I don't remember anymore if you had to install the app, to be able to setup an account.
  • How (and why) to add the bot to a group
  • How to control which groups can include the bot, because I want my Node-Red flow to send alarm messages to my phone (but I don't want anyone else to be able to send messges to my phone).
And in the 'architecture' picture, you start by sending a message from the app to the Node-Red flow.
This way the flow has all the required data (e.g. a chatId), which can be used to send data back to the app.
But suppose I want to send a message when something happens at home.  
So there is no message from the app to the Node-Red flow as starting point.  
Where do I have to get the communication information (chatId ...), to initiate a communication from the Node-Red flow to the app?

Thanks a lot !!!
Bart

Electronic Playground

unread,
Mar 22, 2018, 1:41:14 AM3/22/18
to node...@googlegroups.com
Hi Bart,

Thanks for the suggestions and questions. I will add more details soon.

Just a tip: from what i saw, the chatid that comes with a telegram message is unique per user so you can save that in a file maybe, then read it in node-red whenever you need it.

You could use the telegram sender node to send messages at any time. Just construct a payload with content and chatId at least. Indeed, my drawing is incomplete in that perspective.

Thanks for the feedback. I'll post here when i add more details.

Florin

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/HQ33wVs0zxs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Electronic Playground

unread,
Mar 22, 2018, 2:52:11 AM3/22/18
to node...@googlegroups.com

Electronic Playground

unread,
Mar 25, 2018, 5:09:42 AM3/25/18
to node...@googlegroups.com
Hi guys, I added more details for the Telegram flows. Any feedback is welcomed  and I will add more details if necessary.
Will continue with adding content for using Dialogflow as NLP (natural language processor) as I assume that you already know how to read sensor values in Node-RED.

I'm thinking to create at some point a very short post about sending data between a python script (that may read serial data from an Arduino or read GPIO on a Raspberry Pi) and Node-RED using mqtt. 

Have a good weekend!

On Thu, Mar 22, 2018 at 6:51 AM, Electronic Playground <electronicp...@gmail.com> wrote:

To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.

Bart Butenaers

unread,
Mar 25, 2018, 2:30:44 PM3/25/18
to Node-RED
Evening E.P.

You are my hero on this sunday evening!  
After reading your updated tutorial, I was finally able to send Telegram messages from my Node-Red flow.
Thanks a lot for spending your free time to get this up-and-running !!!!!!!!!!!!!!!!

My missing key was the chatId.
I could get the chatId easily with a debug node, after I had send a test message from (the Telegram app on) my Android phone:

Afterwards I used that same chatId with the TelegramSender node, which allowed me to send a message back to my Android app.


However I expected the message to arrive on the first output of the TelegramReceiver node.

Thought I would be an authorized user for my own bot.  Or should I do something special to become an authorized user myself ??


Bart

Electronic Playground

unread,
Mar 25, 2018, 2:39:22 PM3/25/18
to node...@googlegroups.com
Hi Bart,

Glad to hear the tutorial was helpful. :)
Also thanks for the feedback. Helps a lot to have input while developing it.

In order to become an authorized user you need to add your chatId to your bot configuration in Node-RED ("ChatIds" field). After that, you will receive messages on the first TelegramReceiver
input.


--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/HQ33wVs0zxs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Bart Butenaers

unread,
Mar 25, 2018, 4:31:48 PM3/25/18
to Node-RED
Yep, that does indeed the trick ...

Could you perhaps also add an example of sending non-text data in a message (like images, ...)?

Started an image test twenty minutes ago, and I expected it would become a complete failure.
However it seemed to be working fine from the first time:



[{"id":"588d455a.b9a3bc","type":"inject","z":"d7a683c8.03b5e","name":"Send message with image","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":390,"y":1120,"wires":[["ba2d2c19.20a63"]]},{"id":"ba2d2c19.20a63","type":"http request","z":"d7a683c8.03b5e","name":"","method":"GET","ret":"bin","url":"https://accelerator-origin.kkomando.com/wp-content/uploads/2016/08/shutterstock_330700175-970x546.jpg","tls":"","x":630,"y":1120,"wires":[["aa6aee4a.976e1"]]},{"id":"aa6aee4a.976e1","type":"change","z":"d7a683c8.03b5e","name":"","rules":[{"t":"set","p":"temp_image","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.content","pt":"msg","to":"temp_image","tot":"msg"},{"t":"set","p":"payload.type","pt":"msg","to":"photo","tot":"str"},{"t":"set","p":"payload.chatId","pt":"msg","to":"<your chatId>","tot":"str"},{"t":"set","p":"payload.caption","pt":"msg","to":"Burglar detected","tot":"str"},{"t":"delete","p":"headers","pt":"msg"},{"t":"delete","p":"statusCode","pt":"msg"},{"t":"delete","p":"responseUrl","pt":"msg"},{"t":"delete","p":"temp_image","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":1120,"wires":[["4e2ab0bb.45ae2"]]},{"id":"4e2ab0bb.45ae2","type":"telegram sender","z":"d7a683c8.03b5e","name":"","bot":"","x":1070,"y":1120,"wires":[[]]}]


By adding something like this to your tutorial, other users would become aware immediately that they can easily send e.g. an image as content (as a Buffer).  And that they can add an accompanying caption text.


Thanks again ...

Bart Butenaers

unread,
Mar 25, 2018, 5:06:11 PM3/25/18
to Node-RED
Perhaps a bit trivial for most users, but it cannot harm to add a link to the node-red-contrib-telegrambot node(s) to your tutorial.  
When I started experimenting with Telegram some time ago, I had no idea which bot contribution I had to install...

Julian Knight

unread,
Apr 14, 2018, 6:42:19 AM4/14/18
to Node-RED
There is a comprehensive example for using Telegram with NR on the flows site: https://flows.nodered.org/flow/c092bc6bcd4131a59cab52e82afbc7be


Though that site is likely to be short lived as I'm currently migrating my WordPress blog over to Hugo and will fold in the dev site - but I will redirect everything so the old links should still be OK.


On Thursday, 1 March 2018 18:18:08 UTC, Electronic Playground wrote:

Paul Reed

unread,
Apr 14, 2018, 9:37:11 AM4/14/18
to Node-RED
Strange, but the link to your site Julian, continually crashes my browsers, both on Android phone & tablet. Not home, so haven't tried laptop.

Mark Setrem

unread,
Apr 14, 2018, 11:26:07 AM4/14/18
to Node-RED
works well on an iPhone

Electronic Playground

unread,
Apr 14, 2018, 12:59:12 PM4/14/18
to node...@googlegroups.com
Hey Julian, 

Nice looking flows. :) I'll import them and see what I can "steal" from them in the next days.

Also, Bart's idea of sending image data in the capture property of the telegram payload seems to work well.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/HQ33wVs0zxs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Julian Knight

unread,
May 10, 2018, 11:43:32 AM5/10/18
to Node-RED
You might want to try again. You possibly caught them at a bad time. Also note that I'm actually migrating that GitHub site to my blog since I quickly got fed up with the limitations of GitHub pages.

I won't delete the old GitHub pages, but everything can now also be reached via my blog.

https://it.knightnet.org.uk/kb/nr-qa/telegram-bot

I finally got round to migrating the blog, which has been on a self-hosted WordPress site for some years, to something hosted by Netlify and written using Hugo. Better, faster, more secure.

Let me know if you still have issues.

Paul Reed

unread,
May 10, 2018, 3:07:07 PM5/10/18
to Node-RED
That url still crashes browsers on my Android phone or tablet.
However, no worries as I've found the url of your new site - https://it.knightnet.org.uk/posts/ and can access it fine from there.
I've used Hugo for a couple of years now, and surprised that it's not more widely used, as its amazingly fast, very configurable and easy to use once you grasp the basic concepts.

Paul

shykitten55

unread,
May 10, 2018, 9:39:23 PM5/10/18
to Node-RED
Here comes my dumb question.

I haven't heard of either of these nodes.

But scrolling down looking, Telegram looks similar to MQTT - to me.

I'm interested in what these are, though MQTT seems to do what I need.   I like to try and learn - and on a good day ACTUALLY learn.

That's always a bonus!   <wink>


Electronic Playground

unread,
May 11, 2018, 1:47:43 AM5/11/18
to node...@googlegroups.com
Hi,

I'll try to explain in a short manner what MQTT and Telegram are:

MQTT - nodes that can connect to a 
broker software and use it as a communication hub to talk to eachother. MQTT is also the protocol underlying the communication channel

Telegram - a messaging platform (there are messaging apps like WhatApp or FB messenger for roughly any platform: Android, Windows, Linux is what I have it running on). They give you acces to their servers through an API (software accessed over internet) and with telegram bot api and nodes you can send messages to a node-red without exposing ports to the internet. NodeRed telegram nodes ask periodically the server for new messages sent from a telegram app. You can talk to your pi running nodered securelly this way.

Have fun learning! ;)

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/HQ33wVs0zxs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Julian Knight

unread,
May 22, 2018, 4:34:28 AM5/22/18
to Node-RED
Cool, thanks Paul. Not sure what was causing the problems but I'm much happier having ditched the rubbish Jekyll for the cool Hugo :)

For reference, the Node-RED posts that were (and still are) at https://totallyinformation.github.io/nr-qa/ are all now copied over to https://it.knightnet.org.uk/kb/nr-qa/ I will keep the old site but it won't be updated. All of the pages on the old site have a link to the equivalent page on the new site. However, I will be (and have) creating new content on the new site, it will not be available on the old.

Sorry for the confusion but GitHub pages simply weren't cutting it and Jekyll was causing me no end of issues. Using Netlify (for hosting) and Hugo is a joy!

As you will see, the new site is a migration of my blog from Wordpress combined with the knowledgebase from GitHub. So much quicker, more secure, more modern.

Julian Knight

unread,
May 22, 2018, 4:39:17 AM5/22/18
to Node-RED
Sorry for the slow response. I'm not looking at this group very much any more. The new discourse site is so much better.

Telegram is aimed at human messaging rather than the machine-to-machine messaging that MQTT is aimed at. Telegram just happens to also have a decent, fairly easy to use bot capability too.

The main benefit of Telegram is that it is available easily and in human consumable form on every platform. Try getting decent MQTT tools on iOS or, even worse, Windows Phone! 

Telegram bots act as the interface between machine and human. So my Node-RED home automation server sends and receives information to/from Telegram but the Telegram end is consumed by humans - well mainly me but close enough!

Hope that clarifies things? If not, why not ask the question on the Discourse and I will try to expand on the answer there.
Reply all
Reply to author
Forward
0 new messages