Botkit: How to know user's name who pinged the bot?

Created on 1 Jun 2016  路  3Comments  路  Source: howdyai/botkit

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?

Slack-related question

Most helpful comment

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+'>');
});

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

abinashmohanty picture abinashmohanty  路  4Comments

TheJimFactor picture TheJimFactor  路  4Comments

znat picture znat  路  4Comments

simpixelated picture simpixelated  路  3Comments

stelio picture stelio  路  4Comments