I use: https://www.npmjs.com/package/@slack/interactive-messages and https://www.npmjs.com/package/@slack/events-api for my Slack/Node.js bot. I catch any interaction to the bot using:
slackEvents.on(‘message’, (message: any, body: any) => …);
Before Slack users can chat with the bot they must integrate it into their workspace using: https://api.slack.com/docs/sign-in-with-slack which is available in my website for logged on users. On successful response I get two different access tokens:
- xoxb based auth tokens from bot_access_token (if im correct this is workspace based access token)
- xoxp based auth tokens from access_token (if im correct this is user based access token)
I store above tokens in the users record in my database. I use the xoxb token to execute methods from my bot engine which also has access to the database, methods such as: https://api.slack.com/methods/chat.postMessage
However, once the bot is integrated the bot is exposed to many users. Users that did not do the 'Sign in with slack'-process and does not have any xoxp or xoxb tokens in their user record in the database. What xoxb token can I use to chat.postMessage to them?
I see there is an OAuth Access Token (xoxp) and Bot User OAuth Access Token (xoxb) in the Slack API Bot Dashboard under ‘OAuth & Permission’ link. Is this a master xoxb token that can be used to chat.postMessage to all users in Slack in any workspace that integrated my app?