# 農業數據資料查詢

## 應用情境：打造農業即時數據查詢助理 <a href="#use-case-build-agriculture-realtime-data-assistant" id="use-case-build-agriculture-realtime-data-assistant"></a>

若您是農業從業人員，例如農民、批發商、零售商，或是農業相關公部門的政策制定者，為了分析與預測各類農產品（如稻米、水果、蔬菜、畜牧產品等）的市場價格與交易趨勢，可透過介接農業部公開的 API，即時查詢農產品的交易資料，進一步進行數據分析、提升決策制定效率。

## 應用流程 <a href="#application-workflow" id="application-workflow"></a>

### 1. 建立農產品交易行情查詢工具 <a href="#step1-create-crop-price-query-tool" id="step1-create-crop-price-query-tool"></a>

#### 取得 API 配置 <a href="#get-api-config" id="get-api-config"></a>

首先，您可先透過農業資料開放平台的 API 專區，依據需求取得所需的資料介接來源。

{% hint style="info" %}
<https://data.moa.gov.tw/api.aspx>
{% endhint %}

這邊以農產品交易行情作為工具建置範例，於 Parameters 區塊點選 <mark style="color:blue;">「Try it out」</mark> 按鈕，接著點選 <mark style="color:blue;">「Execute」</mark>，即可取得 API 配置資料。

<figure><img src="/files/FL7xE84VK1lqREFDnFxy" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/BQDCApM6Mru0xJ2zBHp2" alt=""><figcaption></figcaption></figure>

#### 建立 API 工具 <a href="#create-api-tool" id="create-api-tool"></a>

至 MaiAgent 平台左側功能欄點選 「工具」，點選 「新增工具」

<figure><img src="/files/TmwCLmSoJ7afWkwhZZFd" alt=""><figcaption></figcaption></figure>

填入顯示名稱、工具名稱，工具類型選擇 API，填寫此工具的描述

下方 API 配置，可將農業資料開放平台上的 API 資訊介面截圖，貼至 MaiAgent 工具製作助理，快速取得 API URL、HTTP 方法、標頭、參數結構內容。

{% hint style="info" %}
[工具製作 AI 助理](https://chat.maiagent.ai/web-chats/27934296-105a-4f3f-80f0-7e9dcdb638d3)
{% endhint %}

<figure><img src="/files/9SFWBYYPETwlrcGLmtHY" alt=""><figcaption></figcaption></figure>

* API URL 範例：`https://data.moa.gov.tw/api/v1/AgriProductsTransType/`
* HTTP 方法範例：`GET`
* 標頭 (JSON) 範例：

```
{
  "Accept": "application/json"
}
```

* 參數結構 (JSON Schema) 範例：

```
{
  "type": "object",
  "required": [
    "Start_time",
    "End_time"
  ],
  "properties": {
    "End_time": {
      "type": "string",
      "description": "查詢結束日期 (格式: 民國年.月.日, 例如: 107.07.10)"
    },
    "Start_time": {
      "type": "string",
      "description": "查詢起始日期 (格式: 民國年.月.日, 例如: 107.07.01)"
    }
  }
}
```

### 2. 建立農業資料查詢 AI 助理 <a href="#step2-create-agriculture-data-query-assistant" id="step2-create-agriculture-data-query-assistant"></a>

#### 建立 AI 助理 <a href="#create-ai-agent" id="create-ai-agent"></a>

至 MaiAgent 平台左側功能欄點選 「AI 助理」，點選 「建立 AI 助理」

<figure><img src="/files/SVfBmspFIzLlOlXXzgPy" alt=""><figcaption></figcaption></figure>

回答模式選擇 「Agent」，輸入角色指令

<figure><img src="/files/aJG7PowlcFAUHsQJcmH8" alt=""><figcaption></figcaption></figure>

#### 為 AI 助理配置工具 <a href="#configure-tools-for-assistant" id="configure-tools-for-assistant"></a>

選擇 「工具」 頁籤，點選 <mark style="color:blue;">「＋選擇工具」</mark>

<figure><img src="/files/mZOcO3fBC2xACVGfY5t7" alt=""><figcaption></figcaption></figure>

選擇方才建立的農產品交易行情查詢工具，點選確認

<figure><img src="/files/jyQ5sjXS14OHPLsiNNAl" alt=""><figcaption></figcaption></figure>

### 3. AI 助理上線應用 <a href="#step3-ai-agent-go-live" id="step3-ai-agent-go-live"></a>

現在您可以直接透過 AI 助理問答介面進行提問，快速查詢農產品交易量、平均價格變化等資訊，即時掌握市場價格與交易趨勢，方便進一步進行數據分析、提升決策分析效率！

<figure><img src="/files/dqSiPpQNNMeTWD4FkGDQ" alt=""><figcaption></figcaption></figure>

您也可至 MaAgent 平台的 「所有對話」 功能，查看 AI 助理回覆時調用的工具記錄。

<figure><img src="/files/BNtZXdh2VlwUMSDhw3Lo" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.maiagent.ai/application/integrate/farmingsearch.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
