Matrix-Telegram bridge: setting up mautrix-telegram

Updated

mautrix-telegram connects your Matrix homeserver to Telegram, so Telegram chats show up as Matrix rooms and replies flow both ways. You run it as a Docker container next to Synapse, give it your own Telegram API keys, register it as an application service, then log in from a chat with the bridge bot. Since v26.04 the bridge is a Go rewrite on the shared “megabridge” (bridgev2) architecture, so older Python-era guides no longer match.

At a glance

Item Current answer
Project mautrix-telegram, AGPL-3.0, written in Go
Latest release (checked 2026-12-02) v26.11, published November 16 on the GitHub releases page
Docker image dock.mau.dev/mautrix/telegram:<version>
Default bridge port 29317
Homeserver change Add the registration file to app_service_config_files in Synapse
Telegram side An app at my.telegram.org for api_id and api_hash
Login options Phone number plus code, QR code, or bot token
Database PostgreSQL (v16 or newer per the docs) or SQLite for small setups

What bridging does: puppeting vs relay

A bridge is an application service. The homeserver lets it control a whole namespace of user IDs, pushes events to it over HTTP, and skips rate limits for it. mautrix-telegram uses that to create “ghost” Matrix users for every Telegram contact and a “portal” room for every Telegram chat.

There are two ways to use it:

  • Puppeting. You log in to the bridge with your own Telegram account. Messages you send in Matrix go out as you on Telegram, and your chat list syncs into Matrix. Add double puppeting and messages you send from the Telegram phone app also appear from your real Matrix account instead of a ghost.
  • Relay. One login (ideally a Telegram bot on a dedicated Matrix account) is designated as the relay for a room. Matrix users who have not logged in have their messages sent through it, with their name prefixed. This suits a community room where only some people use Telegram.

Most personal setups use puppeting. Relay mode is for shared rooms.

Prerequisites

  • A working Matrix homeserver that supports application services, such as Synapse, and access to edit its config. If you do not have one yet, start with running your own Matrix server.
  • Docker with Compose on the same machine or network as the homeserver. A small VPS is enough; see choosing a VPS for self-hosting.
  • A database. The Go setup page lists PostgreSQL v16 or higher; the initial config page says SQLite is fine for small instances. Never point the bridge at Synapse’s database. A separate database in the same Postgres instance is fine.
  • Telegram API keys. Sign in at my.telegram.org with an active Telegram account, open “API development tools” and fill in the form. Telegram allows one api_id per phone number. The mautrix docs note the form often returns a generic ERROR; changing the app name (avoid the word “telegram”) usually helps. The keys do not grant access to any account; they only let the bridge talk to the API.
  • An established Telegram account created in an official app. Registration from third-party clients stopped in 2023, and the bridge docs warn that brand-new accounts logging in through third-party clients look suspicious and can get banned.

Docker setup

These steps follow the official Docker guide. Create a directory and stay in it, because every command mounts the current directory as /data and the image changes that directory’s owner to UID 1337.

mkdir mautrix-telegram && cd mautrix-telegram
docker pull dock.mau.dev/mautrix/telegram:v26.11

Pin a release tag. The docs point out that :latest follows the latest commit, not the latest release.

Run the container once so it writes a config.yaml:

docker run --rm -v `pwd`:/data:z dock.mau.dev/mautrix/telegram:v26.11

Edit the config

The config is self-documenting, and the bridge rewrites it on startup to keep it current. The fields you must change, shown with the values a typical Docker setup needs:

network:
    api_id: CHANGE_ME
    api_hash: CHANGE_ME

bridge:
    permissions:
        "*": relay
        "example.org": user
        "@admin:example.org": admin

database:
    type: postgres
    uri: postgres://user:password@host/database?sslmode=disable

homeserver:
    address: http://synapse:8008
    domain: example.org

appservice:
    address: http://mautrix-telegram:29317
    hostname: 0.0.0.0
    port: 29317

Key points from the docs:

  • homeserver.domain must equal Synapse’s server_name, not the hostname of a reverse proxy.
  • Inside Docker, localhost points at the container itself. Use container names (synapse, mautrix-telegram) on a shared Docker network, and set appservice.hostname to 0.0.0.0 so the bridge listens on that network.
  • For SQLite, set type to sqlite3-fk-wal and use a URI of the form file:<path>?_txlock=immediate, with the path inside /data.
  • Permission levels are relay, commands, user and admin. Give user only to your own domain.

Run the same docker run --rm command again. This time it generates registration.yaml.

Register the appservice in Synapse

Copy registration.yaml somewhere Synapse can read it (inside Synapse’s container if it runs in Docker), then list it in homeserver.yaml:

app_service_config_files:
- /data/mautrix-telegram-registration.yaml

Restart Synapse. You must restart it again every time you regenerate the registration. If Synapse refuses to start, the YAML is malformed or the path is wrong or unreadable; its logs say which. The registration must be regenerated whenever you change homeserver.domain, appservice.address, appservice.id, the bot username, the tokens, the username template, appservice.ephemeral_events or encryption.appservice.

Other homeservers differ: Continuwuity and other Conduit-based servers register appservices with a register_appservice command in the admin room instead of a config file.

Run it with Compose

The docs’ Compose file, with the bridge name, port and version filled in:

version: "3.7"

services:
  mautrix-telegram:
    container_name: mautrix-telegram
    image: dock.mau.dev/mautrix/telegram:v26.11
    restart: unless-stopped
    volumes:
    - .:/data

    # If you put the service above in the same docker-compose as the homeserver,
    # ignore the parts below. Otherwise, see below for configuring networking.

    # If synapse is running outside of docker, you'll need to expose the port.
    # Note that in most cases you should either run everything inside docker
    # or everything outside docker, rather than mixing docker things with
    # non-docker things.
    #ports:
    #- "29317:29317"
    # You'll also probably want this so the bridge can reach Synapse directly
    # using something like `http://host.docker.internal:8008` as the address:
    #extra_hosts:
    #- "host.docker.internal:host-gateway"

    # If synapse is in a different network, then add this container to that network.
    #networks:
    #- synapsenet
# This is also a part of the networks thing above
#networks:
#  synapsenet:
#    external:
#      name: synapsenet

Start it with docker compose up -d. If Synapse lives in the same Compose project, networking works without the commented sections. If you add the bridge to an existing Compose file, mount ./mautrix-telegram:/data instead of ..

Log in to Telegram

Start a private chat with the bridge bot, @telegrambot:example.org by default. In that management room, commands need no prefix. Then pick one method:

  • Phone code: send login phone +123456789 with your number in international format. Telegram sends a code to another logged-in Telegram client (not SMS), and the bot asks you to paste it. If you use a two-step verification password, the bot asks for that too.
  • QR code: in the Telegram phone app, open Settings, then Devices, then “Link Desktop Device”. Send login qr to the bot and scan the code.

After a successful login the bridge creates portal rooms for your chats, depending on your backfill and sync settings. Backfill cannot be redone for rooms that already exist, so set the backfill options before you log in. The same applies to end-to-bridge encryption (see below).

Relay mode

Relay mode lets Matrix users without their own Telegram login talk in a bridged group.

  1. Set bridge.relay.enabled to true in the config and make sure the people you invite have at least the relay permission level.
  2. Create a bot with Telegram’s @BotFather (/newbot) and copy its token. Keep it secret: anyone with the token controls the bot.
  3. From a dedicated Matrix account (not your main one), log in to the bridge with login bot <token>.
  4. In each portal room, run !tg set-relay. Add !tg set-pl 100 if you need to change room settings and invite others.

Things to know before relying on it:

  • By default only bridge admins can set a relay (admin_only: true). The default_relays list lets anyone use a shared relay login.
  • Telegram bots run in privacy mode by default and only see commands and replies in groups. Bots added as group admins receive all messages; otherwise disable privacy with /setprivacy in @BotFather and re-add the bot.
  • Reactions from relayed users are not bridged.
  • Small Telegram groups (minigroups) cannot share one portal between several Matrix users. Upgrade the group to a supergroup with !tg upgrade if you need a shared room.
  • The old Python-style relaybot is gone; the generic relay mode replaces it.

For other kinds of automation in your rooms, see Matrix bots.

Common errors

  • The bot ignores your invite. Synapse is not reaching the bridge. Check appservice.address and the port, search Synapse’s log for transactions, and remember only the configured bot username accepts invites. Synapse also backs off after the bridge was down for a while.
  • The bot joins but never answers. In rooms other than the management room, commands need the !tg prefix. Also check you have not ignored the bot in your client.
  • as_token was not accepted. The registration is not listed in Synapse’s config, Synapse was not restarted, or the tokens in config.yaml and the registration differ.
  • Token accepted but /register rejected. Usually homeserver.domain does not match server_name, or you changed the bot username without regenerating the registration.
  • Appservice ping failure. The homeserver cannot reach the url in the registration, which is copied from appservice.address. Fix the address and regenerate.
  • Configuration error: <field> not configured. An example value is still in place. Set a real one.
  • ForeignTablesFound. The bridge is pointed at a database another program uses. Give it its own database.
  • Upgrading from the Python bridge fails. v26.10 removed the legacy migration. Upgrade to a release between v26.04 and v26.09 first, then move on.

Updates, backups and exposure

The bridge does not need to face the internet. Keep port 29317 on the internal Docker network or bound to the host, and only publish it when the homeserver runs elsewhere. The config notes the bridge has no built-in TLS, so a bridge on a different machine needs a reverse proxy with HTTPS or a private link such as WireGuard. Your Synapse reverse proxy keeps handling TLS for clients.

To update, change the tag in the Compose file, then run docker compose pull and docker compose up -d; docker compose restart does not pick up a pulled image. The changelog shows releases arriving roughly monthly. Read it before each upgrade.

Back up the bridge directory (config.yaml, the registration and, with SQLite, the database file) and the bridge’s Postgres database if you use one. The database holds your Telegram session, so treat backups as sensitive.

Privacy caveats

  • Telegram regular chats are not end-to-end encrypted, and the bridge does not support Telegram secret chats. Telegram sees everything you send through it, as it would with any Telegram client.
  • Anyone with admin access to the server can read bridged messages. In unencrypted Matrix rooms they sit in plaintext in the Synapse database. Enabling encryption.allow and encryption.default (end-to-bridge encryption) protects the Matrix side, but the bridge itself must see plaintext to forward messages.
  • A multi-user bridge shares ghost users between everyone who uses it. The contact_names and contact_avatars options (personal names and avatars from one user’s contact list) are off by default; leave them off unless the bridge has a single user.
  • Relay mode sends Matrix users’ messages and display names to Telegram, including people who never chose to use Telegram. Tell your room.
  • Public instances run by third parties (the docs list Beeper, t2bot.io and tchncs.de) see your messages and session. Self-hosting keeps that on infrastructure you control, which is the main reason to do it. If you do not already run a homeserver, a public instance is the simpler choice.

More Matrix guides are on the Matrix hub.

Frequently asked questions

Is mautrix-telegram still a Python project?
No. Version v26.04 rewrote the bridge in Go on the shared bridgev2 (megabridge) architecture. The last Python code lives in the python-final tag of the repository, and some public instances still run the legacy Python bridge.
Do the Telegram API keys give someone access to my account?
No. The mautrix docs say the api_id and api_hash only let the bridge connect to the Telegram API. You still log in to your account separately with bridge commands, and the keys can be used to log in to any account.
Can I log in to the bridge without a Telegram app?
Not with a phone number. Telegram does not send the login code by SMS, so you need an official Telegram client already logged in. You can also log in with a QR code from the phone app, or with a bot token for relay use.
Are bridged Telegram chats end-to-end encrypted?
No. Normal Telegram chats are not end-to-end encrypted, and the bridge does not support Telegram secret chats. End-to-bridge encryption only protects the Matrix side between your client and the bridge.
How do I upgrade from the old Python bridge?
Upgrade in place from v0.15.3 or later to a version between v26.04 and v26.09 first, because v26.10 removed the legacy migration code. Back up the database and config before you start, then check the config after the upgrade.

Sources, checked December 2, 2026

  1. mautrix/telegram repository (README)
  2. mautrix-telegram CHANGELOG
  3. mautrix-telegram releases
  4. mautrix-telegram ROADMAP
  5. mautrix-telegram docs index (public instances)
  6. Bridge setup with Docker (mautrix docs)
  7. Go bridge setup (mautrix docs)
  8. Initial bridge config (mautrix docs)
  9. mautrix-telegram example config
  10. Registering appservices (mautrix docs)
  11. mautrix-telegram authentication
  12. Relay mode (mautrix docs)
  13. Troubleshooting (mautrix docs)
  14. End-to-bridge encryption (mautrix docs)
  15. Double puppeting (mautrix docs)
  16. Synapse: Registering an Application Service
  17. Telegram: Obtaining api_id
  18. Telegram Bot Features (BotFather, privacy mode)

More in Matrix