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?