Node-RED - Chat Bot

We are now going to let your AI-Bot communicate with your phone via a Chat Bot. But we first need to install additional nodes in Node-RED for this. Create a new worksheet for this lesson and name it "Chat Bot".
Now click the menu button to the right of the "Deploy" button in Node-RED. Then click on the "Manage Palette" option.

Now click on the tab that says "Install" and search for "telegram". Click the "install" button at the node-red-contrib-telegrambot line.

Then click "Install" again in the window that appears. Now you have installed additional nodes for telegram which you can find in the left list.

Now drag a Command node from the left list to Flow 1 on the right.

Now double click on the telegram "command" node and edit it as follows:

Command: "/wave"
Bot: Click on the pencil icon here. In the screen that appears next to Bot-Name and Token, enter the two values that you collected during the preparation. Then click the "Add" button.
Then click the "Done" button again.

Now drag a "wave" node to the worksheet and open this node once so that the correct bot configuration is selected and click "Add". Now connect the "wave node" to the top output of the "command" node.
The top output sends a message when the command is recognized (/wave). The bottom output sends a message when a command is not recognized. Now click on "Deploy".

Now open Telegram on your mobile phone and send the following text to your own Chat Bot in Telegram: "/ wave".
Your AI-Bot should now start to wave.

Assignments

Now build to flow which will allow your AI-Bot to receive and respond to the following commands via the Telegram Chat Bot:

  1. Speak with the command /speak. For example, you send "/speak Hello" after which your AI-Bot says "Hello".
    Tip: Set msg.payload to msg.payload.content
  2. LED Light changing color by command /shine. For example, you send "/shine red" after which your AI-Bot lights up the LED light red
    Tip: Set msg.color to msg.payload.content
  3. Send a photo back with the command /tp. You then send the command "/tp" after which your AI-Bot returns a photo.
    Tip: Process the output of node "see" (Take Picture) with a "function" node using this code:
msg.payload.content = msg.filename;
msg.payload.type = "photo";
return msg;