A Slack bot that automatically detects and marks duplicate URLs shared in channels within the last 24 hours.
- Monitors channels for URL sharing
- Detects duplicates within 24 hours
- Marks duplicates with a
:repeat:emoji - Smart URL matching - treats
https://example.com/page?ref=123andexample.com/pageas the same - Manual scanning with
@bot check duplicates
npm install @slack/bolt dotenv- Go to api.slack.com/apps
- Create New App → From an app manifest
- Paste this manifest:
display_information:
name: URL Duplicate Detector
description: Automatically detects and marks duplicate URLs shared in channels
features:
bot_user:
display_name: url-duplicate-bot
always_online: false
slash_commands:
- command: /check-duplicates
description: Scan current channel for duplicate URLs
oauth_config:
scopes:
bot:
- channels:history
- reactions:write
- chat:write
- commands
- app_mentions:read
settings:
event_subscriptions:
bot_events:
- message.channels
- app_mention
socket_mode_enabled: true- Bot Token: OAuth & Permissions → Install to Workspace → Copy the
xoxb-token - App Token: Basic Information → App-Level Tokens → Generate Token with
connections:writescope - Signing Secret: Basic Information → Copy signing secret
SLACK_BOT_TOKEN=xoxb-your-bot-token
SLACK_APP_TOKEN=xapp-your-app-token
SLACK_SIGNING_SECRET=your-signing-secret
PORT=3000node bot.js- Add bot to channel:
/invite @url-duplicate-bot - Share URLs - duplicates get marked automatically
- Manual scan:
@bot check duplicates - Check stats:
@bot cache stats
- Extracts URLs from messages using regex
- Normalizes URLs (removes protocols, query params, etc.)
- Caches URLs for 24 hours
- Marks duplicates with emoji reactions
- Auto-cleans old cache entries
Edit these values in bot.js:
const DUPLICATE_EMOJI = 'repeat'; // Change the emoji
const CHECK_HOURS = 24; // Change time windowBot not responding?
- Check Socket Mode is enabled
- Verify tokens are correct
- Make sure bot is in the channel
Permission errors?
- Reinstall app after changing scopes
- Check OAuth permissions match the manifest