← 返回
未分类 Key

Flight Price Advisor with Trend Chart for developer

Embed interactive flight price trend charts into AI responses. Requires SerpAPI key for real-time data. Use when users want to visualize 60-day price history...
将交互式航班价格趋势图表嵌入AI响应。需要SerpAPI密钥获取实时数据,用于可视化60天价格历史。
keyikoi
未分类 clawhub v1.0.0 1 版本 100000 Key: 需要
★ 0
Stars
📥 474
下载
💾 0
安装
1
版本
#latest

概述

Flight Price Chart

Embed an interactive flight price trend visualization component when AI responses contain flight recommendations with confirmed OD (Origin-Destination) pairs.

⚠️ 使用前必需配置

本 skill 需要 SerpAPI Key 才能获取实时航班价格数据。

如果用户尚未配置 SerpAPI Key,请先引导用户完成以下步骤:

  1. 注册 SerpAPI 账号:访问 https://serpapi.com/users/sign_up 免费注册
  2. 获取 API Key:登录后在 Dashboard 中复制你的 API Key
  3. 配置项目
    • 复制 price/config.example.jsonprice/config.json
    • 将 API Key 填入 config.json 中的 serpapi.apiKey 字段
    • 重启服务器使配置生效

> 💡 SerpAPI 提供免费额度,足够个人使用。配置完成后即可获取真实的航班价格趋势数据。

Quick Start

  1. Detect flight recommendations: When AI output contains flight search results with specific origin and destination
  2. Fetch price data: Call the price trend API with the OD pair
  3. Render component: Embed the PriceChart component at the end of the response

Component API

PriceChart Component

<PriceChart
  data={priceHistory}           // Array of {date, price}
  currentPrice={currentPrice}   // Current flight price
  analysis={analysis}           // Price analysis object
  destination={destination}     // Destination info
/>

Data Structure

priceHistory - 60-day price history:

[
  { date: "2026-03-01", price: 1299 },
  { date: "2026-03-02", price: 1350 },
  // ... up to 60 days
]

analysis - Price analysis object:

{
  min: 1199,           // Lowest price in period
  max: 1899,           // Highest price in period
  average: 1450,       // Average price
  pctDiff: -12,        // Percentage vs average
  level: "low",        // "low" | "mid" | "high"
  trend: "falling"     // "falling" | "rising" | "stable"
}

destination - Destination info:

{
  code: "TYO",         // Airport/city code
  name: "Tokyo"        // City name
}

Usage Scenarios

1. After Flight Search Results

When AI returns flight recommendations:

[Flight cards showing 3-5 options]
[Price trend chart showing 60-day history]
[Buy/wait recommendation]

2. Price Inquiry Responses

When user asks about price trends:

"Here's the price trend for Tokyo flights over the past 60 days..."
[Price trend chart]
"Current prices are 12% below average, making it a good time to buy."

3. Buy/Wait Recommendations

When providing purchase timing advice:

[Price analysis summary]
[Recommendation card: "Buy Now" or "Wait"]
[Price trend chart for context]

Integration with flyai

When using flyai for flight searches:

  1. Call flyai search-flight to get flight results
  2. Extract OD pair from search parameters
  3. Call price trend API with OD pair
  4. Append PriceChart component after flight cards

Visual Design

Color Coding

  • Low price: Green (#16A571) - Below average
  • Mid price: Gray (#666666) - Near average
  • High price: Red (#E54D4D) - Above average
  • Brand: Purple (#6666FF) - Chart line

Chart Features

  • Interactive hover/touch to see daily prices
  • Dashed line showing average price
  • Current price highlighted
  • Min/max/avg stats at bottom
  • 60-day date range

Data Source Notice

Quick Setup for Real Data

By default, the price trend uses simulated data (for demo/development only).

To enable real price data, configure your SerpAPI Key:

  1. Get API Key at https://serpapi.com/users/sign_up
  2. Add to price/config.json:

```json

{ "serpapi": { "apiKey": "your-key-here" } }

```

  1. Restart the server

See references/configure-serpapi.md for detailed setup guide.

Data Flow

Before: User Query → Mock Data Generator → Estimated Prices
After:  User Query → SerpAPI → Real Prices → Auto-collect & Store

Confidence Levels

As data accumulates, AI responses should indicate confidence:

Days of DataConfidenceAI Disclaimer
-----------------------------------------
< 7 daysLow"价格数据为估算值,仅供参考"
7-29 daysMedium"根据部分真实价格数据..."
30+ daysHigh"根据积累的真实价格数据..."

See references/data-sources.md for more details.

References

ComponentDoc
----------------
PriceChartreferences/price-chart-component.md
Data APIreferences/price-api.md
Analysis Logicreferences/price-analysis.md
Data Sourcesreferences/data-sources.md

Example Output

Based on your search, here are the best flights to Tokyo:

[Flight Cards Component]

## Price Analysis

Current prices are **12% below average** for this route.

[PriceChart Component]

### Recommendation: Buy Now ✅
- Current price: ¥1,299
- Historical average: ¥1,450
- You save: ¥151

Prices have been falling over the past 2 weeks. If you need to travel in peak season, booking now is recommended.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-07 10:24 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

Flight Price Advisor

keyikoi
生成简洁、用户友好的机票价格摘要,并提供购买/等待建议。需要SerpAPI密钥获取实时价格数据。用于当用户询问...
★ 0 📥 630

攒够了去旅行

keyikoi
旅行积分奖励技能,围绕“攒够了,就去旅行”。仅在用户想记录今日高能量行为、将努力转为旅行积分、查询离50/100/300分目标差距或查看积分记录与旅行进度时触发。不适用于机票酒店预订、旅行攻略、路线规划、签证咨询、普通人生建议或泛化奖励池推
★ 0 📥 325

去哪不挤

keyikoi
去哪不挤:一个在节假日出行前,帮助用户判断“默认选择是否值得、哪里更不挤、更值、更适合去”的决策型 skill。 当用户询问“五一去哪不挤”“国庆想出去玩但不想人太多”“想去海边有没有比三亚更好的选择”“预算 5000 节假日去哪更值”等问
★ 0 📥 332