matrix-org / matrix-org/matrix-widget-api

[HELP] How to make a custom widget that receives a matrix user's userid?

Open
#50 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
95
Forks
24
Avg merge
16h 16m
Merged PRs (30d)
1

Description

Let's say my friend hosts a hypothetical video game that allows users to join without registration, and a URL like `https://coolgame.com/?guestname=` allows the browser to suggest a pre-filled username (similar to KiwiIRC, some wikis, Jitsi, etherpad, etc). When I simply add `$matrix_user_id` to the end of the URL (e.g. `/addwidget https://coolgame.com/?guestname=$matrix_user_id` ) the game website thinks that a guest wants to use the name `$matrix_user_id`, instead of `alice`, `bob` etc

If I host a file, e.g. `https://mysite.com/coolgame.html`, can I simply use
``
+
``

then in Element enter `/addwidget https://mysite.com/coolgame.html` to allow my Matrix users to open the game widget with their name pre-filled for them?

I tried to ask about this kind of scenario in the Matrix room and am still a bit lost. I think that asking this as an issue is useful, because if other people wonder how to do this hypothetical scenario in the future (it will become more common as Matrix and Element, etc grow) this issue / future documentation should be able to cover this hypothetical usecase: help someone who's not a webdev or JS person make a custom widget that listens to Matrix suggestions (eg: room name, username) with as little work as possible.

Sorry to be a nuisance, and I am very grateful for any support 🙏

Contributor guide

Open the contributing guide

Research direction

No repository file or test is named. Start with the supplied api.min.js and iframe example, then verify how a custom widget can receive Matrix user information and whether the proposed URL substitution is supported. Done means documenting a minimal working path for this use case and clearly stating any limitations.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
api, documentation, web-dev
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.