Slack App Setup Guide
Complete guide for setting up the Yappa Knowledge Hub Slack app.
Prerequisites
- Slack workspace with admin permissions
- Node.js 18.0.0 or higher installed
- Access to create Slack apps at https://api.slack.com/apps
Quick Setup with Manifest
Step 1: Create the Slack App
- Go to https://api.slack.com/apps
- Click "Create New App"
- Select "From an app manifest"
- Choose your workspace
- Copy the contents of
slack-app-manifest.yamlfrom this repository - Paste it into the YAML tab
- Click "Next" and review the configuration
- Click "Create"
Step 2: Configure Socket Mode
Socket Mode allows your app to receive events without exposing a public URL.
- In your app settings, go to "Socket Mode" in the left sidebar
- Toggle "Enable Socket Mode" to ON
- Click "Generate" to create an app-level token
- Name it "Socket Mode Token" and add the
connections:writescope - Click "Generate"
- Copy the token (starts with
xapp-) and save it asSLACK_APP_TOKENin your.envfile
Step 3: Install the App to Your Workspace
- In the left sidebar, click "Install App"
- Click "Install to Workspace"
- Review the permissions and click "Allow"
- Copy the "Bot User OAuth Token" (starts with
xoxb-) - Save it as
SLACK_BOT_TOKENin your.envfile
Step 4: Get Your Signing Secret
- In the left sidebar, click "Basic Information"
- Scroll down to "App Credentials"
- Copy the "Signing Secret"
- Save it as
SLACK_SIGNING_SECRETin your.envfile
Step 5: Configure Environment Variables
Create or update your .env file in the backend directory:
# Slack Configuration
SLACK_BOT_TOKEN=xoxb-your-bot-token-here
SLACK_SIGNING_SECRET=your-signing-secret-here
SLACK_APP_TOKEN=xapp-your-app-token-here
# Server Configuration
PORT=3000Step 6: Start the Application
cd /path/to/yappa-knowledge-hub
npm install
npm startYou should see:
[Yappa Kennishub] Bot is actief op poort 3000
[Yappa Kennishub] Socket Mode: ingeschakeldManual Setup (Without Manifest)
If you prefer to configure the app manually or need to modify an existing app:
OAuth & Permissions
Navigate to "OAuth & Permissions" and add these Bot Token Scopes:
Chat & Messaging:
chat:write- Send messages as the botchat:write.public- Send messages to channels without joining
Commands:
commands- Add slash commands
Reactions:
reactions:read- View emoji reactions
Files:
files:read- View files shared in channels
Channels & Conversations:
channels:history- View messages in public channelschannels:read- View basic channel informationgroups:history- View messages in private channelsgroups:read- View basic private channel informationim:history- View messages in direct messagesim:read- View basic direct message informationmpim:history- View messages in group direct messagesmpim:read- View basic group direct message information
Users:
users:read- View people in the workspaceusers:read.email- View email addresses of people
App Home:
app_mentions:read- View messages that mention the app
Slash Commands
Navigate to "Slash Commands" and create:
Command: /knowledge
- Request URL:
https://your-domain.com/slack/events(not needed for Socket Mode) - Short Description: Manage and search the Knowledge Hub
- Usage Hint:
[dashboard|add|search <query>|help] - Escape channels, users, and links: Unchecked
Interactivity & Shortcuts
Navigate to "Interactivity & Shortcuts":
- Toggle "Interactivity" to ON
- Request URL:
https://your-domain.com/slack/events(not needed for Socket Mode)
Create Message Shortcut:
- Name: Save to Knowledge Hub
- Short Description: Save this message to the Knowledge Hub
- Callback ID:
save_to_knowledge
Create Global Shortcut:
- Name: Quick Add Knowledge
- Short Description: Quickly add new knowledge to the hub
- Callback ID:
quick_add_knowledge
Event Subscriptions
Navigate to "Event Subscriptions":
- Toggle "Enable Events" to ON
- Request URL:
https://your-domain.com/slack/events(not needed for Socket Mode)
Subscribe to Bot Events:
message.channels- Messages in public channelsmessage.groups- Messages in private channelsmessage.im- Direct messagesmessage.mpim- Group direct messagesapp_home_opened- User opens App Homefile_shared- File is sharedreaction_added- Emoji reaction is addedapp_mention- App is mentioned
App Home
Navigate to "App Home":
- Home Tab: Toggle ON
- Messages Tab: Toggle OFF
- Edit the bot display name to "Yappa Knowledge Hub"
Feature Configuration
Slash Command Usage
The /knowledge command supports multiple subcommands:
/knowledge Open the dashboard
/knowledge dashboard Open the dashboard
/knowledge add Open add knowledge modal
/knowledge search <query> Search the knowledge base
/knowledge help Show help messageMessage Shortcuts
Save to Knowledge Hub:
- Hover over any message
- Click the three dots (More actions)
- Select "Save to Knowledge Hub"
- Fill in the modal with title, category, target groups, and tags
- Click "Save"
Global Shortcuts
Quick Add Knowledge:
- Click the lightning bolt icon in the message input area
- Select "Quick Add Knowledge"
- Fill in the form with title, content, category, URL (optional), and tags
- Click "Add"
Emoji-Based Capture
React to any message with one of these emojis to trigger a save prompt:
- 🧠 (brain)
- 💡 (bulb)
- 🔖 (bookmark)
- 📚 (books)
The bot will send you an ephemeral message with a button to save the message.
URL Detection
When a URL is posted in a channel where the bot is present:
- The bot automatically scrapes metadata (title, description, image)
- Sends an ephemeral message to the user who posted it
- Offers to save the URL to the knowledge base with pre-filled information
File Sharing
When a file is shared in a channel:
- The bot detects the file
- Sends an ephemeral message to the user
- Offers to save file information to the knowledge base
App Home
The App Home tab provides:
- Welcome message and quick action buttons
- Statistics (total items and categories)
- Browse by thematic list
- Recently added items
- Tips for using the app
To access:
- Click on the app name in the Slack sidebar
- Select the "Home" tab
Troubleshooting
Bot Not Responding to Commands
Check:
- Bot is running (
npm startshows no errors) - Socket Mode is enabled
SLACK_APP_TOKENis correctly set in.env- App is installed to the workspace
Solution:
# Restart the bot
npm startEvents Not Being Received
Check:
- Socket Mode is enabled in app settings
- All required event subscriptions are added
- Bot has necessary scopes
Solution:
- Go to "Event Subscriptions" in app settings
- Verify all events are listed under "Subscribe to bot events"
- Reinstall the app if scopes were added after installation
Shortcuts Not Appearing
Check:
- Shortcuts are created with correct callback IDs
- App is reinstalled after adding shortcuts
Solution:
- Go to "Interactivity & Shortcuts"
- Verify shortcuts exist with callback IDs:
save_to_knowledge(message shortcut)quick_add_knowledge(global shortcut)
- Reinstall the app to workspace
Modal Not Opening
Check:
- Trigger ID is valid (expires after 3 seconds)
- Modal payload is valid JSON
- No network errors in console
Solution:
- Check application logs for errors
- Verify modal structure matches Slack's Block Kit format
Emoji Reactions Not Triggering
Check:
reaction_addedevent is subscribedreactions:readscope is granted- Reaction is one of: brain, bulb, bookmark, books
Solution:
- Verify event subscription in app settings
- Check bot logs for reaction events
- Ensure bot is in the channel (or use public channels)
URL Detection Not Working
Check:
message.channels(and other message events) are subscribed- Bot is in the channel or has
chat:write.publicscope - URL is valid (starts with http:// or https://)
Solution:
- Add bot to the channel:
/invite @Yappa Knowledge Hub - Check logs for URL detection errors
- Verify URL scraper service is working
File Sharing Not Detected
Check:
file_sharedevent is subscribedfiles:readscope is granted- Bot is in the channel where file was shared
Solution:
- Add
file_sharedto event subscriptions - Grant
files:readscope - Reinstall app
- Invite bot to channel
App Home Not Loading
Check:
app_home_openedevent is subscribed- Home tab is enabled in App Home settings
- No errors in application logs
Solution:
- Enable Home Tab in "App Home" settings
- Verify
app_home_openedevent subscription - Check logs when opening App Home
Socket Mode Connection Issues
Check:
SLACK_APP_TOKENis correct and starts withxapp-- Token has
connections:writescope - No firewall blocking WebSocket connections
Solution:
# Verify token in .env
cat .env | grep SLACK_APP_TOKEN
# Check for connection errors in logs
npm startPermission Errors
Check:
- All required scopes are granted
- App was reinstalled after adding new scopes
Solution:
- Go to "OAuth & Permissions"
- Verify all scopes from the list above are present
- Click "Reinstall App" if scopes were added
- Update
SLACK_BOT_TOKENif it changed
Testing the App
Test Slash Command
/knowledge helpExpected: Help message appears
Test Message Shortcut
- Post a test message
- Click three dots "Save to Knowledge Hub" Expected: Modal opens with save form
Test Global Shortcut
- Click lightning bolt in message input
- Select "Quick Add Knowledge" Expected: Modal opens with add form
Test Emoji Reaction
- Post a test message
- React with 🧠 Expected: Ephemeral message with save button
Test URL Detection
- Post a message with a URL:
https://example.comExpected: Ephemeral message with URL preview and save button
Test App Home
- Click app name in sidebar
- Open "Home" tab Expected: Dashboard with stats and recent items
Security Best Practices
Never commit tokens to version control
- Add
.envto.gitignore - Use environment variables for all secrets
- Add
Rotate tokens regularly
- Regenerate tokens every 90 days
- Update
.envfile with new tokens
Limit scope permissions
- Only request scopes your app needs
- Review permissions periodically
Use Socket Mode for development
- No need to expose public URLs
- Easier local development
Monitor app usage
- Check Slack app analytics
- Review error logs regularly
Production Deployment
For production deployment without Socket Mode:
Set up a public HTTPS endpoint
- Use a service like Heroku, AWS, or DigitalOcean
- Ensure SSL/TLS is properly configured
Update Request URLs
- Go to "Slash Commands" and update Request URL
- Go to "Interactivity & Shortcuts" and update Request URL
- Go to "Event Subscriptions" and update Request URL
Disable Socket Mode
- Toggle Socket Mode to OFF
- Remove
socketMode: truefrom app configuration - Remove
SLACK_APP_TOKENfrom environment
Update app.js
javascriptconst app = new App({ token: process.env.SLACK_BOT_TOKEN, signingSecret: process.env.SLACK_SIGNING_SECRET, // Remove socketMode and appToken });Set up process manager
bashnpm install -g pm2 pm2 start src/app.js --name yappa-knowledge-hub pm2 save pm2 startup
Support
For issues or questions:
- Check the troubleshooting section above
- Review Slack API documentation: https://api.slack.com/
- Check application logs for error messages
- Verify all configuration steps were completed