Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Stagehand + Browserbase Templates

A comprehensive collection of ready-to-use automation templates demonstrating the power of Stagehand and Browserbase for web automation, data extraction, and AI-powered browser interactions.

## 🚀 Quick Start

1. **Choose your language**: TypeScript or Python
2. **Browse available templates** in the respective language folder
3. **Read the template's README** for detailed setup instructions and use cases
4. **Start automating!**

## 📁 Available Templates

### TypeScript Templates (`/typescript/`)
- **context** - AI-powered context switching and page analysis
- **formFilling** - Automated form submission and data entry
- **giftfinder** - AI-powered product discovery and recommendation
- **pickleball** - Court booking automation with user interaction
- **proxies** - Proxy testing and geolocation verification
- **realEstateCheck** - License verification and data extraction

### Python Templates (`/python/`)
- **context** - AI-powered context switching and page analysis
- **formFilling** - Automated form submission and data entry
- **giftfinder** - AI-powered product discovery and recommendation
- **pickleball** - Court booking automation with user interaction
- **proxies** - Proxy testing and geolocation verification
- **realEstateCheck** - License verification and data extraction

> **📖 Each template includes a comprehensive README with:**
> - Detailed setup instructions
> - Required environment variables
> - Use cases and examples
> - Troubleshooting guides
> - Dependencies and installation steps

## 🔧 Getting Started

1. **Choose a template** from the TypeScript or Python folders
2. **Read the template's README** for specific setup instructions
3. **Set up your environment** with the required API keys and dependencies
4. **Run the template** and start automating!

> **💡 Pro Tip**: Each template's README contains detailed installation steps, environment variable requirements, and troubleshooting guides specific to that template.

## 📚 Resources

### Documentation
- **Stagehand Docs**: https://docs.browserbase.com/stagehand
- **Browserbase Docs**: https://docs.browserbase.com
- **API Reference**: https://docs.browserbase.com/api

### Support
- **Community**: Join our Discord community
- **Email Support**: support@browserbase.com
- **GitHub Issues**: Report bugs and request features

### Examples & Tutorials
- **Getting Started Guide**: Learn the basics of Stagehand
- **Advanced Patterns**: Complex automation workflows
- **Best Practices**: Tips for reliable automation

## 🤝 Contributing

We welcome contributions! Here's how you can help:

1. **Report Bugs**: Use GitHub issues to report problems
2. **Suggest Features**: Propose new templates or improvements
3. **Submit Pull Requests**: Contribute code improvements
4. **Share Templates**: Create and share your own templates

### Template Guidelines
- Follow the established structure and naming conventions
- Include comprehensive README documentation
- Add proper error handling and logging
- Test templates thoroughly before submitting

## 📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

## 🙏 Acknowledgments

- **Stagehand Team**: For the amazing automation framework
- **Browserbase Team**: For reliable cloud browser infrastructure
- **Community Contributors**: For templates and improvements
- **Open Source Projects**: For the tools and libraries we build upon

---

**Ready to start automating?** Pick a template and follow its README to get started! 🚀
20 changes: 8 additions & 12 deletions python/context/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,14 @@
Docs → https://docs.stagehand.dev/basics/act

## QUICKSTART
1) Create virtual environment (optional but recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
2) Install dependencies:
pip install stagehand browserbase python-dotenv pydantic requests
3) Create .env with:
BROWSERBASE_PROJECT_ID=...
BROWSERBASE_API_KEY=...
SF_REC_PARK_EMAIL=...
SF_REC_PARK_PASSWORD=...
4) Run:
python index.py
1) cd context-template
2) python -m venv venv
3) source venv/bin/activate # On Windows: venv\Scripts\activate
4) pip install -r requirements.txt
5) pip install browserbase pydantic requests
6) cp .env.example .env
7) Add your Browserbase API key, Project ID, and SF Rec Park credentials to .env
8) python main.py

## EXPECTED OUTPUT
- Creates context, performs login, saves auth state
Expand Down
12 changes: 9 additions & 3 deletions python/context/index.py → python/context/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ async def create_session_context_id():
env="BROWSERBASE",
api_key=os.environ.get("BROWSERBASE_API_KEY"),
project_id=os.environ.get("BROWSERBASE_PROJECT_ID"),
model_name="gpt-4o",
model_name="openai/gpt-4.1",
model_api_key=os.environ.get("OPENAI_API_KEY"),
browserbase_session_id=session.id,
verbose=1 # 0 = errors only, 1 = info, 2 = debug
# (When handling sensitive data like passwords or API keys, set verbose: 0 to prevent secrets from appearing in logs.)
# https://docs.stagehand.dev/configuration/logging
)

async with Stagehand(config) as stagehand:
Expand Down Expand Up @@ -102,7 +105,7 @@ async def main():
env="BROWSERBASE",
api_key=os.environ.get("BROWSERBASE_API_KEY"),
project_id=os.environ.get("BROWSERBASE_PROJECT_ID"),
model_name="gpt-4o",
model_name="openai/gpt-4.1",
model_api_key=os.environ.get("OPENAI_API_KEY"),
browserbase_session_create_params={
"project_id": os.environ.get("BROWSERBASE_PROJECT_ID"),
Expand All @@ -112,7 +115,10 @@ async def main():
"persist": True,
}
}
}
},
verbose=1 # 0 = errors only, 1 = info, 2 = debug
# (When handling sensitive data like passwords or API keys, set verbose: 0 to prevent secrets from appearing in logs.)
# https://docs.stagehand.dev/configuration/logging
)

async with Stagehand(config) as stagehand:
Expand Down
18 changes: 7 additions & 11 deletions python/formFilling/README.md → python/form-filling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,13 @@
- variable substitution: inject dynamic values into actions using `%variable%` syntax

## QUICKSTART
1) Create virtual environment (optional but recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
2) Install dependencies:
pip install stagehand python-dotenv
3) Create .env with:
BROWSERBASE_PROJECT_ID=...
BROWSERBASE_API_KEY=...
OPENAI_API_KEY=...
4) Run:
python index.py
1) cd form-fill-template
2) python -m venv venv
3) source venv/bin/activate # On Windows: venv\Scripts\activate
4) pip install -r requirements.txt
5) cp .env.example .env
6) Add your Browserbase API key and Project ID to .env
7) python main.py

## EXPECTED OUTPUT
- Initializes Stagehand session with Browserbase
Expand Down
17 changes: 6 additions & 11 deletions python/formFilling/index.py → python/form-filling/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ async def main():
env="BROWSERBASE",
api_key=os.environ.get("BROWSERBASE_API_KEY"),
project_id=os.environ.get("BROWSERBASE_PROJECT_ID"),
model_name="gpt-4o",
model_name="openai/gpt-4.1",
model_api_key=os.environ.get("OPENAI_API_KEY"),
browserbase_session_create_params={
"project_id": os.environ.get("BROWSERBASE_PROJECT_ID"),
}
},
verbose=1 # 0 = errors only, 1 = info, 2 = debug
# (When handling sensitive data like passwords or API keys, set verbose: 0 to prevent secrets from appearing in logs.)
# https://docs.stagehand.dev/configuration/logging
)

try:
Expand All @@ -52,15 +55,7 @@ async def main():
timeout=60000 # Extended timeout for reliable page loading.
)

# Analyze form structure to identify fillable fields before attempting to fill.
print("Analyzing form fields...")
contact_page = await page.observe(
instruction="What are the fields that can be filled in?",
return_action=True # Return action objects for potential reuse with act().
)
print(f"Available form fields: {contact_page}")

# Fill form using a more reliable approach with individual field targeting.
# Fill form using individual act() calls for reliability
print("Filling in contact form...")

# Fill each field individually for better reliability
Expand Down
19 changes: 8 additions & 11 deletions python/giftfinder/README.md → python/gift-finder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@
Docs → https://docs.browserbase.com/features/proxies

## QUICKSTART
1) Create virtual environment (optional but recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
2) Install dependencies:
pip install stagehand python-dotenv InquirerPy openai pydantic
3) Create .env with:
BROWSERBASE_PROJECT_ID=...
BROWSERBASE_API_KEY=...
OPENAI_API_KEY=...
4) Run:
python index.py
1) cd gift-finder-template
2) python -m venv venv
3) source venv/bin/activate # On Windows: venv\Scripts\activate
4) pip install -r requirements.txt
5) pip install InquirerPy pydantic openai
6) cp .env.example .env
7) Add your Browserbase API key, Project ID, and OpenAI API key to .env
8) python main.py

## EXPECTED OUTPUT
- Prompts user for recipient and description
Expand Down
Loading