Identifying a user #54

Closed
chriskinsman opened this Issue Dec 29, 2015 · 10 comments

Comments

Projects
None yet
10 participants
@chriskinsman

I want to get the friendly name of a user.

Tried: controller.storage.users.get(message.user,function(err,user) {}) which is in the bot.js file but user always come in as undefined.

Reading through source it appears that there is storage but no methods to lookup users...

Is this right?

@benbrown

This comment has been minimized.

Show comment
Hide comment
@benbrown

benbrown Dec 29, 2015

Contributor

Sounds like you want to get the name of the user from Slack. Am I right?

For this, you would use bot.api.users.info()

Contributor

benbrown commented Dec 29, 2015

Sounds like you want to get the name of the user from Slack. Am I right?

For this, you would use bot.api.users.info()

@chriskinsman

This comment has been minimized.

Show comment
Hide comment
@chriskinsman

chriskinsman Dec 29, 2015

Yep. Just thought there would be a method backed by storage that would identify the user from storage and only make the call if needed. I added one. Will look at a pull request..

Yep. Just thought there would be a method backed by storage that would identify the user from storage and only make the call if needed. I added one. Will look at a pull request..

@Shubhamjain112

This comment has been minimized.

Show comment
Hide comment
@Shubhamjain112

Shubhamjain112 Jun 3, 2016

How do I get the user name through bot.api.users.info() ?

How do I get the user name through bot.api.users.info() ?

@ding444

This comment has been minimized.

Show comment
Hide comment
@ding444

ding444 Aug 25, 2016

@Shubhamjain112, it's late to the game but this is how I've done it:

controller.hears('hello', ['direct_mention'], (bot, message) => {
    bot.api.users.info({user: message.user}, (error, response) => {
        let {name, real_name} = response.user;
        console.log(name, real_name);
    })
})

ding444 commented Aug 25, 2016

@Shubhamjain112, it's late to the game but this is how I've done it:

controller.hears('hello', ['direct_mention'], (bot, message) => {
    bot.api.users.info({user: message.user}, (error, response) => {
        let {name, real_name} = response.user;
        console.log(name, real_name);
    })
})
@lucaskatayama

This comment has been minimized.

Show comment
Hide comment
@lucaskatayama

lucaskatayama Jan 20, 2017

I got

{ ok: false, error: 'not_authed' }

I added users:read to the scope... but still not_auth...

I got

{ ok: false, error: 'not_authed' }

I added users:read to the scope... but still not_auth...

@littleStudent

This comment has been minimized.

Show comment
Hide comment
@littleStudent

littleStudent Jan 22, 2017

same problem here. users:read added to the scope. still getting not_authed error

same problem here. users:read added to the scope. still getting not_authed error

@hannesjung

This comment has been minimized.

Show comment
Hide comment
@hannesjung

hannesjung Mar 17, 2017

same for me, did you find a fix?

same for me, did you find a fix?

@djanowski

This comment has been minimized.

Show comment
Hide comment
@djanowski

djanowski Mar 29, 2017

(For people finding this issue via Google:)

If you just want to mention the user, you don't need to query the users API to get the handle.

Format the message like this: Hello <@${user}>. Slack will turn the ID into a proper mention.

(For people finding this issue via Google:)

If you just want to mention the user, you don't need to query the users API to get the handle.

Format the message like this: Hello <@${user}>. Slack will turn the ID into a proper mention.

@littleStudent

This comment has been minimized.

Show comment
Hide comment
@littleStudent

littleStudent Mar 30, 2017

I could not figure out how to get the user...
I used this package just for getting the list of users https://www.npmjs.com/package/slackbots

I could not figure out how to get the user...
I used this package just for getting the list of users https://www.npmjs.com/package/slackbots

@azizimranz

This comment has been minimized.

Show comment
Hide comment
@azizimranz

azizimranz Jun 26, 2017

Hi,

I want the bot to hear from only specific user.

(Its drift user that I want to hear only).

Hi,

I want the bot to hear from only specific user.

(Its drift user that I want to hear only).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment