Public
Like
slackBotExample
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v10View latest version
Build and host a Slack bot on Val Town in minutes!
This guide walks you through creating a Slack bot that replies when mentioned in a channel. You'll use Val Town to host your bot and Slack's API to connect it to your workspace.
Get started quickly by remixing our Slack bot example:
- Remix this val to create your own copy.
Copy its HTTP endpoint URL (via the ... menu for main.tsx
). You'll use this in
your Slack app setup.
- Go to Slack API and create a new app From Scratch.
- Name your app and select your workspace.
In your val's sidebar, add these Environment Variables
:
- slackVerificationToken: Copy from your Slack app's Settings → Basic Information → Verification Token.
- slackToken: Leave empty for now (you'll fill this in after installing the app).
- In your Slack app, go to Features → Event Subscriptions
- Enable events and paste your val's HTTP endpoint in Request URL.
- Subscribe to the app_mention event under Subscribe to bot events.
In OAuth & Permissions → Scopes, add:
app_mentions:read
(should already be there)chat:write
- Go to Settings → Install App and install the app to your workspace.
- In OAuth & Permissions, copy the Bot User OAuth Token.
- Update your val's
slackToken
environment variable with this value.
- Invite the bot to any channel you want it to respond in.
- Mention the bot and your val will reply with a hello!
Need help? Join us on Val Town Discord and we'll help you get your Slack bot running!