Setting Up the Slack App
This guide walks you through creating a Slack app and connecting it to mOperator. Even if you're not a developer, you can complete these steps by following along carefully.
Step 1: Create the Slack App
- Go to api.slack.com/apps
- Click "Create New App"
- Choose "From scratch"
- Give your app a name (e.g., "mOperator")
- Select the Slack workspace you want to use
- Click "Create App"
You should now see your app's settings page.
Step 2: Configure OAuth Scopes
mOperator needs specific permissions to read messages and send responses:
- In the left sidebar, click "OAuth & Permissions"
- Scroll down to "Scopes" → "Bot Token Scopes"
- Click "Add an OAuth Scope" and add these scopes one by one:
app_mentions:read — Read when the bot is mentionedchat:write — Send messagesfiles:read — Read attached filesfiles:write — Upload filesim:history — Read direct messagesusers:read — Get user informationusers:read.email — Get user email addresses (needed for approval workflow)channels:history — Read channel messagesgroups:history — Read private channel messagescommands — Enable slash commands
Your scopes list should look like this:
app_mentions:read
chat:write
commands
files:read
files:write
groups:history
channels:history
im:history
users:read
users:read.email
Step 3: Enable Event Subscriptions
- Click "Event Subscriptions" in the left sidebar
- Toggle "Enable Events" to ON
- In "Request URL", enter your app's URL:
- Local development: Not applicable (use proxy or skip this)
- Deployed to Vercel:
https://your-app.vercel.app/api/slack - Replace
your-app with your actual Vercel domain
- Once the URL is verified, scroll down to "Subscribe to bot events"
- Click "Add Bot User Event" and select:
app_mention — Bot was mentionedmessage.im — Direct message to bot
Step 4: Create Slash Commands
- Click "Slash Commands" in the left sidebar
- Click "Create New Command"
- Fill in:
- Command:
/moperator - Request URL:
https://your-app.vercel.app/api/slack/commands (or your local dev URL) - Short Description: "mOperator AI assistant"
- Usage Hint:
bug|feature|help
- Click "Save"
Step 5: Enable Interactivity (for Approval Workflow)
If you want to use the approval workflow for Salesforce write operations, you need to enable interactivity so Slack can send button clicks to your app:
- Click "Interactivity & Shortcuts" in the left sidebar
- Toggle "Interactivity" to ON
- In "Request URL", enter:
- Deployed to Vercel:
https://your-app.vercel.app/api/slack/interactions - Replace
your-app with your actual Vercel domain
- Click "Save Changes"
This enables the Approve/Deny buttons that appear when a non-authorized user triggers a Salesforce write operation. See the approval workflow section below for details on configuring AUTHORIZED_USER_EMAILS.
Step 6: Configure App Home
- Click "App Home" in the left sidebar
- Under "Messages Tab", toggle ON
- Enable these options:
- "Allow users to send messages"
- "Show Tab"
This lets users DM the bot directly.
Step 7: Install the App to Your Workspace
- Click "Install to Workspace" (or "Reinstall" if you made changes)
- Review the permissions and click "Allow"
- You'll be redirected back to Slack settings
Step 8: Copy Your Bot Token
- Go back to "OAuth & Permissions"
- Under "OAuth Tokens for Your Workspace", find "Bot User OAuth Token"
- It starts with
xoxb- — copy the entire token - Add it to your
.env.local:
SLACK_BOT_TOKEN=xoxb-your-copied-token-here
Step 9 (Optional): Get Your Bot User ID
This is only needed if you want the bot to access thread history:
- In the left sidebar, go to "Basic Information"
- Under "App Credentials", find "Bot User ID"
- It looks like
U12345678ABC - Add it to your
.env.local:
SLACK_BOT_USER_ID=U12345678ABC
Step 10: Test the Bot
- Go to your Slack workspace
- In any channel or DM, mention the bot:
@mOperator say hello - The bot should respond
Troubleshooting
"Request URL failed to validate"
- Make sure your app is deployed and the URL is correct
- If developing locally, you can skip this and deploy first, then come back to enable events
"Bot doesn't respond to messages"
- Check that you've installed the app to your workspace
- Verify all scopes are added (especially `app_mentions:read` and `chat:write`)
- Make sure the `SLACK_BOT_TOKEN` is set in your `.env.local`
"Can't use slash commands"
- Confirm `/moperator` command was created in Slash Commands settings
- Check that the Request URL points to `/api/slack/commands`
- Reinstall the app to your workspace after making changes
Approval Workflow
mOperator includes an approval workflow for Salesforce write operations (create, update, delete, bulk update, add to campaign). When a non-authorized user asks the bot to perform a write operation, the bot posts an approval request with Approve and Deny buttons in the Slack thread. An authorized user must click Approve before the operation executes.
Configuration
Add these to your .env.local:
# Comma-separated email addresses of authorized users (must match Slack profile emails)
AUTHORIZED_USER_EMAILS=admin@example.com,ops-lead@example.com
Optional: Slack user group ID for @mentioning approvers in approval messages
Find this in Slack Admin > User Groups > copy the group ID (e.g., S0123456789)
SLACK_APPROVER_GROUP_ID=S0123456789
You also need Redis configured for the approval store:
UPSTASH_REDIS_REST_URL=https://your-redis.upstash.io
UPSTASH_REDIS_REST_TOKEN=your-token-here
How It Works
- A non-authorized user asks the bot to perform a Salesforce write (e.g., "delete contact John Smith")
- The bot posts a message in the thread: "Approval needed — Delete Contact record
003xxx" with Approve/Deny buttons - An authorized user (whose email is in
AUTHORIZED_USER_EMAILS) clicks Approve or Deny - If approved, the operation executes and the result is posted to the thread
- If denied, the requester is notified in the thread
- Approval requests expire after 30 minutes
Notes
- If
AUTHORIZED_USER_EMAILS is empty or not set, all write operations require approval (no one can self-approve) - Authorized users' write operations execute immediately without approval
- Bulk operations have record limits: 1,500 for authorized users, 500 for non-authorized users
- Redis is required for the approval workflow — without it, write operations will return an error
Next Steps
- Once the Slack app is set up:
- Go back to the main setup guide
- Configure the AI provider (Anthropic or OpenAI)
- Deploy your app to Vercel
- Optionally set up Salesforce, Linear, or GitHub integrations