Matrix Bridges Working Together

I am testing SmsMatrix, an SMS-to-Matrix bridge on Android. It is one of many Matrix bridges. But this post is not mainly about SmsMatrix, it is mainly the start of a train of thought about how we can manage communications with one person bridged over different channels.

This is a write-up of thoughts I first posted to the SmsMatrix discussion room, which would be better continued on #bridges:matrix.org.

Let’s say my friend has telephone number 123456 and is in my phone’s address book as “Ray”.

When my phone receives an SMS from Ray, SMSMatrix sees that message arrive in the Android SMS subsystem, and (if it hasn’t previously done so) it creates a new Matrix direct-chat room which it will associate with the SMS sender’s phone number, and invites me to join the room.

The other participant in this room is the bridge bot. Its username is @sms-bot:my_hs, and it sets its own display name to “Ray”. I assume that is a per-room display name, so it will show as a different name in each SMS conversation. The bot does not set a room name, and so Riot displays it as “Ray” (the other participant’s display name), and the bot sets the room “topic” field to “123456”, which Riot displays next to the room name. The idea is that in the user interface it looks like I am having a chat with “Ray” and it works like I am having a chat with Ray.

In Riot-web’s message view, the sender of this first SMS message shows as (precisely) “sms-bot”. The display name of @sms-bot does seem to be correctly set to “Ray” — I can see that in the “users” panel. Perhaps that’s a Riot bug that it doesn’t always display the user’s display name.

This bot works without admin privileges. It can do so because it doesn’t try to create and control a new Matrix user for each SMS sender, nor does it try to find and puppet an existing “real” matrix user account corresponding to the sender.

I wonder if it would be nice to upgrade it to a puppeting bridge if I one day have enough time to devote to it. I’m wondering exactly what we could achieve if we did so.

I also have some other bridges, and let’s say Ray also has her own Matrix account on her own homeserver, where she calls herself by her full name “Radiator”. Now I have Ray’s messages coming in to me in these Matrix rooms/users:

  • @sms-bot:my_hs “Ray”
    • in room (unnamed) displayed as “Ray 123456”;
  • @whatsapp_123456:my_hs “Ray (WA)”
    • in room (unnamed) displayed as “Ray (WA) WhatsApp private chat”;
  • @telegram_123456:my_hs “Ray (TG)”
    • in room (unnamed) displayed as “Ray (TG)”;
  • @ray:rays_hs “Radiator”, Ray’s real Matrix user account
    • in room named “Ray”

The mautrix-telegram and mautrix-whatsapp bridges each create a new user id for Ray in their own namespace of matrix user-ids, which is different from the SMS bridge.

I am interested in researching how we could improve this situation. Would we want to make all bridges to the same person somehow bridge to the same Matrix user?

@pwr22 asked, “How would the bridge know which method to use when sending a message?” That’s a good UX question. The first thought coming to my mind is that’s easy if we dedicate a separate room for each bridge for that user. (Ray’s SMS chat room, Ray’s Telegram chat room, …).

“In that case what do we gain from having one puppet user instead of separate ones per service?” We gain things like,

  • “search for all messages from @ray [containing the word ‘zoo’]”,
  • “search for the rooms that @ray is in”.

I expect users would want to choose, by their own preferences and perhaps per contact, whether a contact’s messages are all grouped in the same room or a separate room per bridge.

If I want to group all Ray’s messages into one room, then the sending UX issue must be solved a different way. Perhaps the client would allow me to set a preference. (That could be stored as client-managed metadata, like how Riot stores some settings in “account data” under “im.vector.riot.xxx” keys.) And/or there could be bot commands so I can tell a bridge "!sms-bot: enable [or disable] sending outgoing messages in this room through SMS".

In response to my thought about making all bridges bridge to the same Matrix user, @swedneck replied, “i’m not sure that’d make sense. i would probably have all those bridges in the same room if possible. you’d probably want his bots to ignore each other though.” So:

  • one room (“My direct chat room with Ray”) containing
    • myself,
    • the virtual user @sms-bot:my_hs (“Ray”),
    • the virtual user @telegram_123456:my_hs (“Ray”),
    • …, and
    • the Matrix user @ray:rays_hs (“Radiator”).

I see how that would work well for incoming messages: I would be able to see which bridge each message came through, if I wanted, while keeping all the display names the same if I mostly didn’t care to see the difference.

We would need a way to make the bots know about each other. When Ray sends me a message through one bridge, we (probably) don’t want all the other bridges to send him copies of it. They’re all “my” bots running against my Matrix home server (HS), so I could add something to their configs easily enough. Alternatively, we could define common metadata that they could each set, so they could detect the situation automatically. The latter would be more flexible, in case some of them are not configured directly alongside my HS.

What about when I send messages to Ray? If I just type without a mention, then the same applies as I said before: some way of configuring in advance which bridge(s) is/are to send it.

When I Mention Ray, there are different matrix usernames I might mention, depending how I do it: if I click on one of the received msgs, I might select a bridge username that isn’t the currently configured preferred send method; how should that all work?

Maybe bridged usernames should be specially treated: all treated as something like aliases, and all resolved to the same single “real” matrix username?

Needs more thought.

MSC2346: Bridge information state event

As part of a solution, we will need a mechanism to allow multiple bridges in a room to communicate with each other. This proposal may achieve it:

Matrix Big Issues

A year ago I wrote up some thoughts on Matrix Big Issues. Here is another take on the medium-to-big issues that I think are important and interesting.

As you will see, these are just sketchy notes to record ideas I have been thinking about. I have not had time to research them and write them up further.

(My personal view as someone who runs my own homeserver and is getting involved with Matrix development.)

Big Issues

Matrix needs…

Easy Open Data

An ordinary user should be able to control their data (message history & media)…

  • extract their data
  • process (“re-mix”) their data offline using third-party tools
  • load their data, even if it is not a “true” history

Use cases

  • Alice and Bob register on Server-1 and exchange some messages. Server-1 goes read-only and is about to shut down. Alice uses her matrix client’s “Save to file” option to save “everything”: rooms, media, her account data, as far as the client can access it. Bob does the same but after the server has shut down, so his client can only save what it had cached. They register on Server-2 and import all their data. Everything works as well as possible.
    • Perhaps they can choose whether to import a read-only history using original identifiers tied to Server-1 (better preserving external links) or create read-write rooms (etc.) with history populated by translating to Server-2 identifiers (more disruptive to external links).

Support in popular address books [EXTERNAL-ENGAGEMENT]

  • VCARD/CARDDAV, microformats2
  • Thunderbird-CARDBOOK, Evolution, Gnome, KDE, Ubuntu-accounts,

Mobile: 1st class integration [MOBILE-UX]

  • Contacts: call/text directly from Contacts, save to Contacts
  • Contacts: get Mx support into popular Contacts apps [EXTERNAL-ENGAGEMENT]
  • Calls: make/receive just like phone calls (dedicated buttons, mute media, etc.)
  • SMS bridge: smsmatrix needs work
  • telephony bridge: should be a separate component, serving multiple Mx apps

Mark-up system (for IM class)

  • A base mark-up system with subclassing, to bridge systems that have their own mark-up sets.
  • Seek common denominators plus extensions.
  • NOT like https://github.com/tulir/matrix-doc/blob/formatting-entities/proposals/2427-json-based-message-formatting.md
  • Find that composable/pluggable news media markup system I read about a few years ago

The Public Switched Social Network (PSSN) [EXTERNAL-ENGAGEMENT]

  • Industry Co-ordination
  • see John Ryan’s presentation in: https://blog.archive.org/2020/01/30/our-social-media-is-broken-is-decentralization-the-fix/ from which (PSTN -> PSSN):
    1. Alternative operators -> alternative media operators
    2. Interconnect technology -> server-server / backend data exchanges
    3. Interconnect business agreements
    4. Data / records
    5. User equipment / experience -> new user apps / APIs
    6. Regulatory framework (and transparent ethics)

Single Sign-On (SSO) [ONBOARDING, SERVER]

  • Why? Users hate multiple logins. Self-sovereign services must flock together.
  • Especially target easy setup for private and small group installations. (Enterprises can plug in to their existing SSO.)
  • Poor state of SSO in FOSS.
  • Work with other FOSS; decouple the id provider functionality.
  • see: keycloak.org, pomerium.io, portier.github.io
  • see: self-host systems that offer SSO provider: Nextcloud? Mattermost? UBOS?

Scripting, auto-responder, filtering, web-hooks [CORE-APPS]

  • What? Allow user to program functions in their user account.
  • Why? User of a digital comms system should be empowered to control their own automation, in case they don’t want GAFAM doing it for them.
  • Why? Enterprises benefit from automation of email, SMS, webhooks, etc.; private/small groups should be able to benefit as well.
  • first class core + user plug-ins
  • Simple config; like old home computers booted up to BASIC; e.g. manual config through a bot room, scripted config by file uploads.
  • eg: look at GAFAM: respond to calendar invitations, maps
  • eg: look at enterprise customer comms: SMS to query & top-up accounts, book a ticket

In decentralizing ids: option for forwarding one’s own DNS domain to a multi-tenant server [DIDS]

  • DNS is one method for addressing/routing to my id

Sign-up [SERVER, ONBOARDING, EXTERNAL-ENGAGEMENT]

  • “install on my existing server” (NextCloud, UBOS, Sandstorm, etc.)
  • link/guide to purchasing a domain name?

The route to Matrix for an average individual needs to look more like this:

  • invited by a friend to join Matrix
  • sign up to matrix.org or another big free general-purpose server
  • find the concepts and UI easy to understand
  • after a while, want a self-sovereign id
  • choose a self-sovereign id: either own-domain DNS or another form
  • add own id to the account, setting it as the main id, setting old id to forward to new id
  • want to bridge to WhatsApp etc.; current server doesn’t allow it
  • choose another server; easily move the account, id and history to the new server

Smaller Issues

And some smaller but still important and interesting issues:

Riot: Simple UI mode [ONBOARDING]

  • (see “Idiot mode”, https://github.com/vector-im/riot-web/issues/8952 )
  • Why? New user: Child/Parent.
  • Why? New user: friend migrating from WhatsApp.
  • Why? Power user (myself) wants minimal clutter in most cases.
  • in group rooms: show minimal metadata (typing notifications, read markers, etc.)
  • in 1:1 rooms: show little metadata
  • vastly simplify Settings (not just remove; organize with modes & search)

A reference system definition for server [DEV-META]

  • for each major use case (private, group, public)

a “Why Should I?” page [ONBOARDING]

  • Why? Because I want to persuade family & friends but I’m not good at persuasion.
  • one specifically addressed to a WhatsApp user with no tech skill
  • one specifically addressed to a FOSS project/group (e.g. Apache Subversion)
  • to quote, link, copy, share

Default Widgets/Integrations/Bots should include FOSS [FOSS-ALIGNMENT]

  • I’m looking at the default integrations (Modular.im)
  • especially provide FOSS alternative to each proprietary one
  • standard calendar (vs. Google)
  • peertube (vs. Youtube)
  • GitLab bot (vs. GitHub)

Responding to a blog that was linked [DEMO-APPS]

  • using activity pub etc.

Log monitoring: Synapse reporting Synapse logs to a room [DEV-META, DEMO-APPS]

  • Suggested ~2020-01-24 by someone on -docker-ansible-deploy; I commented.

Going to build a Matrix

I am leaving my latest job and moving on to my new passion, Matrix.

Recently I have become passionate about the need for modern communications systems that are Open in the sense of freedom to talk to anyone. The currently dominant silos like WhatsApp only let me talk to the friends who are willing and able to subscribe to that company’s terms and restrictions, with no way to get around them when they decide to display advertising to me or stop supporting my mother’s not-terribly-old iPhone. To me, that is like some historical feudal system in which I live as a tenant and I must obtain agreement from the lord of the estate if I want to invite any of my friends to visit me. We need and deserve better than that: an Open way to communicate to our friends and business contacts. Email served that role for the first part of the 21st century, and Matrix now serves that role for the era of instant messaging.

My software development in recent years has been mostly on the open source Subversion version-control system, and I have particularly enjoyed helping to create something so widely used and appreciated. Nowadays its popularity is eclipsed by Git in small to medium sized projects, while Subversion still enjoys a strong following in certain fields such as games development due to its strengths in versioning large data sets and simplicity of usage. Participating in the development of Open Source software has given me the greatest satisfaction in my professional life, and I intend to keep it that way. That is why developing the Matrix communication system is so exciting.

p.s. I am still contracting on Subversion support work, so get in touch if you need any bug fixing or problem diagnosis.