A simple Computer Use Agent connected to Slack and powered by Browserbase.
Slack Operator is an Computer-Use Agent that can perform web-based tasks through natural language commands in Slack. Here's how the system works:
-
Browser Control: The agent uses Browserbase to control a real browser instance, allowing it to interact with websites just like a human would.
-
Integration Points:
- Slack Integration: When deployed, the bot listens for mentions in Slack channels and responds to user requests in threads
- Demo API: A simplified endpoint (
/api/demo
) for testing the functionality without Slack integration
-
Agent Loop:
- The agent receives a goal (either from Slack or the demo API)
- It analyzes the request and determines the appropriate starting point (usually a relevant website)
- Through an iterative process, it:
- Navigates websites
- Interacts with web elements
- Extracts information
- Reports progress back to the user
- When deployed to Vercel, the agent maintains state between interactions, allowing for follow-up questions and multi-step tasks
-
State Management:
- For Slack interactions, the agent maintains conversation state using Vercel's blob storage to support continuous interactions
- Each session uses a dedicated browser instance that persists throughout the task
-
Regional Optimization:
- The system automatically selects the closest browser region based on the server's timezone for optimal performance
You can test the functionality directly using the demo API endpoint without setting up Slack integration:
-
Clone this repository
-
Install dependencies:
npm install
-
Copy
.env.example
to.env.local
and add your API keys. You can get a Browserbase API key and project ID from the Browserbase Dashboard.BROWSERBASE_API_KEY=your-browserbase-api-key BROWSERBASE_PROJECT_ID=your-browserbase-project-id OPENAI_API_KEY=your-openai-api-key
-
Run the development server:
npm run dev
-
Send a POST request to
/api/demo
with your goal:curl -X POST http://localhost:3000/api/demo \ -H "Content-Type: application/json" \ -d '{"goal": "What is the weather in San Francisco?"}'
Note: The demo endpoint does not support follow up questions with the agent. The requires persistent state to be saved between steps.
- Click here to create a pre-configured Vercel project
- Once it's deployed, you'll need to enable blob storage and fluid compute to enable state persistence and long-running tasks. Make sure to update slack/route.ts
- You can test it's working by sending a POST request to
/api/demo
with your goal.curl -X POST https://YOUR_VERCEL_URL/api/demo \ -H "Content-Type: application/json" \ -d '{"goal": "What is the weather in San Francisco?"}'
- Once Slack integration is set up, you'll need to configure the environment variables in Vercel as described in the next steps.
- Go to https://api.slack.com/apps and click "Create New App"
- Choose "From an app manifest"
- Select your workspace and paste the contents of
slack-manifest.json
- Replace
https://your-vercel-deployment-url
in the manifest with your actual Vercel deployment URL - Review and create the app
- Go to "Install App" in the sidebar
- Click "Install to Workspace" and authorize the app
- Go to your Slack App's "Basic Information" page and copy the "Signing Secret"
- Go to "OAuth & Permissions" and copy the "Bot User OAuth Token"
- In your Vercel project settings, add these environment variables:
SLACK_BOT_TOKEN
: Your Bot User OAuth Token (starts with xoxb-)- Go to "OAuth & Permissions" and copy the "Bot User OAuth Token"
SLACK_SIGNING_SECRET
: Your Signing Secret- Go to your Slack App's "Basic Information" page
SLACK_BOT_USER_ID
: Your Bot User ID (starts with U)- You can get that from the Slack API. You'll need the user_id from the response
curl -X POST "https://slack.com/api/auth.test" -H "Authorization: Bearer xoxb-your-slack-bot-token"
BROWSERBASE_API_KEY
: Your Browserbase API KeyBROWSERBASE_PROJECT_ID
: Your Browserbase Project IDOPENAI_API_KEY
: Your OpenAI API Key
- Make sure to enable Fluid Compute and update the timeout in
slack/route.ts
to 800 seconds! Otherwise the agent will timeout while working. - Redeploy your Vercel project for the changes to take effect