Skip to content

Commit

Permalink
Merge pull request #541 from threefoldtech/development_telegrambot
Browse files Browse the repository at this point in the history
added node status bot guide
  • Loading branch information
khaledyoussef24 authored May 27, 2024
2 parents 8e156a0 + 104695a commit cef932c
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@
- [Ecommerce](documentation/system_administrators/advanced/ecommerce/ecommerce.md)
- [WooCommerce](documentation/system_administrators/advanced/ecommerce/woocommerce.md)
- [nopCommerce](documentation/system_administrators/advanced/ecommerce/nopcommerce.md)
- [Node Status Bot](documentation/system_administrators/advanced/node_status_bot.md)
- [ThreeFold Token](documentation/threefold_token/threefold_token.md)
- [TFT Bridges](documentation/threefold_token/tft_bridges/tft_bridges.md)
- [TFChain-Stellar Bridge](documentation/threefold_token/tft_bridges/tfchain_stellar_bridge.md)
Expand Down
3 changes: 2 additions & 1 deletion src/documentation/system_administrators/advanced/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ In this section, we delve into sophisticated topics and powerful functionalities
- [IPFS](./ipfs/ipfs_toc.md)
- [IPFS on a Full VM](./ipfs/ipfs_fullvm.md)
- [IPFS on a Micro VM](./ipfs/ipfs_microvm.md)
- [Hummingbot](./hummingbot.md)
- [AI & ML Workloads](./ai_ml_workloads.md)
- [Ecommerce](./ecommerce/ecommerce.md)
- [WooCommerce](./ecommerce/woocommerce.md)
- [nopCommerce](./ecommerce/nopcommerce.md)
- [Hummingbot](./hummingbot.md)
- [Node Status Bot](./node_status_bot.md)
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ We start by deploying a full VM on the ThreeFold Dashboard.

## Preparing the VM

We prepare the full to run Hummingbot.
We prepare the full VM to run Hummingbot.

* Update the VM
```
Expand Down
132 changes: 132 additions & 0 deletions src/documentation/system_administrators/advanced/node_status_bot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<h1> Node Status Bot </h1>

<h2>Table of Contents</h2>

- [Introduction](#introduction)
- [Prerequisites](#prerequisites)
- [Deploy a Micro VM](#deploy-a-micro-vm)
- [Network Choice](#network-choice)
- [Create a Telegram Bot](#create-a-telegram-bot)
- [Prepare the VM](#prepare-the-vm)
- [Set the Bot](#set-the-bot)
- [Start the Bot](#start-the-bot)
- [Set Zinit](#set-zinit)
- [Questions and Feedback](#questions-and-feedback)

---

## Introduction

We show how to deploy the [Telegram Node Status bot](https://github.com/threefoldfoundation/node-status-bot) on a micro VM running on the ThreeFold Grid.

The Node Status bot provides realtime status updates and alerts on status changes for nodes on the ThreeFold Grid. You can find an [instance live on Telegram](https://t.me/tfnodestatusbot).

## Prerequisites

To run the bot, you need to have a TFChain account activated with a twin. For this, you can simply create an account on the ThreeFold Dashboard.

- [A TFChain account](../../../dashboard/wallet_connector.md)
- TFT in your TFChain account
- [Buy TFT](../../../threefold_token/buy_sell_tft/buy_sell_tft.md)
- [Send TFT to TFChain](../../../threefold_token/tft_bridges/tfchain_stellar_bridge.md)

## Deploy a Micro VM

We start by deploying a micro VM on the ThreeFold Dashboard.

* On the [Threefold Dashboard](https://dashboard.grid.tf/#/), go to the [micro virtual machine deployment page](https://dashboard.test.grid.tf/#/deploy/virtual-machines/micro-virtual-machine/)
* Deploy a micro VM (Ubuntu 22.04) with the network connection of your choice
* Minimum vcores: 1vcore
* Minimum MB of RAM: 2048GB
* Minimum storage: 25GB
* After deployment, note the VM IP address
* Connect to the VM via SSH
* ```
ssh root@VM_IP_Address
```

### Network Choice

Since the bot works via an outbound connection to the Telegram servers, you do not need any public IP for it. It's thus cheaper to use either WireGuard, Planetary Network or Mycelium.

## Create a Telegram Bot

We create a Telegram bot using the [BotFather](https://t.me/BotFather).

Simply go to this link and follow the steps (`/newbot` ...). Make sure to take note of the bot token for the next steps.

## Prepare the VM

We prepare the micro VM to run the Node Status bot.

* Update the VM and install redis-server, git, nano, pip and python3-venv
```
apt update && apt install redis-server && apt install git && apt install nano && apt install pip && apt install python3.10-venv
```

## Set the Bot

Now that the VM is prepared, you can quickly set the bot.

```
git clone https://github.com/threefoldfoundation/node-status-bot.git
cd node-status-bot
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
wget https://github.com/threefoldtech/rmb-rs/releases/download/v1.0.7/rmb-peer
chmod u+x rmb-peer
```

## Start the Bot

Once the bot is set, you can start it with the following line.

```
python3 node-status-bot.py <bot_token> -s "<mnemonic>"
```

You can now go on Telegram and test the bot!

## Set Zinit

We can make sure the bot will start at any VM reboot by setting a zinit process. We set this using a simple script.

- Create a .yaml file in the zinit folder
```
nano /etc/zinit/node-status-bot.yaml
```
- The content should be the following
```
exec: /root/node-status-bot/start.sh
```
- Create a script to run the bot
```
nano start.sh
```
- The script should contain the following
```
#!/bin/bash
cd /root/node-status-bot
source venv/bin/activate
python3 node-status-bot.py <bot_token> -s "<mnemonic>" &>> /root/node-status-bot-logs
```
- Set permissions to the script
```
chmod +x start.sh
```
- Start the bot with the zinit command
```
zinit monitor node-status-bot
```
- Check if the bot is running
```
zinit status node-status-bot
```

You can then use the bot on Telegram and the Python program will restart every time the VM starts.

## Questions and Feedback

If you have any questions or feedback, please let us know by either writing a post on the [ThreeFold Forum](https://forum.threefold.io/), or by chatting with us on the [TF Grid Tester Community](https://t.me/threefoldtesting) Telegram channel.
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ For complementary information on ThreeFold grid and its cloud component, refer t
- [IPFS](./advanced/ipfs/ipfs_toc.md)
- [IPFS on a Full VM](./advanced/ipfs/ipfs_fullvm.md)
- [IPFS on a Micro VM](./advanced/ipfs/ipfs_microvm.md)
- [Hummingbot](./advanced/hummingbot.md)
- [AI & ML Workloads](./advanced/ai_ml_workloads.md)
- [Ecommerce](./advanced/ecommerce/ecommerce.md)
- [WooCommerce](./advanced/ecommerce/woocommerce.md)
- [nopCommerce](./advanced/ecommerce/nopcommerce.md)
- [Hummingbot](./advanced/hummingbot.md)
- [Node Status Bot](./advanced/node_status_bot.md)

0 comments on commit cef932c

Please sign in to comment.