/Slack_Event_App

This project was primarily an exercise in customising an existing app boilerplate and connecting it to the web.

Primary LanguageJavaScript

Slack Event App

open dialog form in chat

Description and Objective

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).

What technology used and why?

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.

What challenges did I face, what did I learn?

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.

Steps

1. Setting up Environment

Create slack workspace, add app, add description and icon Basic information slack app

2. Configure node.js App

  • 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

Logging

Create app on web server Heroku

  • add heroku remote to existing Git repo
heroku git:remote -a slack-event-app

Screenshot confirmation heruku app is running

3. Enable listening for Events

Enable Event Subscriptions

Event Listener Successful

Interactive message displays to welcome joined member and asks them to fill out form

welcome message in chat

4. Install App in workspace to generate tokens

install app to workspace

5. Add permission scope to send an ephemeral message to WELCOME_CHANNEL

required parameters for ephemeral message

Left Menubar --> Features --> OAuth & Permissions --> Scopes

add bot token scopes

6. Specify details of form presented to joined members (in index and dialog.js)

7. Add URL route for interactive components "https://slack-event-app.herokuapp.com/slack/components”,

Left Menubar --> Features --> Interactivy & Shortcuts

8. Handling request to dialog.open

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.

Successful: New member opens and fills out form

open dialog form in chat

9. Specify arguments to use method chat.postMessage

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.

Successful: Form content is posted to separate channel of internal event planning

internal event planning channel receives result of form submission