Overview
The CrewAI integration enables you to create intelligent agents that can automate web interactions using natural language instructions. The StagehandTool wraps the Stagehand Python SDK to provide CrewAI agents with browser automation capabilities.The CrewAI integration uses the Stagehand Python SDK. For TypeScript/JavaScript projects, use the LangChain integration instead.
Core Capabilities
The StagehandTool provides three core primitives for browser automation:- Act: Perform actions like clicking, typing, or navigating
- Extract: Extract structured data from web pages
- Observe: Identify and analyze elements on the page
When to Use This Integration
The CrewAI integration is perfect for:- Research automation: Have agents research information across multiple websites
- Data collection: Extract structured data from e-commerce sites, job boards, or news sites
- Form automation: Automatically fill out and submit forms based on specific criteria
- Multi-step workflows: Execute complex browser workflows that require decision-making
Installation
Install the required packages:Quick Start
1. Configure Environment Variables
Set up your Browserbase and API credentials:2. Initialize Stagehand
Create a Stagehand instance:3. Create a CrewAI Agent with StagehandTool
4. Create and Execute Tasks
Example Workflows
E-commerce Price Monitoring
Job Posting Aggregation
Form Automation
Multi-Site Research
Multi-Agent Collaboration
CrewAI excels at coordinating multiple agents. Here’s an example with specialized agents:Best Practices
1. Use Clear Task Descriptions
Provide detailed, step-by-step instructions:2. Handle Errors Gracefully
3. Use Appropriate Wait Times
4. Reuse Stagehand Instances
For multiple tasks, reuse the same Stagehand instance:Configuration Options
Cleanup
Always clean up resources:Resources
CrewAI Documentation
Official CrewAI documentation
Stagehand Python SDK
Stagehand Python SDK repository
Browserbase Dashboard
Monitor your browser sessions
Agent Reference
Learn about Stagehand’s Agent API