FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
charmaine
charmaineslackBotExample
Build a Slack bot!
Public
Like
slackBotExample
Home
Code
2
README.md
H
main.tsx
Branches
1
Pull requests
Remixes
5
History
Environment variables
2
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.
Sign up now
Code
/
README.md
Code
/
README.md
Search
6/12/2025
Viewing readonly version of main branch: v10
View latest version
README.md

Build a Slack Bot

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.

Slack bot reply example

1. Remix the Slack bot template

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.

2. Create a Slack app

  • Go to Slack API and create a new app From Scratch.
  • Name your app and select your workspace.

Slack app creation

3. Add environment variables

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).

Find verification token

4. Set up event subscriptions

  • 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.

Event subscription setup

5. Set bot token scopes

In OAuth & Permissions → Scopes, add:

  • app_mentions:read (should already be there)
  • chat:write

Bot token scopes

6. Install your app

  • Go to Settings → Install App and install the app to your workspace.

Install app

7. Add your OAuth token

  • In OAuth & Permissions, copy the Bot User OAuth Token.
  • Update your val's slackToken environment variable with this value.

Copy OAuth token

8. Invite your bot to a channel

  • Invite the bot to any channel you want it to respond in. Invite bot to channel
  • Mention the bot and your val will reply with a hello! Bot reply example

Need help? Join us on Val Town Discord and we'll help you get your Slack bot running!

Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.