Telegram Notifications
Telegram is a free & open-source messenger.
This article describes Telegram configuration for CAS when operating your own CAS server to receive notifications from CAS regarding transactions and other events relevant to your BATM operation.
Server: Notifications can be delivered via Telegram.
Extensions: You can talk to extensions via Telegram.
To use Telegram as a notification method, you must build the extension and load it in CAS.
Extensions are only supported by the GB official Github channels.
Example compilation instructions (below): Compiling from Source
Once the extension is loaded, you can proceed to use the instructions that follow.
1. Create a new bot in Telegram:
Search for the "BotFather" in the Telegram GUI:
Create a name for your new bot.
In this example, we'll use "gb_kb_example_bot".
NOTE: the bot name MUST end with the word "bot"!
In a message to BotFather, type:
/start
/newbot [name of your bot]
Example:
/start
/newbot gb_kb_example_bot
The BotFather will now ask you to invent a "username".
Create a descriptive name for your bot ("ExampleBot").
Save the received HTTP API token.
Example conversation:
Configure CAS from the CLI to use the new bot you created:
Create a Telegram configuration file for CAS:
sudo touch /batm/config/telegram
sudo nano /batm/config/telegram
Enter the following data:
telegram_bot_username=your_unique_bot_name
telegram_bot_token=APIKey:APIToken
The resulting file will look like this (using our example):
Save the file (type Ctrl+x and save when asked).
Restart CAS:
sudo /batm/batm-manage stop all
sudo /batm/batm-manage start all
The bot won't work until the CAS Admin service is running!
Setup CAS to use your new Bot:
Identify your Telegram User ID for CAS:
Open Telegram and locate your new bot:
Click on the start button:
Receive your Telegram User ID in a reply:
This number is your "Telegram User ID" for CAS notification rules!
Add your Telegram User ID to the appropriate CAS Person:
Be sure to SAVE the setting (SUBMIT).
Configure your Notification Policy:
Create a Notification Rule:
Set the Action Parameter to the same Telegram User ID previously identified.
Save the Policy/Rule and test using a BATM.
Troubleshooting:
You can search the master log for the TelegramBot string. You should see the TelegramBot registering command.
If you have carefully followed the above steps, and the test event does not trigger a notification properly, please Create a Support Ticket .
Compiling from source:
Test to see if the extension already exists:
ls /batm/app/master/extensions/server_extensions_examples*.jar
If the extension already exists, building it from source is optional.
REPOSITORIES: GitHub, Java, and source code compilation is beyond the scope of this article and General Bytes' support.
This article is intended for advanced Operators. If you are unfamiliar with Java, website development, or addressing ports via IP, then STOP !
Overview:
Clone the GB repository.
Compile the CAS extension (JAR).
Copy that JAR to the correct destination in your CAS host.
Test it.
1. Clone the GB repository:
Install Git:
sudo apt update && sudo apt install git
Clone the GB repository.
These instructions assume you’ll use your home directory. If you choose to clone into another, different directory, then adjust this next command to change to it instead:
cd $HOME
Now clone the batm_public
repository:
git clone https://github.com/GENERALBYTESCOM/batm_public
If you’ve previously cloned the repository (e.g. for the SSH wallet tunnel), the server_extensions_examples directory (and contents) may not exist. Fix that to continue.
You’ll have to either:
reset the current repository clone using:
git reset --hard && git clean -f -d
, orclone the latest version into a different directory (and adjust the commands to reflect that).
2. Compile the CAS extension (JAR).
Compilation currently requires OpenJDK version 8.
sudo apt update && sudo apt install openjdk-8-jdk openjdk-8-jre
Build the batm_server_extensions_examples.jar extension with:
cd $HOME/batm_public/currencies
../gradlew clean build
cd ../server_extensions_api
../gradlew clean build
cd ../server_extensions_examples
../gradlew clean build
After each build (above), you should see “BUILD SUCCESSFUL”:
You have succeeded in building the API jar from source code. Now copy the file to CAS.
3. Copy that JAR to the correct folder in your CAS host.
You’ve prepared CAS (in step 1) to look for an extension in a specific place. Put it in it’s place.
The default compiled location of the JAR (using above instructions) is:
$HOME/batm_public/server_extensions_examples/build/libs/batm_server_extensions_examples.jar
We want to copy it to this folder:
/batm/app/master/extensions/
Use this command to copy it:
sudo cp $HOME/batm_public/server_extensions_examples/build/libs/batm_server_extensions_examples.jar /batm/app/master/extensions/batm_server_extensions_examples.jar
Modify file ownership:
sudo chown batmmaster:batmmaster /batm/app/master/extensions/batm_server_extensions_examples.jar
Restart CAS to implement the new extension.
sudo /batm/batm-manage stop all
sudo /batm/batm-manage start all
Success. The JAR is now in the proper place, and CAS will load it when started.
Related content
Copyright © 2020-2024 General Bytes USA LLC