Problem/Motivation

How can Drupal leverage Matrix integration?

From the project page:

Embedded Chat -- embed a Matrix chat room in a web page, using matrix-react-sdk
Authentication Provider -- provide some sort of single-sign-on facility to allow a private Matrix homeserver to accept a Drupal login, and auto-provision account
Application Service -- create an endpoint in Drupal that receives Matrix events
Matrix HS management -- Create a Matrix Application Service that can manage rooms, users from a Drupal module

Proposed resolution

Make a roadmap what has to be done, and how much effort is needed.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

geek-merlin created an issue. See original summary.

geek-merlin’s picture

I did some research. The simplest way to embed a matrix room chat into drupal seems to be this nowadays: https://github.com/vector-im/hydrogen-web/blob/master/doc/SDK.md

freelock’s picture

Title: Roadmap for Drupal / Matrix integration » Embedded Matrix chat in Drupal
Category: Task » Feature request

Hi,

We may have a client project to do this coming up shortly. @geek-merlin are you working on something like this already?

I've been tracking 2 projects to build on/consider for this:

... the second one is built on Hydrogen by the Element team.

Regarding Authentication provider, I think this can be done now using Simple OAuth/OIDC -- it's on my list to give this a try.

geek-merlin’s picture

One pro-bono project of mine would like this a lot. So i'll be able to chip in a limited amout of time to test and maybe weed out stuff.

I looked into the links you cited.
- https://github.com/nomadic-labs/safesupport-chatbox/
So any user, auth or not, can send messages, and a bot posts them on matrix.

- https://github.com/vector-im/chatterbox
It's not completely clear from the description, but it looks like it creates a matrix user for any local user.

So let's clarify what our need is, and what your customer wants, and what the intersection is.

We have a platform with groups, and need a room-per-node chat, with auto-created rooms and invitiations.
The mapping from Drupal to matrix user is done via Drupal user profile. Auto-creating users is no hard requirement, we can simply show a provide-your-matrix-id-or-registe dialog.

Are there intersections with your requirements?

It looks like the link i researched is the best match for this:
https://github.com/vector-im/hydrogen-web/blob/master/doc/SDK.md

Did you check that out?

geek-merlin’s picture

Title: Embedded Matrix chat in Drupal » Embedded Matrix room-per-node chat in Drupal
geek-merlin’s picture

Title: Embedded Matrix room-per-node chat in Drupal » Embedded Matrix chat in Drupal (room-per-node, user-per-user)
freelock’s picture

The scenarios we need to support first are largely sales support types of questions -- the client interested is a community college that wants to be able to answer questions for prospective students, and we have several other clients with similar needs.

I think Chatterbox implements the Hydrogen SDK you link to, so I suspect that becomes a question of which integrates easier, between those two.

My sense is that the Safe Support Chat did their own front end, and have a separate bot to handle the room creation/invitations/etc. Whereas Chatterbox does something similar, but so far their support bot is not open sourced (at least not yet) so for now you need to figure out the plumbing around creating the rooms and invitations you need.

I do think we're talking about (at least) two different parts here:

  1. Front end interface for chatting
  2. Back end bot or application service to manage user/room creation, invites, and unavailable messaging

For your user accounts, I think you can now auto-create users in Synapse using OpenID Connect (OAuth2). We've used Simple OAuth on several sites now to make Drupal an identity provider. I haven't yet connected Synapse this way, but it seems like that should be pretty straightforward, to at least make it so you could log into your own Synapse instance using Element and OIDC against a Drupal back end, with Matrix users auto-created.

So it seems like a good next step for what you're trying to do might involve automatically doing this on a page with a chat widget embedded -- this certainly seems doable, not sure how much effort is involved.

I think for the scenarios I'm trying to support, we need to be able to handle anonymous users, not Drupal users, so that's where I'm going to be spending time...

geek-merlin’s picture

Yes, that all makes sense. And yes, good idea to start with OIDC as identity provider.

freelock’s picture

Ok just saw in #twim:matrix.org , WordPress is in active development of a plugin for Matrix, called Chatrix. It's a fork of Element's Chatterbox, and from the github page, it says it essentially allows embedding Hydrogen on a WordPress site.

I'm thinking we might be able to use the front end as is -- https://github.com/Automattic/chatrix-frontend -- perhaps with some pull requests to that project if we need any changes.

Their plugin code is here: https://github.com/Automattic/chatrix . Not sure whether this is a complete, working solution, but it definitely seems like something to jump-start our efforts here -- looking over the WP code, I see lots of code for stuff we get for free in Drupal, our Drupal module would probably start out much tighter...

@geek-merlin this might fit your scenarios without much else needed!

I'm thinking that for my scenario, having a Matrix app service registered, to push messages into Drupal where they can be routed/managed as appropriate.

So I'm thinking maybe we should start a "chatrix" module for the front end -- separate module to make composer dependency management easier to make optional. And then a "matrix_api_appservice" submodule of this one to get appropriate messages pushed into Drupal for a variety of scenarios, with implementing a chat broker/bot as the first one.

freelock’s picture

Update: I went ahead and created the project page for Chatrix. I would welcome any co-contributors who would be interested in working on this! My time is limited on it for the moment, it may be a few weeks before I can start in earnest.

calbasi’s picture

Hi, I'm not sure if this:

https://youtu.be/mC5t00JEG-0

could be interesting for you.

It's the Moodle - Matrix integration, coming in the new 4.3 Moodle version. It seems they use a client to emulate Matrix inside Moodle.