This is a Slack Bot, using Vercel for serverless deployment and Upstash Redis for database.
Simply fill the environmental variables defined below and your serverless functions will be up in seconds!
- Events:
- New channel created:
- When a new is channel created, posts a message to
general
channel stating that such an event happened.
- When a new is channel created, posts a message to
- Slackbot mentioned:
- Whenever the bot is mentioned, posts a
message to
general
channel stating that the bot was mentioned.
- Whenever the bot is mentioned, posts a
message to
- New channel created:
- Commands:
/note set <key> <value>
:- Sets a key value pair.
/note get <key>
:- Gets the value corresponding to the key
/note list-set <list_name> <item_as_string>
:- Adds the
<item_as_string>
to<list_name>
list as an item.
- Adds the
/note list-all <list_name>
:- Lists all the items in the
<list_name>
- Lists all the items in the
/note list-remove <list_name> <item_as_string>
:- Removes
<item_as_string>
from the<list_name>
- Removes
- P.S:
- All of the commands mentioned can be implemented as slackbot mentions rather than slash commands. For demonstration purposes, slash commands are also used. Use cases may differ.
-
Go to the Upstash Console and create a new database
Find the variables in the database details page in Upstash Console:
UPSTASH_REDIS_REST_URL
andUPSTASH_REDIS_REST_TOKEN
(These will be the env variables for vercel deployment)
- Go to Slack API Apps Page:
- Create new App
- From Scratch
- Name your app & pick a workspace
- Go to Oauth & Permissions
- Add the following scopes
- app_mentions:read
- channels:read
- chat:write
- chat:write.public
- commands
- Install App to workspace
- Basic Information --> Install Your App --> Install To Workspace
- Add the following scopes
- Create new App
- Note the variables (These will be the env variables for vercel deployment) :
SLACK_SIGNING_SECRET
:- Go to Basic Information
- App Credentials --> Signing Secret
- Go to Basic Information
SLACK_BOT_TOKEN
:- Go to OAuth & Permissions
- Bot User OAuth Token
- Go to OAuth & Permissions
- Click the deploy button:
- Fill the environmental variables defined above.
- After deployment, you can use the provided
vercel_domain
.
-
Go to Slack API Apps Page and choose relevant app:
- Go to Slash Commands:
- Create New Command:
- Command :
note
- Request URL :
<vercel_domain>/api/note
- Configure the rest however you like.
- Command :
- Create New Command:
- Go to Event Subscribtions:
- Enable Events:
- Request URL:
<vercel_domain>/api/events
- Request URL:
- Subscribe to bot events by adding:
- app_mention
- channel_created
- Enable Events:
- Go to Slash Commands:
-
After these changes, Slack may require reinstalling of the app.