Software
- Node-RED
- Telegram
Hardware
- LightBlue Bean
- Windows or OS X computer with Bluetooth LE
For setting up a Telegram Bot you need a account. After that, you need to start and write /newbot
to @BotFather and follow the steps to create your bot.
Node-RED is a visual programming interface for the Internet of things. If you haven’t used Node-RED with the LightBlue Bean before, you need to set it up before following this tutorial. Here is Node-Red website: http://nodered.org
To install LightBlue Bean and Telegram nodes here: Telegram and Bean. This is what the Node-RED flow for the project looks like:
- /setcolor: Uses the Telegram Bot API to receive setcolor command from the bot.
- /help: Uses the Telegram Bot API to receive help command from the bot.
- confirmation message: When you send
setcolor
command, it sends a reply and makes a custom keyboard.
- create response: Make a response with the color you pick.
- setcolor: Send the color in RGB to Bean.
- help: Make a response for help command.
- Telegram Sender: Uses the Telegram Bot API to send responses.
- Bean LED: Sets the Bean’s LED to the given RGB value.
Copy the JSON data below to your clipboard.
Step 2: Start Node-RED serverOpen your terminal. Navigate to your Node-RED folder and type node red.
Step 3: Import project file to Node-REDGo to http://localhost:1880 in your browser. Click the menu in the top right corner and choose import > clipboard.
Double click the Bean LED node and click on the pen to edit the Bean settings. Update the name to be the name of your Bean. It is important you write the exact name as it’s the only way for Node-RED to find and connect to the correct Bean.
Double click in one Telegram node, choose “add new telegram bot ” and click on the pen to edit the Telegram settings to connect to the Telegram Bot API. You need to configure all Telegram's nodes with this bot.
- Bot-Name: is the name of your Telegram bot.
- Token: is the token you get from BotFather when you create your bot.
- Users: list of allowed users (without [])
- ChatIds: For getting this, you can connect a node telegram to two debug nodes:
Then, send a message to the bot and in one output you get the chatId (without []).
Step 6: DeployClick deploy in the top right corner and you’re done!
Comments
Please log in or sign up to comment.