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?
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.
https://github.com/hassifow/Get-slack-user-name-who-pinged-the-bot
For dialogFlow users.
Most helpful comment
Because
message.useris just the userid, I ended up dropping down to the Slack api and used/users/infoto do something like:Here, the
response["user"]object matches what you get back from the Slack API here: https://api.slack.com/methods/users.infoThere may be other ways, but that way is currently working for me.