book-hotel
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesebook-hotel
预订酒店
Create a hotel reservation and pay with USDC. The payment is handled automatically via the x402 protocol — your travel API responds with HTTP 402 Payment Required, the agent's wallet pays in USDC, and the booking confirms.
This is a real on-chain financial transaction. Proceed carefully.
创建酒店预订并使用USDC支付。支付将通过x402协议自动处理——旅行API返回HTTP 402 Payment Required状态码,Agent钱包使用USDC完成支付,随后预订确认。
这是真实的链上金融交易,请谨慎操作。
When to use
使用场景
The user has chosen a specific package and explicitly asks to book it:
- "Book the Park Hyatt for me"
- "Reserve option 2"
- "Confirm and pay for this hotel"
- "Go ahead with this one"
Do NOT use this skill speculatively. Only when the user explicitly approves payment.
用户已选定具体套餐并明确要求预订:
- “帮我预订柏悦酒店”
- “预订选项2”
- “确认并支付这家酒店”
- “就选这个了”
请勿随意使用此技能,仅在用户明确批准支付时使用。
Prerequisites
前置条件
You need ALL of these before calling:
- A valid from
packageIdorsearch-hotelsearch-room - The from that same search session
sessionId - Guest details: first name, last name, email (the user must give these — never invent)
- An authenticated Coinbase wallet — if not, run the skill first (from the
authenticate-walletpackage)coinbase/agentic-wallet-skills - Sufficient USDC in the wallet — if balance is too low, run the skill first
fund - Explicit user confirmation of package, total price, and dates
If any of these are missing, ask the user or chain to the relevant skill — do not skip ahead.
调用前必须满足以下所有条件:
- 有效的:来自
packageId或search-hotel技能search-room - 对应的:来自同一搜索会话
sessionId - 客人信息:名字、姓氏、邮箱(必须由用户提供,绝不能编造)
- 已认证的Coinbase钱包:若未认证,先运行包中的
coinbase/agentic-wallet-skills技能authenticate-wallet - 钱包中有足够的USDC:若余额不足,先运行技能
fund - 用户明确确认:套餐、总价和日期均已得到用户确认
若缺少任何一项,请询问用户或调用相关技能,切勿跳过步骤。
Wallet setup check
钱包设置检查
Before booking, verify wallet status. Quick check:
bash
npx awal@latest balanceIf the user is not authenticated, this returns an auth error → trigger skill.
If USDC balance is below the booking total, trigger skill.
authenticate-walletfund预订前,请验证钱包状态。快速检查命令:
bash
npx awal@latest balance若用户未认证,将返回认证错误→触发技能。
若USDC余额低于预订总价,触发技能。
authenticate-walletfundPre-booking confirmation
预订前确认
Always summarize and confirm before paying. Example:
About to book and pay:
- Park Hyatt Tokyo, Park Deluxe King with breakfast
- May 1–5 (4 nights), 2 adults
- Total: 1,800 USDC (paid from your Coinbase wallet)
- Free cancellation until April 29
- Guest: Nguyen Van A, guest@example.com
Confirm? (yes/no)
Only run the pay command after the user says yes (or equivalent). If the user already explicitly authorized booking with all the above info in the same turn, you can proceed without re-asking.
支付前务必汇总信息并确认。示例:
即将完成预订并支付:
- 东京柏悦酒店,豪华公园大床房含早餐
- 5月1日至5日(4晚),2位成人
- 总价:1,800 USDC(从您的Coinbase钱包支付)
- 4月29日前可免费取消
- 客人:Nguyen Van A,guest@example.com
是否确认?(是/否)
仅在用户回复“是”或类似确认后再执行支付命令。若用户在同一轮对话中已明确授权包含上述所有信息的预订,则无需再次询问即可继续。
How to call
调用方式
Use to call the booking endpoint. The CLI handles 402 → sign → retry automatically.
awal x402 payThe booking endpoint splits inputs across two places:
- Query string (flag):
-q,package_id— the package the user picked and the search session it came from.session_id - Request body (flag): the
-dobject only.contact
bash
npx awal@latest x402 pay https://qpgdy2kn7v.ap-southeast-1.awsapprunner.com/m2m-payment/book \
-X POST \
-q '{"package_id":"<packageId>","session_id":"<sessionId>"}' \
-d '{
"contact": {
"given_name": "<first>",
"sur_name": "<last>",
"email": "<email>",
"phone": "<phone>"
}
}'Note the snake_case field names (, , , ) — the booking endpoint expects this exact shape. The object is required and is part of it. Do NOT put / in the body — they must be query params.
package_idsession_idgiven_namesur_namecontactphonepackage_idsession_id使用调用预订接口。CLI会自动处理402状态码→签名→重试流程。
awal x402 pay预订接口的输入分为两部分:
- 查询字符串(参数):
-q、package_id——用户选定的套餐及其所属搜索会话session_id - 请求体(参数):仅包含
-d对象contact
bash
npx awal@latest x402 pay https://qpgdy2kn7v.ap-southeast-1.awsapprunner.com/m2m-payment/book \
-X POST \
-q '{"package_id":"<packageId>","session_id":"<sessionId>"}' \
-d '{
"contact": {
"given_name": "<first>",
"sur_name": "<last>",
"email": "<email>",
"phone": "<phone>"
}
}'注意字段为蛇形命名(、、、)——预订接口要求严格遵循此格式。对象为必填项,且包含字段。请勿将/放入请求体中,它们必须作为查询参数。
package_idsession_idgiven_namesur_namecontactphonepackage_idsession_idSafety: cap maximum payment
安全设置:支付上限
To prevent unexpected overcharge (e.g. if the API returns a wrong amount), pass in micro-USDC (1 USDC = 1,000,000 micro-units):
--max-amountbash
--max-amount 1850000000 # caps payment at 1,850 USDC for an 1,800 USDC bookingAlways set to roughly the expected total + a small buffer (5%).
--max-amount为防止意外超额收费(例如API返回错误金额),请以微USDC为单位传递参数(1 USDC = 1,000,000微单位):
--max-amountbash
--max-amount 1850000000 # 针对1,800 USDC的预订,将支付上限设为1,850 USDC请始终将设置为预期总价加上少量缓冲(5%)。
--max-amountFull example
完整示例
bash
npx awal@latest x402 pay https://qpgdy2kn7v.ap-southeast-1.awsapprunner.com/m2m-payment/book \
-X POST \
-q '{"package_id":"e47otEJtYeZYblF9","session_id":"6kVmPYwZhQJewNTp"}' \
-d '{"contact":{"given_name":"Justin","sur_name":"Ta","email":"justin@travala.com","phone":"+84336657091"}}' \
--max-amount 1850000000bash
npx awal@latest x402 pay https://qpgdy2kn7v.ap-southeast-1.awsapprunner.com/m2m-payment/book \
-X POST \
-q '{"package_id":"e47otEJtYeZYblF9","session_id":"6kVmPYwZhQJewNTp"}' \
-d '{"contact":{"given_name":"Justin","sur_name":"Ta","email":"justin@travala.com","phone":"+84336657091"}}' \
--max-amount 1850000000Output
输出结果
On success, the CLI prints both the payment receipt and the booking confirmation. The booking response is in the body:
json
{
"bookingId": "BK_2026_05_001",
"status": "CONFIRMED",
"hotelName": "Park Hyatt Tokyo",
"checkIn": "2026-05-01",
"checkOut": "2026-05-05",
"totalPriceUSD": 1800,
"cancellationDeadline": "2026-04-29T23:59:00Z",
"paymentTxHash": "0xabc...",
"confirmationEmail": "guest@example.com"
}The transaction hash () appears in the header — will surface it in the output.
paymentTxHashX-PAYMENT-RESPONSEawal成功时,CLI将同时打印支付凭证和预订确认信息。预订响应位于请求体中:
json
{
"bookingId": "BK_2026_05_001",
"status": "CONFIRMED",
"hotelName": "Park Hyatt Tokyo",
"checkIn": "2026-05-01",
"checkOut": "2026-05-05",
"totalPriceUSD": 1800,
"cancellationDeadline": "2026-04-29T23:59:00Z",
"paymentTxHash": "0xabc...",
"confirmationEmail": "guest@example.com"
}交易哈希()会出现在请求头中——会在输出中展示该信息。
paymentTxHashX-PAYMENT-RESPONSEawalPresenting confirmation
确认信息展示
✅ Booked! Confirmation BK_2026_05_001. Park Hyatt Tokyo · May 1–5 · 1,800 USDC paid Tx: 0xabc...def (view on basescan) Free cancellation until April 29, 2026. Confirmation email sent to guest@example.com.Save your booking ID — you'll need it to manage or cancel.
✅ 预订成功!确认编号BK_2026_05_001。 东京柏悦酒店 · 5月1日至5日 · 已支付1,800 USDC 交易哈希:0xabc...def(可在basescan查看) 2026年4月29日前可免费取消。 确认邮件已发送至guest@example.com。请保存您的预订编号——后续管理或取消预订时需要用到。
Error handling
错误处理
- — Booking total exceeds the safety cap. Stop, tell the user the actual amount, and ask whether to proceed with a higher cap.
402 with amount > --max-amount - — Trigger the
Insufficient USDC balanceskill to top up, then retry.fund - — Trigger the
Wallet not authenticatedskill, then retry.authenticate-wallet - (after payment attempt) — Prices/availability shift between search and book. Re-run
Package no longer availableorsearch-hotel. If payment was already settled but booking failed, the API should refund automatically; tell the user and checksearch-room.awal wallet history - — Re-run search to get a new
Session expired.sessionId - Network error mid-payment — Don't retry blindly. Check to see if payment went through. If it did, contact support with the tx hash; if not, ask the user whether to retry.
awal wallet history
- ——预订总价超出安全上限。停止操作,告知用户实际金额,并询问是否同意提高上限。
402状态码且金额>--max-amount - ——触发
USDC余额不足技能充值,然后重试。fund - ——触发
钱包未认证技能,然后重试。authenticate-wallet - (支付尝试后)——搜索与预订期间价格/库存发生变动。重新运行
套餐已不可用或search-hotel技能。若支付已完成但预订失败,API应自动退款;告知用户并查看search-room。awal wallet history - ——重新运行搜索技能获取新的
会话已过期。sessionId - 支付过程中出现网络错误——请勿盲目重试。查看确认支付是否成功。若已成功,请携带交易哈希联系客服;若未成功,询问用户是否重试。
awal wallet history
Critical rules
关键规则
- Never invent guest details. If the user hasn't given them, ask.
- Never call without explicit approval in this turn or a recent turn.
awal x402 pay - Always set to prevent runaway charges.
--max-amount - If the user changes their mind ("wait, show me option 3"), do NOT pay — go back to .
search-room - Never expose private keys or wallet seed phrases. The agent only signs through ; keys stay in Coinbase's secure infrastructure.
awal
- 绝不能编造客人信息。若用户未提供,请询问。
- 切勿在未获得用户当前轮次或最近轮次明确批准的情况下调用。
awal x402 pay - 始终设置以防止超额收费。
--max-amount - 若用户改变主意(“等等,给我看看选项3”),请勿支付——返回技能。
search-room - 绝不能泄露私钥或钱包助记词。Agent仅通过进行签名;密钥将保存在Coinbase的安全基础设施中。
awal