| name | hotel-booking |
| description | Search and book hotels on Agoda using Playwright browser automation. Use when user asks to book a hotel, search for hotel rates, or find accommodation on Agoda. |
When to Use
When user asks to book a hotel, check hotel prices, or find accommodation on Agoda.
Required Info
Collect these before starting (ask user if missing):
- Hotel name ā e.g. M World Hotel, Hilton KL, etc.
- Check-in date ā e.g. "next Tuesday", "3 March 2026"
- Check-out date ā e.g. "Thursday", "5 March 2026"
- Number of adults ā default: 2
- Number of rooms ā default: 1
- Room preference (optional) ā e.g. King bed, Twin, with breakfast
Arguments
$ARGUMENTS = hotel name and date info, e.g. "M World Hotel next Tuesday to Thursday"
- Parse relative dates (next Tuesday, this Friday, etc.) against today's date
Approach: Playwright Browser Automation
Use the Playwright MCP tools to automate the Agoda search and booking flow.
Step 1: Navigate to Agoda
browser_navigate ā https://www.agoda.com
Step 2: Search for the Hotel
- Click the destination search box (combobox "Enter a destination or property")
- Type the hotel name using
browser_type
- Wait 2 seconds for autocomplete dropdown to appear
- Use
browser_evaluate to find and click the matching hotel option:
() => {
const options = document.querySelectorAll('[role="option"]');
for (const opt of options) {
if (opt.textContent.includes('HOTEL_NAME')) { opt.click(); return 'clicked'; }
}
return 'not found';
}
Step 3: Set Check-in and Check-out Dates
Use browser_evaluate to click date cells by their data-selenium-date attribute:
() => {
const el = document.querySelector('span[data-selenium-date="YYYY-MM-DD"]');
if (el) { el.click(); return 'clicked'; }
return 'not found';
}
() => {
const el = document.querySelector('span[data-selenium-date="YYYY-MM-DD"]');
if (el) { el.click(); return 'clicked'; }
return 'not found';
}
If the target month is not visible, click the next month arrow button to navigate forward.
Step 4: Click SEARCH
() => {
const btns = document.querySelectorAll('button');
for (const b of btns) {
if (b.textContent.trim() === 'SEARCH') { b.click(); return 'clicked'; }
}
return 'not found';
}
Step 5: Open Hotel Page
From search results, find and click the hotel link:
() => {
const links = document.querySelectorAll('a');
for (const a of links) {
if (a.textContent.includes('HOTEL_NAME')) { a.click(); return 'clicked'; }
}
return 'not found';
}
The hotel page often opens in a new tab ā use browser_tabs to switch to it.
Step 6: Set Dates on Hotel Page
The hotel page may show a calendar popup. If check-in/out are not set:
- Click the check-in date field to open the calendar
- Select check-in date using
data-selenium-date attribute
- Select check-out date
- Click the "Update" button to refresh room listings
Step 7: Browse Room Options
Wait for room listings to load (look for "You won't be charged yet" or room price elements).
Take a screenshot to review available rooms.
Present room options to user if they haven't specified a preference:
- Room type, size, bed configuration
- Price per night
- Key perks (breakfast included, free cancellation, etc.)
- Rating if shown
If user hasn't specified, pick the best value option ā generally:
- Prefer rooms with free cancellation over non-refundable
- Prefer rooms with breakfast included if price difference is small
- Note "Our last room!" urgency warnings
Step 8: Click Book
Click the "Book" or "Request to Book" button for the selected room option.
This navigates to the Booking Form page (new tab ā switch to it).
Step 9: Stop at Booking Form
DO NOT fill in personal details or payment info.
The booking form asks for: First name, Last name, Email, Country, Mobile number.
- Dismiss any "You're almost done!" popup by clicking "Continue booking"
- Take a screenshot of the booking form
- Capture the current page URL
Step 10: Send Link to User
Construct a clean, shareable hotel link with dates:
https://www.agoda.com/{hotel-slug}/hotel/{city}.html?checkIn=YYYY-MM-DD&checkOut=YYYY-MM-DD&adults=N&rooms=N&children=0
Send via Telegram using the send-telegram pattern:
cd ~/Agent_K_Telegram && node -e "
const { Telegraf } = require('telegraf');
require('dotenv').config();
const bot = new Telegraf(process.env.TELEGRAM_BOT_TOKEN);
const chatId = process.env.TELEGRAM_GROUP_CHAT_ID;
const message = \`HOTEL_SUMMARY_WITH_LINK\`;
bot.telegram.sendMessage(chatId, message, { parse_mode: 'HTML' })
.then(() => { console.log('Sent'); process.exit(0); })
.catch(e => { console.error(e); process.exit(1); });
"
Message format:
šØ <b>HOTEL_NAME</b> (STAR_RATING, REVIEW_SCORE)
š
Check-in: DATE ā Check-out: DATE (N nights)
š ROOM_TYPE, SIZE, BED_CONFIG
š° PRICE per night (REFUND_POLICY)
ā
PERKS (WiFi, Parking, Breakfast, etc.)
š <b>Hotel page with dates:</b>
SHAREABLE_URL
Just fill in your name, email & phone, then book!
Critical Rules
- NEVER enter personal details ā stop at the booking form. Do not fill in name, email, phone, or payment.
- NEVER complete a booking ā the user must do that themselves.
- Use browser_evaluate for Agoda interactions ā Agoda's dynamic React UI works better with direct JS evaluation than with snapshot-based clicking.
- Be patient with slow pages ā Agoda is JS-heavy. Wait 3-5 seconds after navigation and clicks. Use
browser_wait_for with time parameter.
- Use browser_snapshot sparingly on Agoda ā the snapshots are very large. Prefer
browser_evaluate to extract specific data and browser_take_screenshot to verify page state visually.
- Handle popups ā Agoda shows cookie banners, promo popups, and "almost done" urgency modals. Dismiss them.
- Calendar navigation ā if the target month isn't visible, click the forward arrow. Dates use
data-selenium-date="YYYY-MM-DD" attribute on <span> elements.
- New tabs ā Hotel pages and booking forms often open in new tabs. Always check
browser_tabs and switch as needed.
- Agoda URL redirects ā Agoda frequently redirects hotel pages to their search URL. The actual hotel content still loads ā verify with
document.title or document.querySelector('h1') via evaluate.
Troubleshooting
- Hotel not found in autocomplete: Try shorter or alternate names. Check spelling.
- Calendar month not visible: Click the next-month arrow button. Look for
button with arrow/chevron icon near the calendar header.
- Room listings not loading: Wait longer (up to 10 seconds). Try clicking the "Rooms" tab button.
- Booking form redirect: Agoda may redirect ā check
browser_tabs for the Booking Form tab.
- Page snapshot too large: Use
browser_evaluate to extract specific text instead of full snapshots.
- Date format: Always use ISO format
YYYY-MM-DD for date attributes.