Slack Add Bot To Channel
Before going further, we assume that you already have: Create a Slack App if you haven't. Click the Fill the We recommand creating a new workspace for experiment. You can find the The You can set those permissions in Slack Developer Console → ${YourApp} → OAuth & Permissions → Scopes → Bot Token Scopes Click the The Click the This is the page for the Slack workspace authorizes to the Slack app. Click the Now, you installed the Slack app in your Slack workspace. This is also the place where you can get the access token Bottender need. To enable Slack channels, you can start either from new or existing Bottender apps. Create Bottender App is the best way to start building a new app in Bottender. To create a project, run: Make sure to select the After you go through the steps, First, you must have a Make sure to set the By default, the Bottender server listens to the Slack requests on the We highly recommend setting your sensitive config using Bottender utilizes the dotenv package to load your environment variables when developing your app. To make a Slack bot work, you must prepare the following environment variables, which you may put into your You can find Slack access token in Slack Developer Console → ${YourApp} → OAuth & Permissions → Bot User OAuth Access Token After you get your Slack Access Token, paste the value into the You can find Slack signing secret in Slack Developer Console → ${YourApp} → Basic Information → App Credentials → Signing Secret. After you get your Slack Signing Secret, paste the value into the We recommend using signing secret instead of verification token, but we also support verification token. You can find Slack verification token in Slack Developer Console → ${YourApp} → Basic Information → App Credentials → Verification Token. After you get your Slack Verification Token, paste the value into the After finishing the above settings, you can start your server with Slack webhook event listening using the following commands: When you run bottender in development mode, Bottender automatically run up a ngrok client, and then you can get the information of webhook URL from the console like this: Then, you have to copy your Slack webhook URL to Slack Developer Console → ${YourApp} → Event Subscriptions, where you can pick which bot events to subscribe. Turn on the switch. Fill the Request URL field with your Slack webhook URL. You can see the word Now, open the Add the following events to receive the corresponding webhook requests: For more information about Slack Events, please refer to Slack's official doc, API Event Types Click the Reinstall your app. Now, you can see the slack app require more permissions. Click the The next thing you can do is teaching your bot to echo. Note: If your bot doesn't respond after webhook settings, please take a closer look at bot events you subscribed to. Slack doesn't pick any bot events subscription by default. The first bot event you may subscribe to is Requirements
Create a Slack App
Create New App
button.App Name
and Development Slack Workspace
and then click the Create App
button.Install Slack App to Workspace
Install App to Workspace
button in Slack Developer Console → ${YourApp} → OAuth & PermissionsInstall App to Workspace
button is disabled. To enable the button, you need to setup at least one of the permissions the Slack app need.Add an OAuth Scope
button in the Bot Token Scopes
section to create a chat:write
OAuth Scope, which allows Slack app to send messages as a bot user.Install App to Workspace
button is enabled now.Install App to Workspace
button.Allow
button.Enabling Slack Channels
New Bottender Apps
npx create-bottender-app my-app
slack
option:bottender.config.js
and .env
are generated automatically for further channel settings.Existing Bottender Apps
bottender.config.js
file includes the following settings:
module.exports = { channels: { slack: { enabled: true, path: '/webhooks/slack', accessToken: process.env.SLACK_ACCESS_TOKEN, signingSecret: process.env.SLACK_SIGNING_SECRET, // verificationToken: process.env.SLACK_VERIFICATION_TOKEN, // deprecated, use signingSecret }, }, };
channels.slack.enabled
field to true
./webhooks/slack
path. However, you can overwrite the path by assigning the preferred webhook path in the channels.slack.path
field.process.env
, so you could avoid any credentials get exposed.Environment Configuration
.env
file later:
Slack Access Token
SLACK_ACCESS_TOKEN
field in your .env
file:
# .env SLACK_ACCESS_TOKEN=<YOUR SLACK ACCESS TOKEN>
Slack Signing Secret
SLACK_SIGNING_SECRET
field in your .env
file:
# .env SLACK_SIGNING_SECRET=<YOUR SLACK SIGNING SECRET>
Slack Verification Token (Deprecated)
SLACK_VERIFICATION_TOKEN
field in your .env
file:
# .env # SLACK_VERIFICATION_TOKEN=<YOUR SLACK VERIFICATION TOKEN> # deprecated, use `SLACK_SIGNING_SECRET` instead
Webhook
# in production mode npm start # or in development mode npm run dev
App has started slack webhook URL: https://42bbf602.ngrok.io/webhooks/slack server is running on 5000 port...
Verified
after setting the webhook URL.Subscribe to bot events
block to subscribe some events.
Save Changes
button.Allow
button. Now you can chat with the slack bot in direct message channel or in any channel the slack bot in.
message.im
, which is the event whenever a user posts a direct message to your bot.
Slack Add Bot To Channel
Source: https://bottender.js.org/docs/en/channel-slack-setup
Posted by: etheridgethersen.blogspot.com
0 Response to "Slack Add Bot To Channel"
Post a Comment