To get started, we’ll need a workspace to install our bot in. A Slack workspace is a way to group communication within an organization. Everyone in an organization can belong to one workspace, which is then subdivided into multiple channels.
Install Slack on your device and create a new workspace. Slack will then send a 6-digit code to your email that you can use for verification. Now for the fun part! Give your workspace a name; for this tutorial, we’ll create a fictional company called DaCompany.
Next, Slack will prompt you to enter the name of the project you’re working on. You can call the project whatever you want. You can skip the last step where Slack prompts you to add other team members.
Now, we’ll create a new Slack app. Slack apps are small applications that provide specific functionalities within a workspace. You can install a preexisting Slack application by signing into your Slack workspace and searching for applications within the Slack app directory.
To create a new Slack application, head to the Slack API dashboard. Click the Create New App button on the top right.
Then select the option to create "From an app manifest", select the workspace, and paste the YAML file located in ./config/app-manifest.yaml
- Into your slack application settings, select
OAuth & Permissions
and copy the value ofBot User OAuth Token
. - Then go to general and scroll down until App Level Tokens, generate one with the scope
connections:write
and copy the token information - In the same general section scroll to
App Credentials
and copy the value ofSigning Secret
When you have those 3 tokens copied it's time to generate an .env
file into the root of this project.
.env file
content:
SLACK_BOT_TOKEN=<Value of Bot User OAuth Token>
SLACK_APP_TOKEN=<Value of App-Level Tokens>
SLACK_SIGNING_SECRET=<Value of Signign Secret>
🛑 Since this project is pretty much an MVP, I decided to use SQLite to simplify things, please DON'T USE THIS ON PRODUCTION. 🛑
yarn build # For building the code with typechecking
yarn build:swc # For building without typechecking
yarn start # For running the code builded
Or in development
mode:
yarn dev # For running the code in development thanks to swc and nodemon
⚠️ No typechecking made in dev mode
yarn test # For running unit test
yarn test:watch # For watching unit test
Note: This uses rust compiler SWC
Language: Typescript
Build a Slack app that can be added to individual shared or Slack Connect channels When added, the app can read messages incoming into the channel
The app identifies users who belong to the workspace (e.g, share the same domain as the workspace) vs external users (e.g, implied customers/guests who do not have the same email domain as the workspace)
The Slack app's Home page displays the messages that have come from 1) channels where the app has been added and 2) messages where the sender is an external user
When messages come in, they default to a "New" status
In the Slack app Home tab, users can see the messages that have come in, and they can use a picklist to choose 2 other statuses: "Open" or "Complete" When the message status is moved to "Complete," the messages are hidden from the Home tab view.