Telegram is an (encrypted) messenger service which also offers an API. This makes it ideal for bots and automation. Here it is shown hot to set up telegram-cli on your Pi.

Get a shell on your RasPi, I prefer to do this over SSH. You can also plug your RasPi to a screen and ann a keyboard.

Build

sudo apt-get install -y git
sudo apt-get install -y libreadline-dev libconfig-dev libssl-dev lua5.2 liblua5.2-dev libevent-dev make
git clone --recursive https://github.com/vysheng/tg.git && cd tg
./configure
make
mkdir ~/bin
cp bin/telegram-cli ~/bin/

Then, add this like to your ~/.bashrc to make the binary available in your PATH:

export PATH=$HOME/bin:$PATH

Login

telegram-cli -k <your pubkey>

Get the public key from https://my.telegram.org (Manual), you have to register a new app. Save the contents to a file.

Then you have to enter the code you get per sms to your phone.

You can now use the telegram CLI.