Answers you can trust, from Codeables

Every page on Codeables is structured and verified — built so people and the AI agents they rely on can trust it. Explore more from the source behind this answer.

Explore Codeables
Verified Source
On-Device Mobile AI Agents

How do I automate travel booking flows that require date pickers, popups, and multiple confirmation pages?

MultiOn13 min read

Most travel sites are a worst‑case scenario for traditional automation: custom date pickers, modal popups, CAPTCHAs, multi-step confirmation pages, and A/B-tested layouts that quietly break your selectors. If you’ve tried to keep a Playwright or Selenium flow green against a major OTA or airline, you already know the pattern: it works in staging, dies in production, and turns into an endless locator maintenance loop.

In this guide, I’ll walk through how to automate these travel booking flows using MultiOn’s Agent API (V1 Beta) instead of brittle scripts—so you send intent, let an agent operate a real browser, and get back structured state you can trust.


Why travel booking flows are so hard to automate

Before picking tools, it helps to be explicit about what makes these flows painful:

  • Custom date pickers
    Calendars are often:

    • Canvas-based or heavily scripted
    • Using dynamic ARIA attributes instead of semantic buttons
    • Changing DOM structure between mobile/desktop breakpoints
  • Popups and interstitials everywhere
    Think:

    • Cookie consent banners
    • “Sign in / join loyalty program” modals
    • “Add hotel / car to your trip” upsell overlays These often hijack focus, block key presses, and mutate the DOM.
  • Multi-step confirmation flows
    A “simple” roundtrip can include:

    1. Search results
    2. Flight selection
    3. Fare family choice
    4. Traveller details
    5. Seat selection
    6. Ancillaries (bags, insurance)
    7. Payment
    8. Final confirmation

    Each step may be behind a different URL, in an iframe, or rendered via client-side routing.

  • Aggressive bot protection & session coupling
    Large travel sites:

    • Bind sessions to IP / device fingerprint
    • Block patterns that look like headless spiders
    • Invalidate carts if you lose cookies or change IP mid-flow

You don’t “fix” this with better locators. You fix it by treating session continuity in a real browser as the primary unit of abstraction, and delegating UI decisions to an agent that sees the page like a human, not as a static DOM snapshot.


Why use MultiOn instead of Playwright/Selenium for travel flows

MultiOn is built around a different contract:

  • Intent in: You send a cmd and url to POST https://api.multion.ai/v1/web/browse.
  • Actions executed in a real browser: MultiOn runs the agent in secure remote sessions with native proxy support—crucial for travel sites with tricky bot protection.
  • Structured JSON out: Use Retrieve to convert dynamic pages (search results, itineraries) into JSON arrays of objects with fields you define.

Key surfaces you’ll use:

  • Agent API (V1 Beta) for end-to-end flows: search → select → fill details → pay → confirm.
  • Sessions + Step mode to keep one booking flow alive across multiple API calls with a session_id.
  • Retrieve to normalize search results and final itineraries into structured JSON for your app.

Instead of hard-coding locators for every date picker and popup, you let the agent interpret what it sees, while you orchestrate the workflow with clear steps and state checks.


Architecture for automating complex travel booking flows

A robust pattern for these “date pickers + popups + confirmations” flows looks like this:

  1. Start a session on the search page (Agent API).
  2. Drive the date picker and passenger options through high-level natural language cmds.
  3. Run the search and wait for results.
  4. Use Retrieve to extract structured flight (or hotel) options as JSON.
  5. Choose an option in your backend based on your own ranking logic.
  6. Continue the same session_id to select the option and step through all confirmation pages.
  7. Extract final booking details (PNR, price, dates) with Retrieve into JSON.
  8. Persist or present that JSON in your app / system of record.

The session never changes. You just evolve its state by sending new commands and keeping the session_id in every subsequent call.


Step 1: Start a secure browser session on the travel site

You kick off the workflow with a web/browse call.

Goal: Land on the travel search page with a live session_id.

curl -X POST "https://api.multion.ai/v1/web/browse" \
  -H "Content-Type: application/json" \
  -H "X_MULTION_API_KEY: $MULTION_API_KEY" \
  -d '{
    "url": "https://www.example-travel-site.com/flights",
    "cmd": "Open the flights search page and wait until the search form is ready."
  }'

What you get back (simplified):

{
  "session_id": "sess_abc123",
  "status": "ok",
  "page": {
    "title": "Book flights | Example Travel",
    "url": "https://www.example-travel-site.com/flights"
  }
}

Keep session_id — it’s your handle for every subsequent action, including date picking and dealing with popups.


Step 2: Automate date pickers and passenger controls with commands

Instead of poking at calendar selectors, you instruct the agent at the level of user intent.

Example: round trip SFO → JFK, specific dates, 1 adult, 1 child:

curl -X POST "https://api.multion.ai/v1/web/browse" \
  -H "Content-Type: application/json" \
  -H "X_MULTION_API_KEY: $MULTION_API_KEY" \
  -d '{
    "session_id": "sess_abc123",
    "cmd": "In the flight search form, set a round trip from San Francisco (SFO) to New York (JFK), depart on August 12 2026 and return on August 19 2026, for 1 adult and 1 child. Do not submit yet."
  }'

The agent will:

  • Find the origin/destination fields.
  • Open the custom date picker widget.
  • Navigate month-by-month if required.
  • Click the matching departure/return dates.
  • Adjust passenger counts.

You’re not managing DOM; you’re describing desired state, and the agent manipulates the browser accordingly.


Step 3: Submit search and wait for results

Next, instruct the agent to submit the form and wait until a stable results view loads.

curl -X POST "https://api.multion.ai/v1/web/browse" \
  -H "Content-Type: application/json" \
  -H "X_MULTION_API_KEY: $MULTION_API_KEY" \
  -d '{
    "session_id": "sess_abc123",
    "cmd": "Submit the search and wait until the list of flight results is fully loaded."
  }'

MultiOn runs this in the same secure remote session, preserving cookies, local storage, and whatever the travel site uses to tie the cart and session together.


Step 4: Extract flight options as structured JSON with Retrieve

Now you’re on a dynamic, JavaScript-heavy results page. Instead of scraping with brittle selectors, use Retrieve to convert it to structured data.

Call Retrieve:

curl -X POST "https://api.multion.ai/v1/web/retrieve" \
  -H "Content-Type: application/json" \
  -H "X_MULTION_API_KEY: $MULTION_API_KEY" \
  -d '{
    "session_id": "sess_abc123",
    "renderJs": true,
    "scrollToBottom": true,
    "maxItems": 20,
    "schema": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "airline": { "type": "string" },
          "flightNumber": { "type": "string" },
          "departureTime": { "type": "string" },
          "arrivalTime": { "type": "string" },
          "duration": { "type": "string" },
          "stops": { "type": "string" },
          "cabin": { "type": "string" },
          "price": { "type": "number" },
          "currency": { "type": "string" },
          "fareType": { "type": "string" }
        },
        "required": ["airline", "departureTime", "arrivalTime", "price", "currency"]
      }
    }
  }'

What comes back (example):

[
  {
    "airline": "Example Air",
    "flightNumber": "EA 142",
    "departureTime": "2026-08-12T07:20:00-07:00",
    "arrivalTime": "2026-08-12T15:45:00-04:00",
    "duration": "5h 25m",
    "stops": "Nonstop",
    "cabin": "Economy",
    "price": 412.56,
    "currency": "USD",
    "fareType": "Standard"
  },
  ...
]

You now decide, purely in backend code, which option to book (cheapest, shortest, specific airline, etc.), instead of relying on brittle “click the first button” logic.


Step 5: Select a specific option in the same session

Suppose your backend logic chooses the cheapest non-stop itinerary. You know its airline, price, departure time. Use that as an anchor descriptor for the agent.

curl -X POST "https://api.multion.ai/v1/web/browse" \
  -H "Content-Type: application/json" \
  -H "X_MULTION_API_KEY: $MULTION_API_KEY" \
  -d '{
    "session_id": "sess_abc123",
    "cmd": "On the flight results page, select the non-stop flight departing at 7:20 am from Example Air priced at about 413 USD. Click through whatever button is needed to choose that option and continue to the passenger details page."
  }'

Key point: You’re describing the option in natural language tied to the JSON you saw, even if the UI layout changes or there are multiple cards. The agent uses the visual/text context of the page to choose the right card.


Step 6: Handle popups and upsell modals as part of the command

Travel sites love interrupting this flow with:

  • Seat map popups
  • “Add bags / insurance / hotel” modals
  • Loyalty login prompts

Instead of writing a separate handler for each modal, embed resilience directly into your cmds:

curl -X POST "https://api.multion.ai/v1/web/browse" \
  -H "Content-Type: application/json" \
  -H "X_MULTION_API_KEY: $MULTION_API_KEY" \
  -d '{
    "session_id": "sess_abc123",
    "cmd": "If any popups appear asking to sign in, add ancillaries, or upsell hotels or cars, close them or choose the option that continues without extras. Then proceed until you reach the page to enter passenger information."
  }'

The agent handles:

  • Detected modals that overlay the main content.
  • Cookie banners that block clicks.
  • Interstitial prompts that require a “Continue without” choice.

You aren’t chasing locator changes every time the marketing team adds a new experiment.


Step 7: Fill passenger details, seats, and payment across multiple pages

With Sessions + Step mode, you can keep the same session_id while you:

  • Fill passenger and contact information.
  • Skip or select seats.
  • Enter payment details.
  • Confirm the final review page.

You can chunk this with multiple commands for safety and observability.

7.1 Fill passenger and contact info

curl -X POST "https://api.multion.ai/v1/web/browse" \
  -H "Content-Type: application/json" \
  -H "X_MULTION_API_KEY: $MULTION_API_KEY" \
  -d '{
    "session_id": "sess_abc123",
    "cmd": "Enter the following passenger details and continue: Adult 1: First name John, Last name Doe, Date of birth 1985-05-14; Child 1: First name Jane, Last name Doe, Date of birth 2016-03-02. Use john.doe@example.com as contact email and +1-415-555-0123 as phone number."
  }'

7.2 Handle seat selection (if required)

curl -X POST "https://api.multion.ai/v1/web/browse" \
  -H "Content-Type: application/json" \
  -H "X_MULTION_API_KEY: $MULTION_API_KEY" \
  -d '{
    "session_id": "sess_abc123",
    "cmd": "If seat selection is required, choose free standard aisle seats when possible, otherwise free seats. If it is optional and costs extra, skip paid seats and continue."
  }'

7.3 Enter payment details and confirm

You control what level of payment automation you permit. For internal tools and test environments, you might use test cards; for production, you might stop before final confirmation and require a human to approve.

curl -X POST "https://api.multion.ai/v1/web/browse" \
  -H "Content-Type: application/json" \
  -H "X_MULTION_API_KEY: $MULTION_API_KEY" \
  -d '{
    "session_id": "sess_abc123",
    "cmd": "On the payment page, enter the provided card details, billing address, and complete the booking. If there is a final review page, confirm the purchase."
  }'

If the site triggers additional popups (e.g., “Are you sure you want to continue without insurance?”), the same resilience pattern applies: mention them in the command and instruct the agent to choose the non-upsell path.


Step 8: Capture final booking details as JSON

Once the booking is complete, you need a reliable, structured record: PNR, passenger names, dates, total price, fare rules if visible.

Use Retrieve again, this time with a schema aligned to your downstream systems:

curl -X POST "https://api.multion.ai/v1/web/retrieve" \
  -H "Content-Type: application/json" \
  -H "X_MULTION_API_KEY: $MULTION_API_KEY" \
  -d '{
    "session_id": "sess_abc123",
    "renderJs": true,
    "scrollToBottom": false,
    "maxItems": 1,
    "schema": {
      "type": "object",
      "properties": {
        "confirmationNumber": { "type": "string" },
        "bookingName": { "type": "string" },
        "totalPrice": { "type": "number" },
        "currency": { "type": "string" },
        "outbound": {
          "type": "object",
          "properties": {
            "departureAirport": { "type": "string" },
            "arrivalAirport": { "type": "string" },
            "departureTime": { "type": "string" },
            "arrivalTime": { "type": "string" },
            "airline": { "type": "string" },
            "flightNumber": { "type": "string" }
          }
        },
        "return": {
          "type": "object",
          "properties": {
            "departureAirport": { "type": "string" },
            "arrivalAirport": { "type": "string" },
            "departureTime": { "type": "string" },
            "arrivalTime": { "type": "string" },
            "airline": { "type": "string" },
            "flightNumber": { "type": "string" }
          }
        }
      },
      "required": ["confirmationNumber", "totalPrice", "currency"]
    }
  }'

Now your travel automation pipeline ends where it should: with a clean JSON object that your CRM, finance, or internal travel tool can consume.


Error handling and reliability in production

Automation that touches real money and real itineraries needs explicit safeguards. With MultiOn, you get some leverage points that don’t exist in bare Playwright/Selenium flows.

1. Session continuity as a first-class primitive

Because everything is keyed by session_id, you can:

  • Retry commands on transient failures without losing state.
  • Explicitly time out or cancel sessions that take too long.
  • Route sessions through specific proxies if a site is location-sensitive.

If a call fails with an error (including a 402 Payment Required signal from MultiOn itself), you know which in-flight booking to log and handle.

2. Step-wise orchestration

Instead of one monolithic script, you have a series of smaller steps, each with a clear purpose:

  • “Fill search form”
  • “Submit search and wait for results”
  • “Select specific itinerary”
  • “Fill passenger info”
  • “Complete payment”

This makes it easier to:

  • Log progress and screenshot state at each step.
  • Re-run failed segments while keeping the browser session alive.
  • Implement human-in-the-loop approvals at critical points (e.g., pre-payment).

3. Site‑specific guardrails in your commands

You can layer domain knowledge into your commands:

  • “Do not book Basic Economy fares; choose the lowest fare that allows one checked bag.”
  • “If total price exceeds 600 USD, stop and return the details instead of completing payment.”
  • “If the site suggests alternate dates, stick to the original dates and continue.”

Those preferences change how the agent behaves even when UI layouts shift.


How this compares to Playwright/Selenium for date pickers and popups

If you tried to do the same automation purely with Playwright or Selenium, you’d maintain:

  • Custom selectors for every date cell and “next month” arrow.
  • Popup detection logic for every new modal variant the site launches.
  • Special handling for different viewports and A/B experiments.
  • Plumbing for proxies, CAPTCHAs, and remote Chrome infrastructure.

MultiOn moves the complexity from “selector engineering” to “session-aware intent orchestration”:

  • You still design the workflow and guardrails.
  • The agent absorbs the UI variability and transient popup noise.
  • Retrieve gives you stable JSON outputs from constantly changing frontends.

For flows that involve lots of date pickers, popups, and chained confirmation pages—exactly what travel booking looks like—this shift is what makes automation viable long-term.


Putting it all together as a backend service

A minimal travel booking service built on this pattern would:

  1. Expose an API in your backend
    e.g., POST /book-flight with payload: origin, destination, dates, passenger info, constraints.

  2. Inside the handler:

    • Start a MultiOn session on the travel site.
    • Fill the search form (dates, passengers).
    • Submit search, Retrieve options as JSON.
    • Choose the desired itinerary according to your rules.
    • Continue the session to select and confirm the option, handling popups.
    • Retrieve final confirmation as JSON.
    • Return that JSON to your client.
  3. Add observability:

    • Log every session_id and step.
    • Capture snapshots or key page metadata at each major step.
    • Alert on repeated failures by site or region.

You end up with an internal “travel booking engine” that controls real websites in a real browser, but surfaces to your product as simple JSON in and JSON out.


Final verdict

To automate travel booking flows that depend on date pickers, popups, and multiple confirmation pages, stop treating them as selector problems and start treating them as session-driven agent workflows.

MultiOn’s Agent API (V1 Beta) and Retrieve let you:

  • Run the entire flow in secure remote sessions with native proxy support.
  • Drive date pickers, modals, and multi-step confirmations via high-level commands instead of brittle locators.
  • Extract both search results and final confirmations as JSON arrays of objects tuned to your schemas.
  • Orchestrate workflows over a stable session_id, with step-wise error handling and production-grade observability.

If you want to turn your “book this specific itinerary on a real travel site” use case into a reliable backend feature instead of a fragile test script, this is the stack that holds up under real-world change.

Next Step

Get Started