matrix-joinlink
A bot that allows the creation of Join Links to non-public Rooms in Matrix
matrix-joinlink allows the creation of join links to non-public rooms in Matrix. It uses the trixnity framework.
Reason for this Bot
I often struggled with sharing private rooms with a group of friends. Before this bot, I had to invite everyone manually. Now I can invite matrix-joinlink and create a join link. This link can be shared with friends who want to join the room (including spaces).
Setup
- Get a matrix account for the bot (e.g., on your own homeserver or on
matrix.org) - Prepare configuration:
- Copy
config-sample.jsontoconfig.json - Enter the
baseUrlof the Matrix server andusername/passwordfor the bot user - Set an encryption key. The bot will use this string as key to encrypt the state events.
- Add yourself (e.g.,
@user:matrix.org) or your homeserver (e.g.,:matrix.org) to theusers(empty == allow all). Users can interact with the bot. - Add yourself to the
admins(can’t be empty)
- Copy
- Either run the bot via jar or run it via the provided docker.
- If you run it locally, you can use the environment variable
CONFIG_PATHto point at yourconfig.json(defaults to./config.json) - If you run it in docker, you can use a command similar to this
docker run -itd -v $LOCAL_PATH_TO_CONFIG:/usr/src/bot/data/config.json:ro ghcr.io/dfuchss/matrixjoinlink - If you want to persist sessions, you should persist the data volume
-v $LOCAL_PATH_TO_DATA:/usr/src/bot/data
- If you run it locally, you can use the environment variable
Usage
- A user (see user list in configuration file) can invite the bot to a room.
- After the bot has joined, use
!join helpto get an overview of the features of the bot (remember: the bot only responds to users in the user list) - To create a join link, type
!join link SomeFancyNameForTheLinkand the bot will create one. Please make sure that the bot has the ability to invite users.

Creation of Join (Invite) Links

Entering a Join (Invite) Link Room

Unlinking a Join (Invite) Link

Development
I’m typically online in the trixnity channel. So feel free to tag me there if you have any questions.
- The basic functionality is located in Main.kt. There you can also find the main method of the bot.
How the bot works
- Let’s assume that you want to share the private room
!private:room.domain - After you’ve invited the bot, you can enter
!join link IShareLinksWithYou - The bot creates a new public room that contains “IShareLinksWithYou” in its name. This room will not be listed in the room directory; for this example its ID is
!public:room.domain. - If somebody joins the public room, the bot verifies based on two encrypted state events in
!private:room.domainand!public:room.domainwhether the rooms belong to each other. If so, the bot simply invites the user to the private room. - If you want to disable the share simply type
!join unlinkin the private room. This will invalidate the join link.