Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Add hint buttons to messages (like Telegram does) #2109

Closed
wants to merge 1 commit into from

Conversation

denis-ignatenko
Copy link

Add feature to show buttons with predefined reply action. Similar like it does Telegram messanger. Useful for making hints for available bot commands. Buttons rendering to the bottom of the message combining in two to five buttons in a row.

To make it work message content must be extended by hints list. Each element of a list contain object describing button. Button content could be simple text or formatted html like in ordinary messages. Also it is possible ad image or just place only image.

Pushing button send message to the room with (by default) text of button, but could be set to predefined text by "reply" attribute. Message type for sendback by default is m.text. It is possible to send m.notice type by setting "replynotify" attribute to true.

Sample message content without buttons:

"content": {
    "body": "Test message",
    "msgtype": "m.text"
},

Sample message content with two buttons:

 "content": {
    "body": "Test message",
    "msgtype": "m.text",
    "hints": [
      { "body": "button 1", "reply": "button_action1" },
      { "body": "button 2", "formatted_body": "Button <strong>2</strong>", "format": "org.matrix.custom.html" },
    ]
}

Available attributes in hint objects are:
body - simple text
reply - text to send back
formatted_body - html formatted text
format - formated body type. For now just only "org.matrix.custom.html" to make it look like ordinary body content.
img - internal mx url for image. Could be also external image or base64 encoded data url.
replynotify - boolean, if set to true then message type to send back is m.notice. Useful for "hiding" reply message.

@turt2live
Copy link
Member

Thanks for the contribution! This is something that quite a few people have wanted for a long while now.

Buttons like this would be great to have in the Matrix Specification so that more clients besides Riot can use them safely, which includes bridges to Telegram. The proposal process is a little in flux in the moment as we work towards a more efficient system, however the majority of it is documented over at https://matrix.org/docs/spec/proposals. If you're interested in being part of the beta test for the new process, feel free to drop by #matrix-spec:matrix.org and we can guide you through it.

From chatting with some community members, @tulir is interested in helping out with the spec side of things if you need a hand. Of course, if you have any questions feel free to ask!

@tulir
Copy link
Member

tulir commented Aug 3, 2018

As @turt2live said, I can help out with the spec. I'll also definitely implement this in my Telegram bridge after the spec stuff.

On the implementation side: There should be some confirmation before sending a message. Perhaps a popup showing the message and optionally raw event content that will be sent if the user clicks OK.

@tulir
Copy link
Member

tulir commented Aug 4, 2018

I made an initial spec proposal in matrix-org/matrix-doc#1485 / https://docs.google.com/document/d/1806FWv2B8_vca5ggJC_YGKgz7npbOy7Mg_9LyP74_0w/edit#

@jryans
Copy link
Collaborator

jryans commented Mar 4, 2021

Thanks for making this contribution a while back. Since the code base has changed since this was opened, it no longer applies cleanly, and I don't think there's a need to keep it open in this state, as we can always find the code here again if needed. If you are still interested in pursuing this feature, please discuss with us in #element-dev:matrix.org to find a good approach forward.

@jryans jryans closed this Mar 4, 2021
@MurzNN
Copy link
Contributor

MurzNN commented Mar 4, 2021

Seems this is planned to implement using inline widgets here matrix-org/matrix-spec-proposals#2192 ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants