This is a quick tutorial to setup a very simple chatbot with Telegram and RedBot.
First of all install Node-RED
sudo npm install -g node-red
Then open the user data directory $HOME/.node-red and install the package
cd $HOME/.node-red npm install node-red-contrib-chatbot
The next step is to create a chat bot, I reccomend to use Telegram since the setup it’s easier ( Telegram allows polling to receive messages, Facebook requires a https callback and a valid https certificate).
Telegram is really coherent and you have to use a chat bot to create a chatbot. Connect to @BotFather and type /newbot, then in the next two steps give the bot a name and username (this will be the real unique address of your chatbot), you’ll get something like this for @my_new_chat_bot
Copy and paste the access token. For more information read here.
Then open your Node-RED and add a Telegram Receiver, in the configuration panel, add a new bot and paste the token
Now add a Message node and connect to the Telegram Receiver
Finally add a Telegram Sender node, don’t forget to select in the configuration panel the same bot of the Telegram Receiver, this should be the final layout
Now you have a useful bot that answers “Hi there!” to any received message.
Receving the same answers is not very useful, we can introduce Command node: it will pass through the output only if the input message is “hi”:
In this way it’s possible to trigger different actions with different commands, read more about Telegram commands here.