This is an old revision of the document!
Matrix Telegram Bridge
The Mautrix Telegram bridge is currently the best (only?) option. More info here.
Create subfolder and Python venv inside (see PIP):
su - conduwuit mkdir mautrix-telegram cd mautrix-telegram # Enable PIP like in the link above # - create ~/.config/pip/pip.conf # - add ~/.local/bin to the .bashrc python -m venv . # Note the dot at the end! source ./bin/activate # Now flip include-system-site-packages = true in pyvenv.cfg # Install: pip install --upgrade mautrix-telegram[all]
You need to create API keys to connect to Telegram. Go to this page and Grab the example config file here, save it as config.yaml in the /data/conduwuit/ folder and create a link to the mautrix-telegram folder and customize it to your needs:
wget -O /data/conduwuit/mautrix-telegram-config.yaml mv /data/daemons/conduwuit/mautrix-telegram/config.yaml /data/conduwuit/mautrix-telegram-config.yaml
This file is huge, here are the most relevant changes needed:
- config.yaml
address: https://chat.mydomain.com domain: chat.mydomain.com verify_ssl: true database: sqlite:/data/conduwuit/mautrix-telegram.db # place the database into the /data/conduwuit folder telegram: # Get your own API keys at https://my.telegram.org/apps api_id: << put your id here >> api_hash: << put your hash >> # (Optional) Create your own bot at https://t.me/BotFather bot_token: disabled permissions: "*": "relaybot" # non-local users can only see messages "chat.mydomain.com": "full" # full access to all local users "@myself:chat.mydomain.com": "admin" # who can admin the bot encryption: # Whether to enable encryption at all. If false, the bridge will not function in encrypted rooms. allow: true + double puppeting
More details on configuration can be found here.
I choose to use SQLite as database because i only have a few users and don't want to spin a PostreSQL instance for that.
At this point you need to register the bridge:
python -m mautrix_telegram -g -c /data/conduwuit/mautrix-telegram-config.yaml
This step will create a registration.yaml file that you need to perform the registration of the bridge as an appservice in Conduwuit. Conduwuit is different from Synapse (the most common Matrix server) because the appservice must be registered from the admin chat with the following command:
!admin appservices register << shift+enter >> ``` << shift+enter >> [ ... copy here the content of registration.yaml ... ] ``` << enter >>
When you see « shift enter » you need to press those two keys in order to create a new line in the same command. The three ``` (backthicks) are the markdown token to create a code block. The « autogenrated » are secret strings found in the registration.yaml file.
The chat should reply with a message like:
Appservice registered with ID: telegram
More details on registering the appservice can be found here.
You need to create the telegrambot user, again from the admin chat:
!admin users create-user telegrambot
Good! Now you can run the bridge:
python -m mautrix_telegram -c /data/conduwuit/mautrix-telegram-config.yaml
If all is well, your bridge should be up and running now.
To login into telegram you need to:
- Start a chat with telegrambot:chat.mydomain.com
- type “login”
- when prompted, type your telegram registered phone number with country code
- when prompted, type the code you received in telegram to authorize the login
- when prompted, type your 2FA password (if enabled in telegram)
You will start seeing your telegram chats appear in Matrix now! It takes time, even hours, and also most chats will only appear the first time the other person messages you.
Note: Telegram does not allow registration from third party clients, so to register a new telegram account, you must use Telegram official app.
General documentation on the Telegram bot can be found here.
To manage animated sticker here