Building an AI Ticket Search Agent with Hyperbrowser

In this cookbook, we'll create an intelligent ticket search agent that can find concerts and events matching specific criteria. Using Hyperbrowser's Browser Use capabilities, this agent can:

  • Navigate to a ticketing websites (like Ticketmaster)
  • Filter events by date ranges, locations, and genres
  • Present curated recommendations based on user preferences
  • Maintain the browser session for further human interaction

This approach offers significant advantages over traditional web scraping or API-based solutions. The agent interacts with ticketing sites just like a human would - navigating complex search interfaces, handling dynamic content loading, and extracting relevant information from visually structured results. Plus, by keeping the browser session open, you can seamlessly take over where the AI left off to complete booking or explore additional options.

Prerequisites

Before starting, you'll need:

  1. A Hyperbrowser API key (sign up at hyperbrowser.ai if you don't have one)
  2. Python 3.9+ installed
  3. The dotenv package for loading environment variables

Store your API key in a .env file in the same directory as this notebook:

HYPERBROWSER_API_KEY=your_hyperbrowser_key_here

Step 1: Import Libraries and Set Up Environment

We start by importing the necessary packages and initializing our environment. The key components include:

  • AsyncHyperbrowser: For asynchronous communication with the Hyperbrowser API
  • StartBrowserUseTaskParams: To configure the autonomous browser interaction
  • CreateSessionParams: For setting up the browser session with specific parameters
  • ScreenConfig: To define the browser viewport size for optimal interaction

These tools together enable us to create a powerful event discovery experience that's driven by AI but maintains human-like browsing behavior.

import os
from dotenv import load_dotenv
from hyperbrowser import AsyncHyperbrowser
from hyperbrowser.models import (
StartBrowserUseTaskParams,
CreateSessionParams,
ScreenConfig,
)
from IPython.display import Markdown, display
load_dotenv()

True

Step 2: Initialize the Hyperbrowser Client

Next, we create an instance of the AsyncHyperbrowser client using our API key. This client will handle all communication with the Hyperbrowser API, allowing us to create and control browser sessions and invoke the Browser Use agent.

hb = AsyncHyperbrowser(api_key=os.getenv("HYPERBROWSER_API_KEY"))

Step 3: Define the Ticket Search Function

Now we'll create the core function that powers our ticket search agent. This function takes an existing browser session ID and instructs the browser_use agent to:

  1. Navigate to Ticketmaster's website
  2. Find concerts matching specific criteria (date range, location, and music preferences)
  3. Return a summary of the best matching events
  4. Keep the browser open after completion (using keep_browser_open=True)

The keep_browser_open parameter is particularly powerful as it allows human users to pick up where the AI agent left off. This hybrid workflow combines AI efficiency with human decision-making at the optimal point in the process.

async def find_concert_tickets(session_id: str, search_query: str):
resp = await hb.agents.browser_use.start_and_wait(
StartBrowserUseTaskParams(
task=f"""You are tasked with booking tickets for a concert event for me. To do this you will
- Go to ticketmaster
- If a location is provided
- Click on the location input box
- Fill in the name of the city
- If there is a drop down list for locations, select the option that matches the original location the best
- If there is not drop down list for locations, then simply press the 'Enter' key
- If a date is provided
- If possible at all, try to enter the dates in the text boxes, not through selecting it.
- If a single date is provided
- In the Start Date Input box, enter the Date in the format MM/DD/YYYY
- In the End Date Input box, enter the Date in the format MM/DD/YYYY
- If a date range is provided
- Find the lower date of the range and in the Start Date Input box, enter the Date in the format MM/DD/YYYY
- Find the upper date of the range and in the End Date Input box, enter the Date in the format MM/DD/YYYY
- Click on apply
- If the user has specified any event preference, such as artist, event type, genre, or anything similar
- Click on the search input box for these parameters
- The search box should be to the right of the date range input
- Type in the event preferences
- Click on the search button
- Wait for the page to load
- Scroll down to see all the listed events
- Collect the list of all events
- Collect the following info
- Event Date
- Event Name
- Event Time
- Event Location
- Event URL (if any)
{search_query}
""",
keep_browser_open=True,
session_id=session_id,
)
)
if resp.data is not None:
return resp.data.final_result
return None

Step 4: Execute the Ticket Search and Display Results

Finally, we'll run our ticket search function to find concert events matching our criteria. This process involves:

  1. Using a proxy for reliable access to the ticketing site
  2. Displaying the live URL where you can watch or take over the browser interaction
  3. Invoking our search function with the session ID
  4. Displaying the agent's findings formatted as Markdown

The agent will navigate Ticketmaster's interface, apply filters for dates (April 12-21), location (New York), and music genres (rock and pop), then return a concise summary of available events.

session = await hb.sessions.create(
CreateSessionParams(use_proxy=True, screen=ScreenConfig(width=1920, height=1080))
)
print(session.live_url)
original_search_query = (
"Find me a football event between 1st May and 31st May near New York."
)
response = await find_concert_tickets(session.id, original_search_query)
if response is not None:
display(Markdown(response))
else:
print("No response from the agent")
https://app.hyperbrowser.ai/live?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzZXNzaW9uSWQiOiJmNzIwNzcxYi02NzI4LTQ1Y2YtYmEzZS1mMWRiOWE4MjY2N2YiLCJ0ZWFtSWQiOiIzNDA4NWIxZS0wMjAxLTQ2MTAtODIxYy0xMGZhOWRhZTY2ZDQiLCJpYXQiOjE3NDIyNTE5NDgsImV4cCI6MTc0MjI5NTE0OH0.XWmP4ozpAQdla_OPd7fnpUzON7itomDuOK9k7uozc7I&keepAlive=true
I have searched for football events between 1st May and 31st May near New York. I have extracted the content from the page. Here are the events: Event Date: 5/4/25, Event Name: New York City FC vs. FC Cincinnati, Event Time: 3:00 PM, Event Location: Queens, NY Citi Field, Event URL: https://www.ticketmaster.com/new-york-city-fc-vs-fc-cincinnati-queens-ny/event/00006069D24D37E1 Event Date: 5/10/25, Event Name: New York City FC vs. CF Montréal, Event Time: 7:30 PM, Event Location: Bronx, NY NYCFC at Yankee Stadium, Event URL: https://www.ticketmaster.com/new-york-city-fc-vs-cf-montreal-bronx-ny/event/00006069D377391B Event Date: Jul 26, 2025, Event Name: 2025 Premier League Summer Series, Event Time: 4:00 PM, Event Location: East Rutherford, New Jersey MetLife Stadium, Event URL: https://www.ticketmaster.com/2025-premier-league-summer-series-east-rutherford-new-jersey/event/00006054E8B2429B

Step 5: List ticket prices for a given game

Once the user has selected their preference, you can have Browser Use extract the ticket options available.

Optionally, once the results have been acquired and if the user is interested, they can be navigated to the live session, letting the user continue their search and purchase tickets.

async def get_concert_tickets(
session_id: str,
new_search_query: str,
original_search_query: str,
search_responses: str,
):
resp = await hb.agents.browser_use.start_and_wait(
StartBrowserUseTaskParams(
task=f"""You are a ticket booking agent. You have already presented the user with a list of ticket options for their query of {original_search_query}
You produced the following options :
{search_responses}
Now, the user wants to navigate to the option: {new_search_query}.
These are the steps you should do
- Navigate to the appropriate page
- Wait for the page to load
- If there are any popups, close or accept them.
- There should be a list of tickets available for purchase to the right of the page
- The list might be long, so scroll it to make sure you get a good idea of the range of choices.
- By default, there should be a list of the tickets sorted by the lowest price
- If it isn't selected, then double click the lowest price option
- For each ticket,
- Get the Seat location
- Seat price
- Double click the best seats option (if available)
- For each ticket,
- Get the Seat location
- Seat price
Return to the user the seat locations and their prices.
""",
keep_browser_open=True,
session_id=session_id,
)
)
if resp.data is not None:
return resp.data.final_result
return None
if response is not None:
new_query = "I want the tickets for the game on the 10th."
new_response = await get_concert_tickets(session.id,new_query,original_search_query,response)
if new_response is not None:
display(Markdown(new_response))

I have extracted the seat locations and prices for the first 20 tickets listed under the "Lowest Price" tab. The first 10 tickets are: Sec 210 • Row 7 for $23.40, Sec 207 • Row 1 for $29.25, Sec 214A • Row 7 for $29.25, Sec 233B • Row 13 for $29.25, Sec 209 • Row 3 for $30.42, Sec 136 • Row 6 for $30.42, Supporters for $28.60, Supporters for $28.60, Sec 133 • Row 5 for $31.59, Sec 112 • Row 5 for $31.59. The next 10 tickets were the same.

await hb.sessions.stop(session.id)

BasicResponse(success=True)

The Power of Hybrid Human-AI Ticket Booking

This cookbook demonstrates a powerful hybrid approach to event discovery and ticket booking. The AI agent handles the tedious parts - navigating ticketing sites, applying multiple search filters, and scanning through results - while keeping the browser session active for human takeover at the critical decision point.

By using keep_browser_open=True, we create a seamless handoff experience where:

  1. The AI handles initial discovery and filtering
  2. The human reviews the AI's selections via the live URL
  3. The human can then continue from exactly where the AI left off to:
  • Refine search criteria if needed
  • Select specific seats
  • Complete the purchase process

This approach combines the efficiency of AI automation with the judgment and authentication capabilities of human users - perfect for complex transactions like ticket booking that involve both search/discovery and secure purchasing steps.

Conclusion

We've built a powerful ticket search agent that combines AI automation with human decision-making in a seamless workflow. By leveraging Hyperbrowser's browser_use capabilities, we've created an agent that can navigate complex ticketing websites, apply specific search criteria, and present curated options while maintaining the browser session for human takeover.

This hybrid approach addresses a critical challenge in automated booking systems - balancing the efficiency of AI with the judgment and authentication requirements of human users. The result is a ticket discovery experience that saves significant time while preserving the human's role in making final selections and completing purchases.

All this said, Hyperbrowser encourages responsible automation that respects websites' Terms of Service and rate limits.