# Avalanche | Telegram BOT
### Telegram
- [ ] Creating **Telegram Bot**
* Access **Telegram** ➜ .
* Search: **BotFather**.
* *Click* “**Start**” to activate the BotFather bot.
* Choose the command **/newbot** and *Click*.
* Choose a **name** for your bot. Example: *fujitestavalanche*.
* Choose a **username** for your bot. Example: *fujitestavalanche_bot*.
> You will receive a message with a link to your bot *t.me/nameyourbot*.
> After giving your bot *username*, your **TOKEN** will be available as noted below:

> **Note**: Copy the alphanumeric code of your **TOKEN** , as we will use it later!
> **Note** that **TOKEN** is the code right after “**HTTP API**:”.
* Start communicating with our bot by entering the name of your bot in the *search tab* and *choose* it. Example: *fujitestavalanche*.
> 
* Click on the “**Start**” button and you will be subscribed to your bot.
* Type “**`/ start`**”.
- [ ] Obtain the **CHAT ID** (*chat ID of the bot*):
> Two parameters: **TOKEN** and **CHAT ID** — are mandatory for creating the script for the real-time alert system of your Avalanche Network node.
> We must remember that we already have a *TOKEN*.
* Access the VM/VPS that supports your Avalanche network node.
> First install the “**jq**” utility, set your **TOKEN** variable and, using the curl command.
* Obtain your **chat ID** as shown below:
```
sudo apt-get install jq -y
TOKEN=<insert your token>
curl -s https://api.telegram.org/bot$TOKEN/getUpdates | jq .result[0].message.chat.id
```
:::warning
:bulb: *Copy & Paste — each line of code and “Enter”, successively, line by line, until the last command line, in the SSH Web session of your VPS.*
> If *CHAT_ID is not available*, it's okay to type “`/ start`” three to four times, in the same way, re-enter the command line `curl -s https://api.telegram.org/bot$TOKEN/getUpdates | jq .result [0] .message.chat.id` until the CHAT_ID code appears.
:::
#### Telegram | Avalanchego Monitoring Script:
The Avalanchego monitoring script, which includes the real-time alert system of your Avalanche network node, performs *three fundamental checks* every minute, as shown below:
* If the avalanche process is working;
* If the avalanche process is healthy; and
* CPU usage (the default limit is 40%).
Our Avalanchego monitoring script has *two mandatory* and *two optional parameters*, which are:
* Mandatory are *TOKEN* and *CHAT ID*.
* Optional are *CPU* and *IP limit*.
- [ ] **Avalanchego Monitoring Script** Installation:
```
cd
sudo apt-get install git
git clone https://github.com/burcusan/telegram-monitor-scripts.git
cd telegram-monitor-scripts
./install_avax_monitor.sh -t insert_here_the_code_of_your_token -c insert_here_the_code_of_your_token_CHAT_ID
sed -i 's/health.getLiveness/health.health/g' check_avalanchego_status.sh
```
:::warning
:bulb: *Copy & Paste — each line of code and “Enter”, successively, line by line, until the last command line, in the SSH Web session of your VPS.*
:::
- [ ] **Test** to verify that your script is working correctly:
```
./check_avalanchego_status.sh > check_avalanchego_status.logcat check_avalanchego_status.log
```
```
./check_avalanchego_status.sh test
```
> *In this script we are using the default parameters for a `40% CPU limit` and API call IP is `127.0.0.1`.*
:::success
:point_right: If the script has been installed correctly, the test message will be sent to your Telegram bot as noted below:
```
Mon Sep 26 07:52:31 UTC 2022 | [TEST] [TEST] | Avalanchego Fuji Node TEST Message...!!!
```
:::
- [ ] **Check** the test message received by your Telegram bot:

#### Canceling Alert Messages:
:::info
:point_right: If you no longer want to receive alerts via your Telegram bot, just remove a line from the script in your **`crontab`** file. Edit it via **`crontab -e`** and remove or comment (put # at the beginning of the line) the related line as shown below:
```
#* * * * * /home/username/telegram-monitor-scripts/check_avalanchego_status.sh > /home/username/telegram-monitor-scripts/check_avalanchego_status.log 2>&1
```
:::