Interactive dialog in plugin

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 ?

@Hanzei Would you know more about this?

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 ?

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?

That is what I did but OpenDialogRequest requires also a TriggerId

Maybe I can generate an id in this endpoint ?

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?

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.

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?

@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.

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

@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.

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.

@jasonblais What do you think about this? Would love to create a HW for this soon.

But if we add a plugin API method that creates trigger ID’s, it’s not bound to a user action either.

I see.

If there’s no benefit of adding the ability to generate trigger ID’s for plugins, then no need to do that.

Help Wanted ticket can be found here, @hanzei please help add the relevant labels: Allow plugins trigger interactive dialogs even without clicking an interactive button/menu or using a slash command · Issue #10900 · mattermost/mattermost · GitHub

1 Like