Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to know user's full name who pinged the bot? #411

Closed
iamgabesanchez opened this Issue Sep 10, 2016 · 2 comments

Comments

Projects
None yet
4 participants
@iamgabesanchez
Copy link

commented Sep 10, 2016

I was wondering how can I find out the user's full name from Slack, who pinged the bot such that I can take the conversation forward?

@markmcspadden

This comment has been minimized.

Copy link

commented Sep 14, 2016

Because message.user is just the userid, I ended up dropping down to the Slack api and used /users/info to do something like:

// Within context where you have a message object
var currentUser; 
bot.api.users.info({user:message.user},function(err,response) {
  if(err) {
    bot.say("ERROR :(");
  }
  else {
    currentUser = response["user"];

    bot.say(
      {
        text: 'Hi ' + currentUser["name"],
        channel: whateverChannelId
      }
    );
  }
});

Here, the response["user"] object matches what you get back from the Slack API here: https://api.slack.com/methods/users.info

There may be other ways, but that way is currently working for me.

@hassifow

This comment has been minimized.

Copy link

commented Jun 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.