> For the complete documentation index, see [llms.txt](https://docs.maiagent.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.maiagent.ai/maiagent-user-guide/en/build/integrate/farmingsearch.md).

# Agricultural Data Lookup

Agricultural data query example: use an API tool to integrate with the Ministry of Agriculture's open data, so the Agent can query agricultural product transaction prices in real time and answer quest

## Use Case: Build a Real-Time Agricultural Data Query Assistant <a href="#use-case-build-agriculture-realtime-data-assistant" id="use-case-build-agriculture-realtime-data-assistant"></a>

If you work in agriculture — as a farmer, wholesaler, retailer, or a policy maker in an agriculture-related government agency — you may need to analyze and forecast market prices and trading trends for various agricultural products (such as rice, fruits, vegetables, and livestock products). By integrating with the public APIs of the Ministry of Agriculture, you can query agricultural product transaction data in real time to perform further data analysis and improve decision-making efficiency.

## Workflow <a href="#application-workflow" id="application-workflow"></a>

### 1. Create an Agricultural Product Transaction Query Tool <a href="#step1-create-crop-price-query-tool" id="step1-create-crop-price-query-tool"></a>

#### Obtain the API Configuration <a href="#get-api-config" id="get-api-config"></a>

First, go to the API section of the Agricultural Data Open Platform and obtain the data source you need.

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

Here we use agricultural product transaction prices as an example for building the tool. 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="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-62660f70253893c902138ac2831a20ab6b9ebc23%2F%E6%88%AA%E5%9C%96%202025-05-07%20%E4%B8%AD%E5%8D%8812.49.30.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-013b252bd4a4748ba5eb98f5a9e552cd92e751cd%2F%E6%88%AA%E5%9C%96%202025-05-07%20%E4%B8%AD%E5%8D%8812.52.47.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Create an API Tool <a href="#create-api-tool" id="create-api-tool"></a>

On the MaiAgent platform, click "Tools" in the left sidebar, then click "Add Tool".

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-d6e35a8068eb1f8e19e4d6fd86e727ea8ee6c59d%2F%E6%88%AA%E5%9C%96%202025-05-07%20%E4%B8%AD%E5%8D%8812.38.12.png?alt=media" alt=""><figcaption></figcaption></figure>

Enter the display name and tool name, select API as the tool type, and fill in the description of the tool.

For the API configuration below, you can take a screenshot of the API information page on the Agricultural Data Open Platform and paste it into the MaiAgent Tool Creation Agent to quickly obtain the API URL, HTTP method, headers, and parameter structure.

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

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-3b7d7aabecf51c8e3cd6c4f614818d7f95ce5ef0%2F%E6%88%AA%E5%9C%96%202025-05-07%20%E4%B8%8B%E5%8D%882.18.44.png?alt=media" 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, e.g., 107.07.10)"
    },
    "Start_time": {
      "type": "string",
      "description": "Query start date (format: ROC year.month.day, e.g., 107.07.01)"
    }
  }
}
```

### 2. Create the Agricultural Data Query Agent <a href="#step2-create-agriculture-data-query-assistant" id="step2-create-agriculture-data-query-assistant"></a>

#### Create the Agent <a href="#create-ai-agent" id="create-ai-agent"></a>

On the MaiAgent platform, click "AI Assistants" in the left sidebar, then click "Create AI Assistant".

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-ee2d91ee39ff78ee9fe01e2ccf295d603651ea70%2F%E6%88%AA%E5%9C%96%202025-05-07%20%E4%B8%8B%E5%8D%882.31.33.png?alt=media" alt=""><figcaption></figcaption></figure>

Select "Agent" as the response mode and enter the role instructions.

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-249656b2da2b645f520bc51731c60c17b7a58b3d%2F%E6%88%AA%E5%9C%96%202025-05-07%20%E4%B8%8B%E5%8D%882.32.11.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Configure Tools for the Agent <a href="#configure-tools-for-assistant" id="configure-tools-for-assistant"></a>

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

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-e95758678a9a11f4be9344de150d28cf5f946180%2F%E6%88%AA%E5%9C%96%202025-05-07%20%E4%B8%8B%E5%8D%882.34.49.png?alt=media" alt=""><figcaption></figcaption></figure>

Select the agricultural product transaction query tool you just created, then click Confirm.

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-1d7a988840ccefa5844f037cf8378f26de09d830%2F%E6%88%AA%E5%9C%96%202025-05-07%20%E4%B8%8B%E5%8D%882.36.20.png?alt=media" alt=""><figcaption></figcaption></figure>

### 3. Put the Agent into Use <a href="#step3-ai-agent-go-live" id="step3-ai-agent-go-live"></a>

You can now ask questions directly in the Agent chat interface to quickly look up information such as agricultural product trading volumes and average price changes, keeping track of market prices and trading trends in real time to support further data analysis and more efficient decision-making!

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-4528af3c211ef0e6a152c6d1b1c3f678db0f6cb1%2Fimage%20(1)%20(1)%20(1)%20(1)%20(1)%20(1).png?alt=media" alt=""><figcaption></figcaption></figure>

You can also go to "All Conversations" on the MaiAgent platform to view the records of the tools the Agent called when replying.

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-d039c958da6c415aedb62201fd01d1222acd16eb%2F%E6%88%AA%E5%9C%96%202025-05-07%20%E4%B8%8B%E5%8D%882.42.07.png?alt=media" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.maiagent.ai/maiagent-user-guide/en/build/integrate/farmingsearch.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
