What You'll Build
A production-ready browser automation system that can handle failures gracefully using Temporal’s workflow orchestration and Browserbase’s cloud browsers.
Before you start
Ensure you have these requirements ready:Node.js 18+
Required runtime environment
Temporal CLI
Install:
brew install temporalAPI Access
Browserbase API key
Step 1: Project setup
Clone and install
What gets installed?
What gets installed?
Core Temporal packages:
@temporalio/worker- Workflow execution engine@temporalio/workflow- Workflow definitions@temporalio/activity- Activity implementations
@browserbasehq/stagehand- AI-powered browser controlplaywright- Browser automation engine
@anthropic-ai/sdk- Claude API clientzod- Schema validation
Step 2: Configuration
Environment variables
Create your.env file with the required API keys:
Step 3: Start Temporal Server
Launch development server
Keep this terminal open - The Temporal server must run continuously during development.
Step 4: Run your first workflow
Start the worker process
In a new terminal (keep Temporal server running):Execute a search workflow
In a third terminal, run the demo:- Creates a new workflow execution
- Provides monitoring URL for real-time tracking
- Executes browser automation with automatic retries
- Returns structured search results
Monitoring and debugging
Using Temporal web UI
Testing resilience
The integration includes built-in failure simulation for testing:Troubleshooting guide
Temporal server connection failed
Temporal server connection failed
Error:
Error: 14 UNAVAILABLE: failed to connect to all addressesRoot Cause: Temporal server not running or port conflictsSolutions:- Start Temporal server:
temporal server start-dev - Check port 7233 is available:
lsof -i :7233 - Kill conflicting processes if needed
- Restart the server completely
Worker failed to start
Worker failed to start
Error:
Worker failed to start or connection timeoutsRoot Cause: Worker cannot connect to Temporal serverSolutions:- Ensure Temporal server started successfully first
- Verify task queue name:
browser-automation - Check network connectivity to localhost:7233
- Restart worker after server is stable
Browser session creation failed
Browser session creation failed
Error:
Failed to initialize browser or Browserbase errorsRoot Cause: Invalid API credentials or quota limitsSolutions:- Verify your API key in
.env - Check Browserbase account credits/quota
- Test API credentials with
curlrequest - Try a different Browserbase project
AI extraction returns null
AI extraction returns null
Error:
Extraction returned null values or validation failuresRoot Cause: AI API issues or rate limitingSolutions:- Verify Anthropic API key validity
- Check API rate limits and credits
- Simplify extraction instructions
- Consider switching to OpenAI as fallback
Workflow appears stuck
Workflow appears stuck
Error: Workflows hang or don’t progressRoot Cause: Worker issues or activity timeoutsSolutions:
- Check worker is processing tasks (
npm run worker) - Inspect workflow state in Web UI
- Look for timeout errors in activity logs
- Increase timeout values if needed
- Restart worker if necessary
What’s next?
Now that you have a working Temporal + Browserbase integration:Build custom workflows
Create your own workflows for specific automation tasks
Production deployment
Deploy to Temporal Cloud for production workloads
Advanced patterns
Explore child workflows, signals, and queries
Monitoring & alerting
Set up production monitoring and alerting
Need help? Join the Temporal Community and Stagehand Slack for support and discussions.