# Agricultural Data Query

## Application Scenario: Building an Agricultural Real-Time Data Query Assistant

If you are an agricultural professional, such as a farmer, wholesaler, retailer, or a policy maker in agricultural public sector organizations, in order to analyze and predict market prices and transaction trends for various agricultural products (such as rice, fruits, vegetables, livestock products, etc.), you can integrate with the public APIs provided by the Ministry of Agriculture to query agricultural product transaction data in real-time, further enabling data analysis and improving decision-making efficiency.

## Application Process

### 1. Create Agricultural Product Transaction Market Query Tool

#### Obtain API Configuration

First, you can obtain the required data integration source according to your needs through the API section of the Agricultural Data Open Platform.

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

Here we use agricultural product transaction market data as an example for tool setup. In the Parameters section, click the <mark style="color:blue;">"Try it out"</mark> button, then click <mark style="color:blue;">"Execute"</mark> to obtain the API configuration data.

<figure><img src="/files/6NKyiXsNKYTcyjmQJLlM" alt=""><figcaption></figcaption></figure>

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

#### Create API Tool

Click "Tools" in the left function menu of the MaiAgent platform, then click "Add Tool"

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

Fill in the display name, tool name, select API for tool type, and write the description of this tool

In the API configuration section below, you can take a screenshot of the API information interface from the Agricultural Data Open Platform and paste it into the MaiAgent tool creation assistant to quickly obtain API URL, HTTP method, headers, and parameter structure content.

{% hint style="info" %}
[Tool Creation AI Assistant](https://chat.maiagent.ai/web-chats/27934296-105a-4f3f-80f0-7e9dcdb638d3)
{% endhint %}

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

* API URL Example: `https://data.moa.gov.tw/api/v1/AgriProductsTransType/`
* HTTP Method Example: `GET`
* Headers (JSON) Example:

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

* Parameter Structure (JSON Schema) Example:

```
{
  "type": "object",
  "required": [
    "Start_time",
    "End_time"
  ],
  "properties": {
    "End_time": {
      "type": "string",
      "description": "Query end date (format: ROC year.month.day, example: 107.07.10)"
    },
    "Start_time": {
      "type": "string",
      "description": "Query start date (format: ROC year.month.day, example: 107.07.01)"
    }
  }
}
```

### 2. Create Agricultural Data Query AI Assistant

#### Create AI Assistant

Click "AI Assistant" in the left function menu of the MaiAgent platform, then click "Create AI Assistant"

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

Select "Agent" for response mode, and enter role instructions

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

#### Configure Tools for AI Assistant

Select the "Tools" tab, click <mark style="color:blue;">"+ Select Tool"</mark>

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

Select the agricultural product transaction market query tool you just created, and click confirm

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

### 3. AI Assistant Online Application

Now you can directly ask questions through the AI assistant Q\&A interface to quickly query information such as agricultural product transaction volume and average price changes. This allows you to instantly grasp market prices and transaction trends, facilitating further data analysis and improving decision-making efficiency!

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

You can also go to the "All Conversations" function of the MaiAgent platform to view the tool invocation records when the AI assistant responds.

<figure><img src="/files/tct8PvI9Uy1H9qAjnj4H" 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/maiagent-user-guide/maiagent-user-guide-en/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.
