Skip to content

Commit

Permalink
Fix bot.replyPrivateDelayed. howdyai#444
Browse files Browse the repository at this point in the history
I discovered this when trying to ephemerally respond to an interactive button click. We need to set `replace_original` to `false` in order for our reply to be ephemeral. Otherwise, it will reply publicly. Furrther, when responding to an ephemeral message's button click, currently we cannot update it. Thus, introduce new method to provide the option to update or not. The existing one could be depcrecated.
  • Loading branch information
sundeepgupta committed Oct 27, 2016
1 parent b0889a2 commit 94c5085
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions lib/Slackbot_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,43 @@ module.exports = function(botkit, config) {
msg.channel = src.channel;

msg.response_type = 'ephemeral';
msg.replace_original = false;

var requestOptions = {
uri: src.response_url,
method: 'POST',
json: msg
};
request(requestOptions, function(err, resp, body) {
/**
* Do something?
*/
if (err) {
botkit.log.error('Error sending slash command response:', err);
cb && cb(err);
} else {
cb && cb();
}
});
}
};

bot.replyDelayedPrivate = function(src, resp, replace_original, cb) {
if (!src.response_url) {
cb && cb('No response_url found');
} else {
var msg = {};

if (typeof(resp) == 'string') {
msg.text = resp;
} else {
msg = resp;
}

msg.channel = src.channel;

msg.response_type = 'ephemeral';
msg.replace_original = replace_original;

var requestOptions = {
uri: src.response_url,
Expand Down

0 comments on commit 94c5085

Please sign in to comment.