botkit
botkit copied to clipboard
How to know user's name who pinged the bot?
I am new to this botkit. I was wondering how can I find out the user's name from Slack, who pinged the bot such that I can take the conversation forward?
You can use direct_mention and mention events to listen for bot mentions. Then in handler you will have a message argument that will have user field with user ID that you can use to write a direct message or use in message contents.
Something like this:
controller.hears('hello',['direct_mention', 'mention'],function(bot, message) {
bot.reply(message, 'Hello <@'+message.user+'>');
});
Issue appears resolved.
@PaulAnnekov message.user is some opaque identifier, not the user's actual name. #411 gives a possible solution using the Slack API.