admin管理员组

文章数量:1297036

For context, I'm using the Bolt for JavaScript framework to develop a Slack bot. I have a workspace where I'm the only member.

In the app home, I need to retrieve the current user's email address, but I'm not sure how to do that.

WebAPI methods for users for example, users.profile.get and users.identity, require a user token, I suppose I need to get the user token of the current user.

Any ideas on how to retrieve the user token from the backend? Suggestions would be appreciated.

For context, I'm using the Bolt for JavaScript framework to develop a Slack bot. I have a workspace where I'm the only member.

In the app home, I need to retrieve the current user's email address, but I'm not sure how to do that.

WebAPI methods for users for example, users.profile.get and users.identity, require a user token, I suppose I need to get the user token of the current user.

Any ideas on how to retrieve the user token from the backend? Suggestions would be appreciated.

Share Improve this question asked Aug 13, 2021 at 3:44 Aj ThomasAj Thomas 431 silver badge5 bronze badges 1
  • Wele S. Thomas, it would be easier to help if we can see some code that you have tried. Links to Bolt documentation and the exact section you are working on solving a problem about would also help. What is this token you're talking about, where does it e from and where is the documentation for that? Etc. – anatolhiman Commented Aug 13, 2021 at 3:48
Add a ment  | 

1 Answer 1

Reset to default 9

Instead of a user token, I'd remend using a bot token to call users.info (https://api.slack./methods/users.info). You will need to request the users:read and the users:read.email scopes in order for the email to be returned in the API call. When you install your app on your Workspace your bot token will appear in the OAuth & Permissions page of your Developer Config site (https://api.slack./apps). Your app should be listening for the app_home_opened event. When a user opens the App Home the user_id will be returned in the event payload. You can then use that user_id to call users.info and get the user email.

本文标签: How to get the current user email address for Slack bot using Bolt for JavaScript(NodeJS)Stack Overflow