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.

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


1. Create a new bot in Telegram:

Search for the "BotFather" in the Telegram GUI:

Create a name for your new bot.

NOTE: the bot name MUST end with the word "bot"!

In a message to BotFather, type:

/start
/newbot [name of your bot]
note

Example:

/start
/newbot gb_kb_example_bot

Example:

/start
/newbot gb_kb_example_bot

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

Restart CAS:

sudo /batm/batm-manage stop all
sudo /batm/batm-manage start all

Setup CAS to use your new Bot:

Identify your Telegram User ID for CAS:

  1. Open Telegram and locate your new bot:

  2. Click on the start button:

  3. 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:

Configure your Notification Policy:

  1. Create a Notification Rule:

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

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:

  1. Clone the GB repository.

  2. Compile the CAS extension (JAR).

  3. Copy that JAR to the correct destination in your CAS host.

  4. 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:

  1. reset the current repository clone using: git reset --hard && git clean -f -d , or

  2. clone 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”:

image-20240408-184238.png

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.