Mattermost, Inc.

Cannot open dialog

I am not sure what I am doing wrong, but I cant seem to open the dialog, but I am getting a {status: 'OK'} response…

Mattermost Version: 5.13.2

The post from the slash command is ephemeral

My slash command is working fine, and so is the interactive button (this is what should trigger the dialog to open).

Here is my code for the dialog to trigger. This req param is being passed from the action from clicking a button.

module.exports.addEmail = (req) => {
	let body = req.body;
	let data = JSON.stringify({
		trigger_id : body.trigger_id,
		url        : resolve(config.MM_ACTION_URL, '/mattermost/dialog'),
		dialog     : {
			title       : 'Email',
			callback_id : 'add_email',
			elements    : [
				{
					display_name : 'Email',
					name         : 'email',
					type         : 'text',
					subtype      : 'email',
					placeholder  : 'placeholder@example.com'
				}
			]
		}
	});
	mmRequest('post', 'actions/dialogs/open', data)
		.then((res) => {
			console.log(res);
		})
		.catch((error) => console.log(error));
};

On the server side, this is my code to add a little more context to my workflow.

app.post('/mattermost/actions', (req, res) => {
	// console.log(req.body);
	let action = req.body.context.action;
	if (action === 'add_email') {
		dialog.addEmail(req);
	}
});

app.post('/mattermost/dialog', (req, res) => {
	console.log(req.body);
	res.sendStatus(200);
});

And the function that is making the API call to the mattermost server is

module.exports.mmRequest = (method, url, data = {}) => {
	let c = {
		method  : method,
		baseURL : resolve(config.MATTERMOST_URL, 'api/v4/'),
		url     : url,
		data    : data,
		headers : {
			Authorization : `Bearer ${config.MM_ACCESS_TOKEN}`
		}
	};
	return new Promise((resolve, reject) => {
		Axios(c)
			.then((res) => {
				resolve(res.data);
			})
			.catch((error) => reject(error.response));
	});
};

In the console.log(res), I get a status OK message, but the dialog doesnt open… What am I doing wrong?

1 Like

I am facing the same issue right now. I send a dialog with correct trigger_id and receive 200/OK, but the dialog does not show. Did you find any solution until now?

Has this been fixed? Facing the same issue on 5.16.0
Getting 200/OK for the POST request to open dialog, but it doesn’t show up.

@securisec, @psharma9
There is a good example of how to display an interactive dialog in the demo plugin here?

It receives a slash command -> invokes the OpenInteractiveDialog PluginAPI that opens the dialog.

Hard to follow along the example mentioned in your post as there are pieces that are missing. Let me know if the demo plugin example helped.

@ali-farooq0
Thank you for your response. While /command should help us do it, my team is specifically looking to use buttons instead of /command.

The document says that we should be able to use it either way. Is a button click to provide the necessary trigger not sufficient?

@psharma9, I’ve uploaded an example where you can launch a dialog through an ephemeral message.

Example: https://github.com/mattermost/mattermost-plugin-demo/blob/403401ddf3c6a396ed53ba374e787b179887ea90/server/http_hooks.go#L185

Which will exhibit this behaviour:

If that was the desired behaviour, let me know and I can create a ticket to include that example in our demo plugin.

@psharma9 Did the example work for you?