matrix-bridge-teams-0.1.0 is not a library.
matrix-bridge-teams
A Matrix <-> Microsoft Teams bridge written in Rust.
Maintainer: Palpo Team
Contact: chris@acroidea.com
Overview
- Rust-only implementation for Matrix <-> Microsoft Teams bridging
- Matrix appservice + Microsoft Graph API integration
- HTTP endpoints for health/status/metrics and provisioning
- Database backends: PostgreSQL, SQLite, and MySQL (feature-gated)
- Dockerfile for local build and container runtime
Repository Layout
src/: bridge implementationconfig/config.sample.yaml: sample configurationmigrations/: database migrationsDockerfile: multi-stage container build
Prerequisites
- Rust toolchain (compatible with the project; Docker build uses Rust 1.93)
- A Matrix homeserver configured for appservices
- Microsoft Teams tenant and app registration
- Database: PostgreSQL, SQLite, or MySQL
Quick Start (Local)
- Create your config file:
-
Set the required values in
config.yaml:bridge.domainauth.tenant_id,auth.client_id,auth.client_secretdatabase.url(ordatabase.conn_string/database.filename)- registration values via either:
registration.id,registration.as_token,registration.hs_token, orteams-registration.yamlnext to your config file, or- env vars (see Environment Overrides below)
-
Run:
- Verify:
Configure Microsoft Teams (Step by Step)
-
Go to https://portal.azure.com/ and create a new App Registration:
- Navigate to Azure Active Directory > App registrations > New registration
- Name: "Matrix Bridge Teams"
- Supported account types: Choose based on your needs
- Redirect URI:
http://localhost:8080/callback(for initial setup)
-
After registration, copy:
- Application (client) ID (for
auth.client_id) - Directory (tenant) ID (for
auth.tenant_id)
- Application (client) ID (for
-
Create a client secret:
- Go to Certificates & secrets > New client secret
- Copy the secret value (for
auth.client_secret)
-
Configure API permissions:
- Go to API permissions > Add a permission
- Select Microsoft Graph > Application permissions
- Add these permissions:
Chat.Read.AllorChat.ReadWrite.AllChannelMessage.Read.AllorChannelMessage.ReadWrite.AllTeam.ReadBasic.AllUser.Read.All
- Grant admin consent for your organization
-
Fill the auth section in
config.yaml:
auth:
tenant_id: "YOUR_TENANT_ID"
client_id: "YOUR_CLIENT_ID"
client_secret: "YOUR_CLIENT_SECRET"
- To bridge a specific Teams channel, collect IDs from:
- Team ID and Channel ID from the Teams URL or API
Configure Matrix / Palpo (Step by Step)
- In Palpo config (
palpo.toml), set your server name and appservice registration directory:
= "example.com"
= "appservices"
- Place your bridge registration file under that directory, for example:
appservices/teams-registration.yaml
- Ensure tokens are consistent between Palpo registration and bridge config:
as_tokenin registration == bridge appservice tokenhs_tokenin registration == bridge homeserver token
- Ensure bridge homeserver fields point to Palpo:
bridge:
domain: "example.com"
homeserver_url: "http://127.0.0.1:6006" # Replace with your Palpo URL
- Start Palpo, then start this bridge.
- Confirm connectivity both ways:
- Palpo must reach bridge registration
url(for appservice transactions) - Bridge must reach
bridge.homeserver_url(your Palpo endpoint)
- Palpo must reach bridge registration
Notes:
- If Palpo and bridge run in different containers/hosts, do not use loopback addresses unless they are in the same network namespace.
- For Docker Desktop,
host.docker.internalis often useful when bridge container needs to reach host Palpo.
Configure Matrix / Synapse (Step by Step)
- Set your Matrix-facing values in
config.yaml:
bridge:
domain: "example.com"
homeserver_url: "https://matrix.example.com"
bind_address: "0.0.0.0"
port: 9006
- Create
teams-registration.yamlnext toconfig.yaml(or setREGISTRATION_PATH):
id: "teams"
url: "http://127.0.0.1:9006"
as_token: "CHANGE_ME_AS_TOKEN"
hs_token: "CHANGE_ME_HS_TOKEN"
sender_localpart: "_teams_"
rate_limited: false
protocols:
namespaces:
users:
- exclusive: true
regex: "@_teams_.*:example.com"
aliases:
- exclusive: true
regex: "#_teams_.*:example.com"
rooms:
- In Synapse
homeserver.yaml, add:
app_service_config_files:
- /path/to/teams-registration.yaml
- Ensure the registration
urlis reachable by Synapse.- Same host:
http://127.0.0.1:9006is fine. - Different host/container: use a routable address.
- Same host:
- Restart Synapse, then start this bridge.
Notes:
bridge.domainshould match your Matrix server domain (right side of MXIDs).bridge.homeserver_urlshould be the real homeserver URL (preferably public HTTPS if Teams needs to fetch media).- If
registrationfields are missing inconfig.yaml, values are loaded fromteams-registration.yaml.
Docker
Build:
Run (expects /data/config.yaml in the mounted directory):
Notes:
- Container listens on
0.0.0.0:9006by default. - Health check endpoint:
GET /health - Default registration file path is
teams-registration.yamlresolved relative toCONFIG_PATH.
Database Configuration
The bridge auto-detects DB type from connection string prefix:
postgres://orpostgresql://-> PostgreSQLsqlite://-> SQLitemysql://ormariadb://-> MySQL / MariaDB- anything else -> PostgreSQL fallback
MySQL backend note:
- Build with the
mysqlfeature enabled, e.g.cargo run -p matrix-bridge-teams --features mysql - Install
libmysqlclient(or MariaDB Connector/C) somysqlclient-syscan link
Examples:
database:
url: "postgresql://user:password@localhost:5432/matrix_bridge"
max_connections: 10
min_connections: 1
database:
url: "sqlite://./data/matrix-bridge.db"
database:
url: "mysql://user:password@localhost:3306/matrix_bridge"
max_connections: 10
min_connections: 1
Environment Overrides
The following environment variables are supported:
CONFIG_PATHREGISTRATION_PATHAPPSERVICE_TEAMS_AUTH_TENANT_IDAPPSERVICE_TEAMS_AUTH_CLIENT_IDAPPSERVICE_TEAMS_AUTH_CLIENT_SECRETAPPSERVICE_TEAMS_REGISTRATION_IDAPPSERVICE_TEAMS_REGISTRATION_AS_TOKENAPPSERVICE_TEAMS_REGISTRATION_HS_TOKENAPPSERVICE_TEAMS_REGISTRATION_SENDER_LOCALPART
Features
Current Features
- Basic Matrix AppService integration
- Microsoft Teams Graph API integration
- Message bridging (Matrix <-> Teams)
- User synchronization
- Room/Channel mapping
- File/Attachment handling
- Edit/Delete message support
- Typing notifications
- Read receipts
- Presence synchronization
Planned Features
- Thread support
- Reaction bridging
- Rich text formatting
- Mentions (@user)
- End-to-end encryption support
- Multi-tenant support
Development
Building
Testing
Linting
Contributing
Contributions are welcome! Please read our contributing guidelines before submitting PRs.
License
Apache-2.0
Acknowledgments
- Based on matrix-bridge-discord architecture
- Inspired by mautrix-teams
- Uses matrix-bot-sdk
- Integrates with Microsoft Graph API