Reputation: 6775
I'm working on an interactive Slack app written in Node.js with Express. When the user clicks a button on an interactive message, I want to post an ephemeral message; however, the replies always appear publicly in the channel. Furthermore, whether or not I set the response_type
, the original message with the interactive elements that the user clicked on disappears. My code looks like this:
const request = require('request');
app.post('/slack-interactivity', async function(req, res) {
const payload = JSON.parse(req.body.payload);
sendResponse(payload.response_url, 'you clicked');
res.send('received');
});
function sendResponse(responseUrl, response) {
request.post({url: responseUrl,
method: 'POST',
json: {
response_type: "ephemeral",
text: response}});
}
When I click on a button in an interactive slack message, I see "you clicked" written publicly to the channel, but I want it to be ephemeral.
Any ideas why this could be happening?
Upvotes: 2
Views: 2454
Reputation:
This isn't possible (as of 5/17/2019)
A message will retain its visibility for life. Meaning you can't go from in_channel to ephemeral (or vice versa).
You can include: replace_original: false
and the ephemeral message will display.
Behind the scenes replace_original is acting like an update, not delete and create new message.
Your code defaults to replace_original: true which preforms an update and thus is not going to work.
Upvotes: 5