Table of Contents
IntroductionJason Lengstorf introduces the course and makes the case for using chatops to improve communication processes and reduce administrative tasks.
Project OverviewJason walks through the accounts and tooling required for the course. GitHub, Slack, Notion, and Netlify accounts will be required to complete the course, along with Node version 16 and the Netlify CLI. The free tier of each platform is all that is required.
Creating a Netlify TunnelJason sets up the live tunnel using the Netlify CLI. The live tunnel makes the local development environment publicly available through a URL generated by Netlify.
Slack App SetupJason creates the Slack application and adds it to the test workspace. Scope permissions are assigned, and the slash command is configured.
API CredentialsJason saves the API credentials in the project and uses them to permit the application to send messages back through the API to the user. A utility method is created to eliminate duplicate boilerplate code for fetch requests.
Sending a CommandJason creates a function for handling the slash command from Slack. When the command is sent to the API, the handler validates the input and returns a message to Slack. Before the slash command can be run, the application must be added to the channel.
Exploring Slack Bot Features
Securing the ApplicationJason creates another utility method for ensuring requests to the Slack bot are API requests from Slack and not a malicious third party. The SLACK_SIGNING_SECRET environment variable is combined with a hashing algorithm to authenticate the request.
Slack Block KitJason introduces the Slack Block Kit UI framework. It allows developers to customize the order and appearance of information in the application. Users can be guided through the application's capabilities with composable, updating, and sequencing blocks.
Generating a ModalJason uses a modal to display the blocks when the command is triggered. The handleSlashCommand method will send a modal when it receives the "/foodfight" slash command.
Handling User InputJason updates the application endpoint to handle the user input and return a message to Slack. The returned message displays in the same channel and includes a mention of the user along with their submitted message.
Handling a ShortcutJason creates a shortcut in the Slack UI to ask a user to use the slash command. This is encourages team members to adhere to a process in a less intrusive way and reduces friction on the team.
Using a Notion Database
Integration with NotionJason creates a Notion integration which will allow the Slack application to send data to a Notion database. An example database is provided and can be duplicated into individual Notion accounts. A notionAPI helper method is also created.
Getting Items from NotionJason creates a helper method to retrieve a list of items from the Notion database. It filters based on the status of "new" so items already in progress or completed are not returned.
Saving Items to NotionJason creates a helper method to save items to the Notion database. The saveItem method will get called any time a new food fight message is submitted from the modal in Slack.
Creating a ReminderJason creates a cron job to run at a set interval and posts a list of unaddressed items to the slack channel.
Deploying to NetlifyThe application code and cron job are committed and pushed to the remote GitHub repo. Netlify is configured to deploy the application from a specific branch.