Table of Contents

B) Matrix Telegram Bridge

Telegram is the well known chat app which started as the main competitor to Whatsapp and it's finally gaining some traction. Most known for it's piracy and porn angles, it's getting more and more popular to replace Whatsapp itself also for private chats.

Telegram can be easily and fully bridged with Matrix using the Mautrix-Telegram bridge here.

At the time of writing this page, the full rewrite in Go of the bridge is the way to go and the older python-based bridge is now officially deprecated.

Installation

I asusme you are installing the bridge directly together with the Matrix server, as user conduwuit.

Create a subfolder to install the bridge:

su - conduwuit
mkdir mautrix-telegram
cd mautrix-telegram
wget -O mautrix-telegram.zip 'https://mau.dev/mautrix/telegram/-/jobs/artifacts/main/download?job=build%20amd64' 
unzip mautrix-telegram.zip
chmod +x mautrix-telegram

Telegram Setup

First of all, you cannot create a new telegram account from the bridge, you need to do so from the official telegram app, it's the one and only way.

Now, assuming you have a Telegramn account, you need to create API keys to connect to Telegram. Go to this page and login with your phone number and the code that will be delivered to your telegram account.

From the page that pops up, generate and take note of api_id and api_hash as you will need to configure the bot. You should also give a name like MatrixBot or whatever you like.

Bridge setup

Let the bridge generate the basic configuration file, and move it to the /data/conduwuit folder:

./mautrix-telegram -e
mv config.yaml /data/conduwuit/mautrix-telegram-config.yaml

Now edit it. You should take a good look at it, the following are only hints and pointers to what you aboslutely need to change:

network:
    # This is very important to have usernames instead of phone numbers!
    displayname_template: "{{or .FullName .BusinessName .PushName .Phone}} (Tg)" 
    
database:
    type: sqlite3-fk-wal
    uri: file:/data/conduwuit/mautrix-telegram.db?_txlock=immediate
 
homeserver:
    address: https://chat.mydomain.com
    domain: chat.mydomain.com

appservice:
    hostname: 127.0.0.1
  
permissions: # this is probably not needed, but anyway...
  "*": "relay"                      # non-local users can only see messages
  "chat.mydomain.com": "admin"          # full access to all local users
  "@myself:chat.mydomain.com": "admin" # who can admin the bot

backfill:
    enabled: true  # to populate chats with older messages
    
    encryption:
    # Whether to enable encryption at all. If false, the bridge will not function in encrypted rooms.
    allow: true

double_puppet:
    # Servers to always allow double puppeting from.
    # This is only for other servers and should NOT contain the server the bridge is on.
    servers:
        anotherserver.example.org: https://matrix.anotherserver.example.org
    # Whether to allow client API URL discovery for other servers. When using this option,
    # users on other servers can use double puppeting even if their server URLs aren't
    # explicitly added to the servers map above.
    allow_discovery: false
    # Shared secrets for automatic double puppeting.
    # See https://docs.mau.fi/bridges/general/double-puppeting.html for instructions.
    secrets:
        chat.mydomain.com: as_token:<< here the double-puppet token >>
        
logging:
      filename: /var/log/conduwuit/mautrix-telegram.log

Note that backfill is disabled by default, you need to enable it to see older messages. Also note that messages cannot be backfilled for already created rooms, so don't forget to enable backfill before the first start!

Since my server will have just a few users, i decided to use an SQLite database.

Bridge Registration

At this point you need to register the bridge with the Matrix server.

First of all, generate the registration.yaml file:

./mautrix-telegram -c  /data/conduwuit/mautrix-telegram-config.yaml -g

Then perform the actual appservice registration, see here.

Usage

The whatsappbot user should have been created automatically.

Good! Now you can run the bridge:

/data/daemon/mautrix-telegram/mautrix-telegram -c /data/conduwuit/mautrix-telegram-config.yaml

If all is well, your bridge should be up and running now.

Login

To login into telegram you need to:

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.

General documentation on the Telegram bot can be found here.

To manage animated sticker here

Autostart

Since i use OpenRC, simply drop the following script to /etc/init.d:

/etc/init.d/conduwuit-telegram
#!/sbin/openrc-run
# Copyright 2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

name="conduwuit telegram bridge"
description="Conduwuit telegram Matrix Bridge"
pidfile="/run/conduwuit-telegram.pid"
command_background=true
command="/data/daemons/conduwuit/mautrix-telegram/mautrix-telegram"
command_args="/data/conduwuit/mautrix-telegram-config.yaml"
command_user="conduwuit:conduwuit"
output_log="/var/log/conduwuit/conduwuit-telegram.log"
output_err="/var/log/conduwuit/conduwuit-telegram.log"

start_pre() {
        cd /data/daemons/conduwuit/mautrix-telegram
}

depend() {
        need net
}

Make it executable and add to the proper runlevel:

chmod +x /etc/init.d/conduwuit-telegram
rc-update add conduwuit-telegram default