mattermost

How to add custom link preview to mattermost


I'am looking for a way to implement custom link preview for our task system (MantisBT). Essentially i would like to create some sort of plugin which would be able to capture links in specific format (https://tasks.com/b/1234). Get simple details of given task using REST api from internal task server and show them as message attachment (ex. task summary, assignee and status).

Unfortunatelly i cant find any info if it is even possible not speaking about some more detailed steps to do such think.

So to sum it up, someone sends a message:

Hello can you please look at https://tasks.com/b/1234

When this is send, i would like to see something like this:

Hello can you please look at https://tasks.com/b/1234

-----------------------------
| 1234: Bug in new system   |
| assignee: John            |
| status: new               |
-----------------------------

Essentially creating own link visualizer.


Solution

  • You can use registerLinkTooltipComponent plugin hook to display a custom component on hovering on a link. You'll be able to filter for specific links and display your custom component for any link you want to support.

    You can refer the GitHub plugin as an example - https://github.com/mattermost/mattermost-plugin-github/tree/master/webapp/src/components/link_tooltip

    enter image description here