
Enhancing AI Agent Capabilities with Browser Use and Amazon Bedrock
Learn how to build AI agents with Browser Use and Amazon Bedrock to automate web interactions using GenAI, Playwright, and Claude for seamless automation.
- Find particular Sports events like Volleyball in San Francisco.
- Type: Boot Camp, Workshop or Tryout trainings.
- Suitable for age group 11 to 15.
- Event location within 15 miles radius.
- Structured Output - List of sports events, formatted in a table with details like name, date, time, location, contact details, age group and cost.
- Amazon Bedrock provides powerful generative AI models to interpret the user’s intent, extract key details, and structure the query for a browser-based agent.
- Browser Use allows us to automate web interactions, extract flight details from Google Flights, and return results in the desired format.
1
2
3
4
from langchain_aws import ChatBedrock
llm = ChatBedrock(
model_id="us.anthropic.claude-3-5-sonnet-20241022-v2:0",
)
1
2
from browser_use import Agent
import asyncio
browser_use
and asyncio
to handle asynchronous operations, and create agent.1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
agent = Agent(
task="""
1. Find all volleyball events in San Francisco.
2. Events may be of the following types:
- Boot camp
- Workshop
- Tryout trainings
3. Find events suitable for age group 11 to 15.
4. All event should be in 15 miles radius.
5. Provide me the list of events with details like event name, date, time, location, contact details and age group.
6. Format result in a table.
""",
browser=Browser(config=BrowserConfig(headless=True)),
llm=llm,
)
- It provides structured instructions for the sports event search.
- Ensures the agent looks for Volleyball event in San Francisco within 11 to 15 age group and 15 miles radius.
- Requests results in a structured table format.
uv run event.py
1
2
3
4
5
6
7
8
9
10
11
12
agent = Agent(
task="""
1. Find me low price flight from San Francisco to Chennai with shortest duration for my vacation.
2. I want to travel in last week of May and return in June 3rd week, any day is fine.
3. Economy or Economy plus is fine.
4. Use google.com/flights to find the flight.
5. Provide me the top 3 flights with the details like price, duration, and departure time.
6. Format result in a table with columns: Flight, Price, Duration, Departure Time, Return date.
7. Provide me the source link to book the flight.
""",
llm=llm,
)
uv run main.py
- Launches Chromium using Playwright.
- Navigates to Google Flights (https://www.google.com/flights).
- Inputs flight details based on the user’s prompt:
- Departure: San Francisco (SFO)
- Arrival: Chennai (MAA)
- Departure Window: Last week of May
- Return Window: Third week of June
- Cabin Class: Economy / Economy Plus
- Sorts by lowest price and shortest duration.
- Extracts the top 3 flight details and formats them into a structured Markdown table.
- Provides direct booking link for the selected flights.
Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.