Learn With Jason
Course Description
Create custom Slack bots to automate your team's everyday tasks and improve company communication! You'll create Slack bot commands and customize the information displayed using the Slack Block Kit UI framework. Secure your Slack bot against unauthorized API calls and integrate it with a Notion database to save and retrieve data. Lastly, you'll implement automated reminders using cron jobs and deploy your Slack bot!
This course and others like it are available as part of our Frontend Masters video subscription.
Preview
CloseLearn Straight from the Experts Who Shape the Modern Web
Your Path to Senior Developer and Beyond
- 200+ In-depth courses
- 18 Learning Paths
- Industry Leading Experts
- Live Interactive Workshops
Table of Contents
Introduction
Section Duration: 16 minutes
- Jason Lengstorf introduces the course and makes the case for using chatops to improve communication processes and reduce administrative tasks.
- Jason 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.
Application Setup
Section Duration: 35 minutes
- Jason 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.
- Jason creates the Slack application and adds it to the test workspace. Scope permissions are assigned, and the slash command is configured.
- Jason 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.
- Jason 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
Section Duration: 45 minutes
- Jason 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.
- Jason 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.
- Jason 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.
- Jason 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.
- Jason 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
Section Duration: 29 minutes
- Jason 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.
- Jason 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.
- Jason 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.
- Jason creates a cron job to run at a set interval and posts a list of unaddressed items to the slack channel.
- The 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.
Wrapping Up
Section Duration: 4 minutes
- Jason wraps up the course by sharing some additional application ideas for ChatBot applications.
Learn Straight from the Experts Who Shape the Modern Web
- In-depth Courses
- Industry Leading Experts
- Learning Paths
- Live Interactive Workshops