Rocket.Chat SaaS
Matrix Bridge
Rocket.Chat and the Matrix Protocol
Rocket.Chat now has federation support via the Matrix protocol. You can now easily connect with external parties, whether they are using Rocket.Chat or any other Matrix compatible platform.

Key Features

You can
  • Create federated rooms
  • Send and receive messages
  • Invite federated users to join rooms
  • Matrix support in Rocket.Chat is currently considered alpha. Expect bugs.
  • Users need to set up a Matrix homeserver and a dendrite server
  • All interactions are performed through slash commands
    • Create a /federation dm <username> slash command
    • Create a /federation setup-room slash command
    • Create a /federation invite <username> slash command
    • Remove the /bridge invite slash command

Why We Use the Matrix Protocol?

  • To allow Rocket.Chat acts as a Matrix Application Service (Bridge) to Communicate to an appropriate Matrix homeserver (Dendrite, Synapse, etc.)
  • To enable the standards-based interoperable federation
  • To build an open, decentralized network, far stronger and more vibrant than any closed communication platform.

Set up Rocket.Chat with a Matrix homeserver (Dendrite)

System Requirements

Prerequisites

  • Install Docker and Docker Compose
  • A Matrix homeserver (Dendrite) that supports application services. You need to have access to register an AppService, which usually involves editing the homeserver config file.
  • Obtain Lets Encrypt Certificates
  • Configure nginx and setup Nginx Rules
  • A domain to host your homeserver on

Rocket.Chat Matrix Bridge Configuration

Now, you go to Administration > Settings > Federation >Matrix Bridge.
The following is a brief explanation of each Matrix Bridge configuration option:
  • AppService ID (automatically generated by Rocket.Chat): A unique identifier for the application service.
  • Homeserver Token (automatically generated by Rocket.Chat): A unique homeserver token to authenticate requests to application services. Example: http://localhost:8008
  • App Service Token (automatically generated by Rocket.Chat): A unique application service token to authenticate requests to homeservers.
  • Homeserver URL: The URL of the Matrix server you want to use as a Proxy homeserver.
  • Homeserver Domain: In the homeserver domain, use your federation domain. For example: local.rocket.chat
  • Bridge URL: The URL for the Matrix bridge. IT is the location you want your bridge should run.
  • Make sure the port that you are using for the bridge is free in your host, otherwise the Rocket.Chat server will crash trying to run a bridge.
  • We recommend a new, empty homeserver, to be used with the federation.
  • No user should connect to the homeserver with third-party clients, only Rocket.Chat.
  • AppService User Localpart: The local part of the user associated with the application service. The bot user used to execute some actions.
  • Registration - Automatically generated and updated by Rocket.Chat based on all the values provided in the above settings.
Registration Configuration File
  • Click Save Changes.
You need to have the Homeserver Token and the AppService Token keys ready.

Matrix Homeserver Configuration

Registering as an AppService with Matrix homeserver
  • Edit your dendrite.yaml file adding the configuration file (rocketchat_registration.yaml) as per the editing_dendrite_yaml image.
Registering as an AppService
  • Edit your config/rocketchat-registration.yaml replacing hs_token value with the Homeserver Token andas_token value with the AppService Token you got from Rocket.Chat.
Rocket.Chat Registration Config. File
Finally now we can start matrix up with:
1
docker compose up -d dendrite
Copied!
Now that you have dendrite and Rocket.Chat ready. You can now go into Rocket.Chat and try inviting and sending a message out to a user connected with another server (Rocket.Chat Server, dendrite, synapse and etc.,) through the Matrix Protocol.

Create a federated room

You can create a channel in Rocket.Chat and then invite users.

Invite a federated user

You can invite users from other servers through the slash command.
If you invite another Rocket.Chat server, it currently will auto-accept.
Invite a user
The structure for the slash command is described below:
/bridge invite @username:server_name
  • /bridge -the slash command alias
  • invite - the command you want to execute
  • @username:server_name - This is the typical structure for the invite. You need to use the @username you want to invite, followed by the server_name split by (:)
You must run the slash command before, inside the room you want to federate.

Communicate

After you have configured it, you can now send and receive messages within a federated channel.
Communicate