I developed this Slack Event App as extra-curricular project during my Full-Stack Web Development Course at CareerFoundry. This project was primarily an exercise in customizing an existing app boilerplate and connecting it to the app. The purpose of the slack app is to facilitate organizing a company's internal events or parties. Once customized the slack app will listen for an event — in this case, new team members joining a specific channel (WELCOME_CHANNEL) created for the company party. Then it will respond to that event with an interactive message that presents them with a form to fill out. The contents of that form will then be posted to a separate channel administered by the internal events team (POST_TO_CHANNEL).
The app is written (by slack) in Node.js and makes use of the Web, Events API, and Conversations APIs. It covers topics such as message formatting and interactive messages. The app is intended to work as a custom, internal app, but the general principles would apply to any other app built for public distribution in the Slack app directory, as well.
Since the elements of the app were predetermined, the challenge was to navigate within the set parameters defined by slack. For example when customizing the dialog form asking the user to fill in certain information, only certain form elements were supported by slack (text, textarea, select). So in order to customize the app within the given parameters, it was necessary to consult the "Developer guides and docs" section and only use the elements described there.
Also, the boilerplate did not include any logging. But I was only able to figure out the correct channel IDs for the "WELCOME_CHANNEL" and the internal event planning team's channel "POST_TO_CHANNEL" by adding logging.
Create slack workspace, add app, add description and icon
- Download existing code
- Install dependencies used
- copy oath token and slack verification token into .env file to keep them secret (file is not published on Github)
- finding out Channel IDs to WELCOME_CHANNEL and POST_TO_CHANNEL via logging
Create app on web server Heroku
- add heroku remote to existing Git repo
heroku git:remote -a slack-event-app
- Add heroku page (https://slack-event-app.herokuapp.com/slack/events) to event subscriptions with toggle on,
- Add event 'member joined channel'
Interactive message displays to welcome joined member and asks them to fill out form
Left Menubar --> Features --> OAuth & Permissions --> Scopes
7. Add URL route for interactive components "https://slack-event-app.herokuapp.com/slack/components”,
Left Menubar --> Features --> Interactivy & Shortcuts
The method dialog.open requires three arguments (auth token, already implemented), dialog definition in form of a JSON-encoded string and a trigger_id. In order to generate this id, it is necessary to implement a user trigger to open dialog only when user interaction takes place. The user trigger is created in form of a slash command.
The API method chat.postMessage sends filled out form to internal events team (Channel: POST_TO_CHANNEL). It takes the arguments token, channel and attachments (or blocks or texts). As attachments I chose the categories "Guest Count", "Dietary Requirements" and preferred "Weekdays" for the party.