Sample Slack app that uses the Events API and interactive message to implement an approvals workflow
MIT License
✨ Updated October 2020: As we have introduced some new features, this tutorial and the code samples have been updated! All the changes from the previous version of this example, read the DIFF.md
This app lets its bot to post an approved message into a public channel- A user DMs to bot to create an announcement, and once it is approved by another user, the message will be posted to public.
User A ("girlie_mac") wants to announce about donuts on #random
channel, and User B ("Slack Boss") approves it:
This app uses:
chat.postMessage
to post messagesconversations.open
to send direct messages from the bot to a userusers.conversations
to get channels the bot user is a member ofviews.publish
to publish a view to the Home tabviews.open
to open a Block Kit modal and collect information for the announcement to be sentconversations.history
to view historical messages between the bot and usermessage.im
to see when a DM message is sentClone the repo (then npm install
to install the dependencies), or if you'd like to work on Glitch, remix from the button below:
channels:read
chat:write
im:write
im:history
/events
(e.g. https://your-server.com/events
)message.im
app_home_opened
To enable interactive UI components (This example uses buttons):
/interactions
To dynamically populate a drop-down menu list in a dialog (This example uses a list of channels):
https://your-server.com/options
) in the Message Menus sectionTo enable App Home:
Home Tab
and Messages Tab
are enabled.Set Environment Variables and run:
.env
(copy from .env.sample
):
SLACK_ACCESS_TOKEN
: Your app's xoxb-
token (available on the Install App page after the installation)SLACK_SIGNING_SECRET
: Your app's Signing Secret (available on the Basic Information page)npm start
)On Slack client, "invite" your bot to appropriate channels. The bot cannot post messages to the channels where the bot is not added.