Skip to content
BotServBotServ
MatterbridgeBotBridgeCross-PlatformTelegramDiscordMatrixIRCSelf-Hosting

Bot-Crossing: Connect Bots Across Platforms

Bridge AI bots and messages between Telegram, Discord, Matrix, IRC and more with Matterbridge setup, use cases and tips.

S

schutzgeist

4 min read
Bot-Crossing: Connect Bots Across Platforms

Bot-Crossing: Connecting Bots Across Platforms with Matterbridge

What this article covers

  • What “bot-crossing” is: bridging messages and AI bots across chat platforms.
  • Matterbridge as the standard tool and which platforms it supports.
  • Setup with Docker and example configuration.
  • Use case: one AI backend, multiple chat frontends.
  • Limitations and pitfalls of bridge solutions.

Introduction

Your community lives on Discord, your family uses Telegram, your club meets on Matrix, and you want your AI bot to respond everywhere? That’s bot-crossing: a bridge between platforms that synchronizes messages and makes your bot available across all of them.

The standard tool for this is Matterbridge, an open-source relay that connects over 20 platforms: IRC, Discord, Telegram, Matrix, Slack, Mattermost, Rocket.Chat, XMPP, WhatsApp, and more. It’s a Node.js application with a simple TOML configuration, no programming required.

Common use cases

  • AI bot everywhere: One Ollama backend, users ask on Discord, Telegram, or Matrix, the bridge routes all requests.
  • Community fusion: A Discord community and Telegram group share a single channel.
  • Migration: Move an old IRC community to Matrix without losing the IRC regulars.
  • Redundant alerts: Critical notifications go to two platforms simultaneously.
  • Message sync: Mirror messages from the “old” chat into the new one.

How Matterbridge works

Discord ──┐
          │
Telegram ─┼── Matterbridge (Relay) ──► other side
          │
Matrix ───┘

Matterbridge connects “gateways”: you define which channels on which platforms are linked together. A message in channel A gets mirrored to connected channels on other platforms, with bot names and source attribution.

Installation: Docker

services:
  matterbridge:
    image: 42wim/matterbridge:latest
    volumes:
      - ./matterbridge.toml:/etc/matterbridge/matterbridge.toml
      - ./data:/data
    restart: always

matterbridge.toml: Example with Telegram ↔ Discord ↔ IRC:

[discord.mybot]
Token = "your-discord-bot-token"
Server = "YOUR_DISCORD_SERVER_ID"
AutoWebhooks = true

[telegram.mybot]
Token = "your-telegram-bot-token"

[irc.mybot]
Server = "irc.libera.chat:6697"
Nick = "crossbot"
UseTLS = true
SkipTLSVerify = false

[[gateway]]
name = "my-gateway"
enable = true

[[gateway.inout]]
account = "discord.mybot"
channel = "general"

[[gateway.inout]]
account = "telegram.mybot"
channel = "-1001234567890"

[[gateway.inout]]
account = "irc.mybot"
channel = "#my-channel"

Run docker compose up -d: messages now flow across all three channels.

The AI-crossing use case: one Ollama backend

The real power move: your bot runs on one platform and answers, then the bridge distributes the response everywhere.

User on Telegram: "!ai what is Ollama?"
    │
    ▼
Matterbridge mirrors to Discord
    │
    ▼
Discord bot (with Ollama) sees "!ai ..." → responds
    │
    ▼
Response gets mirrored back to Telegram

Alternatively: embed AI logic directly in the bridge loop. Matterbridge can be used as a library, or you can write your own relay service that intercepts messages, sends them to Ollama, and posts the response across all connected platforms:

# Concept: message from any platform → Ollama → response everywhere
def on_message(platform, user, text):
    if text.startswith("!ai"):
        answer = ollama.chat(prompt=text[3:])
        broadcast_to_all_platforms(answer)   # via Matterbridge API or custom clients

Key configuration tips

  • Bot names: Configure RemoteNickFormat so messages from other platforms are recognizable (e.g., [TG] Max: Hello).
  • Nick mapping: Use PreserveMessageIds and IgnoreUsers for bots to prevent loops.
  • Webhooks vs. bots: Discord supports webhooks for prettier bridges (AutoWebhooks=true).
  • Selective channels: Use [[gateway.in]] vs [[gateway.out]] for one-way bridges (alerts out only, not in).

Limitations and pitfalls

  • Feature loss: Threads, reactions, edits, and attachments don’t translate perfectly between platforms. Plain text is reliable, everything else is “best effort.”
  • Loop risk: Two bridges mirroring each other creates an endless loop. Set IgnoreNicks/IgnoreUsers for bot accounts.
  • Rate limits: Telegram and Discord have API limits. Heavy cross-traffic can get throttled.
  • Moderation: Spam on one platform spreads to all. You need moderation everywhere.
  • Ambiguity: Users don’t always know which platform the other person is using. Name prefixes help clarify.

Alternatives and complements

  • Mautrix bridges: Specialized for Matrix ↔ WhatsApp/Telegram/Signal (puppets, E2EE), see Matrix bots.
  • n8n: For workflow crossing (event-based, not live chat), see n8n.
  • Custom backend: Often better for AI bots. Build a central backend with platform adapters instead of a generic bridge.

Further reading

Key takeaways:

  • Bot-crossing bridges messages between chat platforms: Matterbridge is the standard tool.
  • TOML config, no programming needed, supports ~20 platforms.
  • AI use case: one Ollama backend, all chat frontends reachable via bridge.
  • Feature loss with threads/attachments, loop risks, rate limits to watch.
  • For serious AI bots, a custom multi-adapter backend is cleaner than a generic bridge.

FAQ

What is bot-crossing?

Mirroring messages between chat platforms (Telegram↔Discord↔IRC…) or making an AI bot available on multiple platforms simultaneously. Matterbridge is the classic tool for this.

Which platforms does Matterbridge support?

IRC, Discord, Telegram, Matrix, Slack, Mattermost, Rocket.Chat, XMPP, WhatsApp, Zulip, MS Teams, and more, over 20 protocols. See the full list in the GitHub repo.

AI bot across multiple platforms?

Yes, one Ollama backend with Matterbridge as transport. Messages with an !ai prefix get mirrored, the bot responds, the bridge distributes the answer. For cleaner control, use a custom multi-adapter backend.

What’s the loop risk?

If two bridges mirror each other or a bot sees its own message, you get an endless loop. Set IgnoreUsers/IgnoreNicks on bot accounts and use only one bridge per channel pair.

Do features get lost?

Yes: threads, reactions, edits, embeds, and attachments only partially translate. Plain text and images are reliable; for complex features, write custom code.

Matterbridge or custom backend?

Matterbridge for quick chat bridging without code. A custom multi-adapter backend when you need AI logic, context management, and platform-specific features. More work, but full control.

Sources and further reading

Back to Blog
Share:

Related Posts