# 代理排程

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-e9169408b97b414663b27cf64cdf81ba1b95f03e%2Fschedule-infographic.png?alt=media" alt="代理排程概念"><figcaption><p>代理排程：定時觸發 → Agent 自動執行 → 結果傳送</p></figcaption></figure>

## 這是什麼？ <a href="#what-is-this" id="what-is-this"></a>

代理排程讓 Agent 不用等人提問，能按照設定的時間自動執行任務。你給它一段提示詞，設定排程時間，Agent 就會定時執行並把結果送到指定的地方。

就像幫 Agent 設了一個鬧鐘——時間到了，它就自動開工。

## 什麼時候需要用？ <a href="#when-do-you-need-it" id="when-do-you-need-it"></a>

* **定期報告**：每天早上 9 點彙整昨日客服摘要
* **監控檢查**：每小時檢查一次系統狀態，有異常就通知
* **資料處理**：每週一整理上週的銷售數據
* **單次任務**：在指定時間執行一次特定動作

## 排程類型 <a href="#schedule-types" id="schedule-types"></a>

| 類型       | 說明               | 範例                        |
| -------- | ---------------- | ------------------------- |
| **Cron** | 用 Cron 表達式設定精確時間 | `0 9 * * 1-5`（週一到五早上 9 點） |
| **間隔**   | 每隔固定時間執行一次       | 每 30 分鐘、每 2 小時            |
| **單次執行** | 在指定時間執行一次        | 2026-04-15 14:00          |

## 執行模式 <a href="#execution-mode" id="execution-mode"></a>

| 模式        | 說明                 | 適合場景             |
| --------- | ------------------ | ---------------- |
| **上下文模式** | 跨次執行保留記憶，後一次能接續前一次 | 需要累積資訊的任務（如持續追蹤） |
| **獨立模式**  | 每次從頭開始，不帶前次記憶      | 獨立的重複性任務（如每日報告）  |

## 結果傳遞 <a href="#result-delivery" id="result-delivery"></a>

執行完成後，結果可以傳送到：

* **對話**：傳送到指定的對話平台對話中
* **Webhook**：POST 到你的外部 URL（串接 Slack、LINE 等）

> **進階說明**：代理排程只支援 Agent 模式的 AI 助理。排程執行時，Agent 會以你設定的提示詞為指令，運用它掛載的所有工具和技能來完成任務。

## 我需要做什麼？ <a href="#what-do-i-need-to-do" id="what-do-i-need-to-do"></a>

1. **選擇 Agent** — 選一個已建好的 Agent（需為 Agent 模式）
2. **寫提示詞** — 描述 Agent 每次執行要做什麼
3. **設定排程** — 選擇排程類型和時間
4. **設定傳遞** — 決定結果要送去哪裡
5. **啟用** — 開啟排程，開始自動執行

## 下一步 <a href="#next-steps" id="next-steps"></a>

完整操作步驟請見 [如何設定代理排程](https://docs.maiagent.ai/agent-builder/schedule/schedule-setup)。


---

# 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/agent-builder/schedule.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.
