slack-friendly
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.
slack-webhook.ts
https://morgante--5e1fc510691511f0ae850224a6c84d84.web.val.run
A simple Slack app that monitors your messages and sends you a private reminder when you end messages with a period, encouraging you to be more friendly in your communication.
- Monitors only messages from the app owner (you)
- Detects messages ending with periods
- Sends private DM reminders with friendly suggestions
- Ignores bot messages, edits, and very short messages
- Go to Slack API and click "Create New App"
- Choose "From scratch"
- Give it a name like "Friendly Reminder Bot"
- Select your workspace
In your Slack app settings:
- Go to "OAuth & Permissions"
- Add these Bot Token Scopes:
chat:write
- To send messageschannels:history
- To read channel messagesgroups:history
- To read private channel messagesim:history
- To read direct messagesmpim:history
- To read group direct messages
- In "OAuth & Permissions", click "Install to Workspace"
- Authorize the app
- Copy the "Bot User OAuth Token" (starts with
xoxb-
)
In Val Town, set these environment variables:
SLACK_BOT_TOKEN
: Your bot token from step 3SLACK_OWNER_USER_ID
: Your Slack user ID (see instructions below)
- In Slack, click on your profile picture
- Click "Profile"
- Click the three dots menu
- Click "Copy member ID"
- In your Slack app settings, go to "Event Subscriptions"
- Enable events
- Set the Request URL to your Val Town webhook URL:
https://[your-username]-slackwebhook.web.val.run
- Under "Subscribe to bot events", add:
message.channels
- Messages in public channelsmessage.groups
- Messages in private channelsmessage.im
- Direct messagesmessage.mpim
- Group direct messages
- Save changes
After adding event subscriptions, you'll need to reinstall the app to your workspace with the new permissions.
- Slack sends webhook events to the Val Town endpoint
- The webhook filters for messages from you (the owner)
- If a message ends with a period, it sends you a private DM reminder
- The reminder suggests using friendlier punctuation like ! or π
Send a message in any channel that ends with a period, like:
This is a test message.
You should receive a private DM from the bot with a friendly reminder!
- Only processes messages from the configured owner user ID
- Ignores all other users' messages
- Sends reminders only as private DMs to the owner