Files
hakorune/private_test/ai_agent_workflow.md
Moe Charm 4b984d937b refactor: MIR builder - extract expressions module (Phase 3-5)
- Moved all expression-related functions to expressions.rs (621 lines)
- Includes: build_expression, build_literal, binary/unary ops
- Added missing functions for build_expression completeness:
  - build_assignment, build_field_assignment
  - build_new_expression, build_await_expression
- expressions.rs now contains 16 functions total
- Build verified successfully
2025-08-25 18:15:23 +09:00

113 lines
2.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# AI Agents Challenge - ワークフロー設計
## 基本的な流れ
### 1. **Nyash側** - トリガー送信
```nyash
box PriceMonitorAgent {
init { webhookUrl, products }
checkPrices() {
local net = new NetBox()
local data = new MapBox()
data.set("action", "check_prices")
data.set("products", me.products)
// n8nのWebhookをトリガー
net.post(me.webhookUrl, data.toJsonBox())
}
}
```
### 2. **n8n側** - ワークフロー
```
[Webhook] → [AI Agent] → [Bright Data] → [Process] → [Response]
```
- **Webhook Node**: Nyashからのリクエストを受信
- **AI Agent Node**:
- どのサイトをスクレイピングするか決定
- Bright Dataへのクエリを構築
- **Bright Data Node**:
- 実際のWebスクレイピング実行
- 商品価格などのデータ取得
- **Process**: データ整形・比較
- **Response**: 結果をWebhookで返す
### 3. **具体例: 価格監視エージェント**
#### Nyash側の実装
```nyash
static box Main {
main() {
local agent = new PriceMonitorAgent()
agent.webhookUrl = "https://your-n8n-instance.n8n.cloud/webhook/price-monitor"
// 監視したい商品
local products = new ArrayBox()
products.push({
"name": "iPhone 15",
"url": "https://example.com/iphone15",
"targetPrice": 800
})
agent.products = products
agent.checkPrices()
}
}
```
#### n8nでの設定手順
1. **Webhook Node設定**
- Method: POST
- Path: /price-monitor
- Response Mode: Last Node
2. **AI Agent Node設定**
- Model: GPT-3.5/4
- Prompt:
```
商品リストから、Bright Dataでスクレイピングすべき
URLとセレクタを生成してください。
商品: {{$json.products}}
```
3. **Bright Data Node設定**
- Scraper API使用
- Dynamic URL from AI Agent
- Extract: 価格情報
4. **Code Node価格比較**
```javascript
const currentPrice = $node["Bright Data"].json.price;
const targetPrice = $node["Webhook"].json.products[0].targetPrice;
if (currentPrice < targetPrice) {
return {
alert: true,
message: `価格が下がりました!${currentPrice}円`
};
}
```
### チャレンジの要件チェック
- ✅ n8n AI Agent Node使用
- ✅ Bright Data Verified Node使用
- ✅ 実用的で複雑
- ✅ 創造的Nyash言語使用
### デモ動画に含めるべき内容
1. Nyashコードの実行
2. n8nワークフローの動作
3. Bright Dataでのデータ取得
4. 結果の表示
### 簡単に始めるには
まず超シンプルな例から:
1. Webhookを受け取る
2. AI Agentに「今日の天気は」と聞く
3. 結果を返す
これが動いたら、Bright Dataを追加していく