Mattermost Peer-to-Peer Forum

Interactive dialog in plugin

#1

Hi,
Is it possible to display an interactive dialog using webapp plugin ?

class HelloWorldPlugin {
    initialize(registry, store) {
        registry.registerPostDropdownMenuAction(
            "test",
            () => {alert('Hello World!')},
        );
    }
}
window.registerPlugin('com.mattermost.webapp-hello-world', new HelloWorldPlugin());

I would like to open a dialog in the registerPostDropdownMenuAction registry.

I know that https:///api/v4/actions/dialogs/open can be called to open a dialog but I don’t have any trigger_id

Do you know how should I do ?

#2

@Hanzei Would you know more about this?

#3

Even if I’m using server references in go, I don’t have any trigger_id.
Is it possible to generate one in the server ?

#4

My initial idea is to set up a http endpoint for you plugin, call this endpoint from the webapp and then open the dialog via OpenInteractiveDialog.

One downside of this approach is that authentication can be tricky.

Does is approach work in general for you?

#5

That is what I did but OpenDialogRequest requires also a TriggerId

Maybe I can generate an id in this endpoint ?

#6

A triggerID only get created when a users click message buttons or select an option from a menu, or use a custom slash command. There is currently no other way.

Sorry, I forgot about this limitation.

@jasonblais What do you think about allowing plugins to open Interative Dialogs independent of a triggerID?

#7

What do you think about allowing plugins to open Interative Dialogs independent of a triggerID?

@hanzei Are there any potential consequences with enabling that? If not, opening a Help Wanted ticket for it seems like a good option.

#8

Well, plugin would be able to create Interactive Dialogs even if a user as not click message buttons or select an option from a menu and did not use a custom slash command.

Does this answer your question?

#9

@Hanzei I’ve drafted a ticket to allow interactive dialogs to be triggered by plugins without clicking an interactive button/menu or without using slash commands

https://mattermost.atlassian.net/browse/MM-15340

However, I’m contemplating options for the proposed change. Instead of allowing plugins to open a dialog without a TriggerId, should we have the plugin generate one? There should always be some user action that triggers the dialog.

#10

I’m wondering the reason behind this. Usually plugin just bypass any security check, that usually apply.

#11

@hanzei Good question - I was more referring from the user experience point of view. Having a dialog open without user action is not necessarily desirable.

For instance, in the use case @gloupmer shared above, the user would first click on the post dropdown menu to trigger it.

#12

Having a dialog open without user action is not necessarily desirable.

But if we add a plugin API method that creates trigger ID’s, it’s not bound to a user action either. Plugins could creates trigger ID’s and then dialogs when ever they want.

I’m not fully against adding the ability to generate trigger ID’s for plugins, but I want to understand the reasoning and why a new API method is needed.