Skip to content

Commit 2c15b4c

Browse files
authored
Merge pull request #2 from browserbase/fixes
Improvements
2 parents 9095a39 + 05a66e9 commit 2c15b4c

File tree

25 files changed

+398
-228
lines changed

25 files changed

+398
-228
lines changed

README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Stagehand + Browserbase Templates
2+
3+
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.
4+
5+
## 🚀 Quick Start
6+
7+
1. **Choose your language**: TypeScript or Python
8+
2. **Browse available templates** in the respective language folder
9+
3. **Read the template's README** for detailed setup instructions and use cases
10+
4. **Start automating!**
11+
12+
## 📁 Available Templates
13+
14+
### TypeScript Templates (`/typescript/`)
15+
- **context** - AI-powered context switching and page analysis
16+
- **formFilling** - Automated form submission and data entry
17+
- **giftfinder** - AI-powered product discovery and recommendation
18+
- **pickleball** - Court booking automation with user interaction
19+
- **proxies** - Proxy testing and geolocation verification
20+
- **realEstateCheck** - License verification and data extraction
21+
22+
### Python Templates (`/python/`)
23+
- **context** - AI-powered context switching and page analysis
24+
- **formFilling** - Automated form submission and data entry
25+
- **giftfinder** - AI-powered product discovery and recommendation
26+
- **pickleball** - Court booking automation with user interaction
27+
- **proxies** - Proxy testing and geolocation verification
28+
- **realEstateCheck** - License verification and data extraction
29+
30+
> **📖 Each template includes a comprehensive README with:**
31+
> - Detailed setup instructions
32+
> - Required environment variables
33+
> - Use cases and examples
34+
> - Troubleshooting guides
35+
> - Dependencies and installation steps
36+
37+
## 🔧 Getting Started
38+
39+
1. **Choose a template** from the TypeScript or Python folders
40+
2. **Read the template's README** for specific setup instructions
41+
3. **Set up your environment** with the required API keys and dependencies
42+
4. **Run the template** and start automating!
43+
44+
> **💡 Pro Tip**: Each template's README contains detailed installation steps, environment variable requirements, and troubleshooting guides specific to that template.
45+
46+
## 📚 Resources
47+
48+
### Documentation
49+
- **Stagehand Docs**: https://docs.browserbase.com/stagehand
50+
- **Browserbase Docs**: https://docs.browserbase.com
51+
- **API Reference**: https://docs.browserbase.com/api
52+
53+
### Support
54+
- **Community**: Join our Discord community
55+
- **Email Support**: support@browserbase.com
56+
- **GitHub Issues**: Report bugs and request features
57+
58+
### Examples & Tutorials
59+
- **Getting Started Guide**: Learn the basics of Stagehand
60+
- **Advanced Patterns**: Complex automation workflows
61+
- **Best Practices**: Tips for reliable automation
62+
63+
## 🤝 Contributing
64+
65+
We welcome contributions! Here's how you can help:
66+
67+
1. **Report Bugs**: Use GitHub issues to report problems
68+
2. **Suggest Features**: Propose new templates or improvements
69+
3. **Submit Pull Requests**: Contribute code improvements
70+
4. **Share Templates**: Create and share your own templates
71+
72+
### Template Guidelines
73+
- Follow the established structure and naming conventions
74+
- Include comprehensive README documentation
75+
- Add proper error handling and logging
76+
- Test templates thoroughly before submitting
77+
78+
## 📄 License
79+
80+
This project is licensed under the MIT License - see the LICENSE file for details.
81+
82+
## 🙏 Acknowledgments
83+
84+
- **Stagehand Team**: For the amazing automation framework
85+
- **Browserbase Team**: For reliable cloud browser infrastructure
86+
- **Community Contributors**: For templates and improvements
87+
- **Open Source Projects**: For the tools and libraries we build upon
88+
89+
---
90+
91+
**Ready to start automating?** Pick a template and follow its README to get started! 🚀

python/context/README.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,14 @@
1414
Docs → https://docs.stagehand.dev/basics/act
1515

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

3026
## EXPECTED OUTPUT
3127
- Creates context, performs login, saves auth state

python/context/index.py renamed to python/context/main.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@ async def create_session_context_id():
4141
env="BROWSERBASE",
4242
api_key=os.environ.get("BROWSERBASE_API_KEY"),
4343
project_id=os.environ.get("BROWSERBASE_PROJECT_ID"),
44-
model_name="gpt-4o",
44+
model_name="openai/gpt-4.1",
4545
model_api_key=os.environ.get("OPENAI_API_KEY"),
4646
browserbase_session_id=session.id,
47+
verbose=1 # 0 = errors only, 1 = info, 2 = debug
48+
# (When handling sensitive data like passwords or API keys, set verbose: 0 to prevent secrets from appearing in logs.)
49+
# https://docs.stagehand.dev/configuration/logging
4750
)
4851

4952
async with Stagehand(config) as stagehand:
@@ -102,7 +105,7 @@ async def main():
102105
env="BROWSERBASE",
103106
api_key=os.environ.get("BROWSERBASE_API_KEY"),
104107
project_id=os.environ.get("BROWSERBASE_PROJECT_ID"),
105-
model_name="gpt-4o",
108+
model_name="openai/gpt-4.1",
106109
model_api_key=os.environ.get("OPENAI_API_KEY"),
107110
browserbase_session_create_params={
108111
"project_id": os.environ.get("BROWSERBASE_PROJECT_ID"),
@@ -112,7 +115,10 @@ async def main():
112115
"persist": True,
113116
}
114117
}
115-
}
118+
},
119+
verbose=1 # 0 = errors only, 1 = info, 2 = debug
120+
# (When handling sensitive data like passwords or API keys, set verbose: 0 to prevent secrets from appearing in logs.)
121+
# https://docs.stagehand.dev/configuration/logging
116122
)
117123

118124
async with Stagehand(config) as stagehand:

python/formFilling/README.md renamed to python/form-filling/README.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,13 @@
1515
- variable substitution: inject dynamic values into actions using `%variable%` syntax
1616

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

3026
## EXPECTED OUTPUT
3127
- Initializes Stagehand session with Browserbase

python/formFilling/index.py renamed to python/form-filling/main.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ async def main():
2626
env="BROWSERBASE",
2727
api_key=os.environ.get("BROWSERBASE_API_KEY"),
2828
project_id=os.environ.get("BROWSERBASE_PROJECT_ID"),
29-
model_name="gpt-4o",
29+
model_name="openai/gpt-4.1",
3030
model_api_key=os.environ.get("OPENAI_API_KEY"),
3131
browserbase_session_create_params={
3232
"project_id": os.environ.get("BROWSERBASE_PROJECT_ID"),
33-
}
33+
},
34+
verbose=1 # 0 = errors only, 1 = info, 2 = debug
35+
# (When handling sensitive data like passwords or API keys, set verbose: 0 to prevent secrets from appearing in logs.)
36+
# https://docs.stagehand.dev/configuration/logging
3437
)
3538

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

55-
# Analyze form structure to identify fillable fields before attempting to fill.
56-
print("Analyzing form fields...")
57-
contact_page = await page.observe(
58-
instruction="What are the fields that can be filled in?",
59-
return_action=True # Return action objects for potential reuse with act().
60-
)
61-
print(f"Available form fields: {contact_page}")
62-
63-
# Fill form using a more reliable approach with individual field targeting.
58+
# Fill form using individual act() calls for reliability
6459
print("Filling in contact form...")
6560

6661
# Fill each field individually for better reliability

python/giftfinder/README.md renamed to python/gift-finder/README.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,14 @@
1717
Docs → https://docs.browserbase.com/features/proxies
1818

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

3229
## EXPECTED OUTPUT
3330
- Prompts user for recipient and description

0 commit comments

Comments
 (0)