This bot will send announcements into a channel of your choice (chosen during the install process). Users can DM @announcebot
to get their announcements into a review queue. Once the approver (set to be the app installer) gives the thumbs up, the user will get a message that gives them the option to post the announcement at their leisure.
This sample app uses the Slack Event Adapter, and the Slack module for button and dialog fuctionality.
- Create an app at api.slack.com/apps
- Click on
Bot Users
- Add a bot user with a descriptive name and make sure it always stays online
- Click on
Incoming webhooks
and enable the feature - Scroll to the bottom of the page and click 'Add New Webhook to Team'
- During the install process, be sure to associate the webhook with announcements channel you'd like to enable approved posting for (such as #general)
- Get the code
- Either clone this repo and run
npm install
- Or visit https://glitch.com/edit/#!/remix/slack-announcements-approval-blueprint
- Either clone this repo and run
- Set the following environment variables in
.env
(copy from.env.sample
):SLACK_CLIENT_TOKEN
: Your app'sxoxp-
token (available on the Install App page)SLACK_BOT_TOKEN
: Your app'sxoxb-
token (available on the Install App page)SLACK_WEBHOOK_URL
: Your app's incoming webhook URL (available on the Incoming Webhook page)SLACK_ANNOUNCEMENT_CHANNEL
: The name of the channel where the incoming webhook will post (available on the Incoming Webhook page)SLACK_VERIFICATION_TOKEN
: Your app's Verification Token (available on the Basic Information page)
- If you're running the app locally:
- Start the app (
npm start
) - In another windown, start ngrok on the same port as your webserver (
ngrok http $PORT
)
- Start the app (
- Go back to the app settings and click on Events Subscriptions
- Set the Request URL to your ngrok or Glitch URL + /slack/events
- On the same page, subscribe to the
message.im
Bot event
- In the app settings, click on Interactive Components
- Set the Request URL to your ngrok or Glitch URL + /slack/actions