> For the complete documentation index, see [llms.txt](https://docs.coreway.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coreway.com/yoov-plus/worksheet/automation/automation-callapi.md).

# 自動化：調用 API 節點

## 一、功能簡介 <a href="#function-introduction" id="function-introduction"></a>

在日常業務處理中，我們經常需要借助外部應用（如 AI 助手、翻譯工具等）的能力來處理資料，然後將處理結果自動寫入系統。為了滿足這類自動化需求，YOOV Plus 在自動化中新增了 **調用 API** 節點。

透過該節點，您可以在自動化執行過程中，自動調用已授權的外部 API（如 YOOV AI Chain 中的應用），並將返回的結果傳遞給後續節點（例如「更新資料」或「新增記錄」節點）進行使用，實現跨系統的資料自動流轉與處理。

***

## 二、前置準備：配置 API 授權 <a href="#prerequisite-configure-api-authorization" id="prerequisite-configure-api-authorization"></a>

在使用自動化的調用 API 節點前，管理員需要先在系統中配置 API 的授權令牌（Token）。目前系統支援接入 YOOV 旗下的 YOOV AI Chain 產品。

{% stepper %}
{% step %}

#### 步驟 1：獲取訪問令牌 <a href="#step-1-get-access-token" id="step-1-get-access-token"></a>

在 YOOV AI Chain 或其他支援的平台中，生成並複製您的 API 訪問令牌（API Key）。

![生成訪問令牌](/files/636a9a1c4a46eab247f312d990ad3e2359ba19cd)
{% endstep %}

{% step %}

#### 步驟 2：在系統中配置授權 <a href="#step-2-configure-authorization-in-system" id="step-2-configure-authorization-in-system"></a>

進入系統的 **團隊管理** > **配置授權管理** 頁面，點擊右上角的 **新建** 按鈕，選擇 **調用 API**，在彈出的「新建令牌」視窗中填寫令牌名稱，並貼上 API Key，點擊確認。

![配置授權管理](/files/93a38b7edbc3cb34232a76250fe52c70307c7e90)
{% endstep %}

{% step %}

#### 步驟 3：授權應用 <a href="#step-3-authorize-application" id="step-3-authorize-application"></a>

建立完成後，在授權列表中找到該令牌，點擊右側的 **操作** > **授權應用**，選擇允許使用此 API 的應用範圍。

![授權應用](/files/713e98eaefa400be255befe8c361574ee6e98514)
{% endstep %}
{% endstepper %}

***

## 三、操作流程 <a href="#operation-process" id="operation-process"></a>

以下以「新增差旅申請記錄時，自動調用 AI 生成行程規劃並回填」為例，說明完整配置流程。

{% stepper %}
{% step %}

#### 步驟 1：建立工作表 <a href="#step-1-create-worksheet" id="step-1-create-worksheet"></a>

首先，在應用中建立包含所需欄位的工作表（如出發日期、返回日期、目的地、行程安排等）。

![建立工作表](/files/19e4791c588df8323c161d3a63fe7b90aa2a23e6)
{% endstep %}

{% step %}

#### 步驟 2：建立自動化 <a href="#step-2-create-automation" id="step-2-create-automation"></a>

進入自動化設計器，點擊 **新建自動化**，填寫自動化名稱，選擇觸發方式（如「表單事件」）。

![建立自動化](/files/5068a70428f864efefa29e161aac7e7e99b8b237)
{% endstep %}

{% step %}
![新建工作表事件流程](/files/c3874b3afc445c57a3c704c21119a27868d662af)

#### 步驟 3：配置開始節點（觸發條件） <a href="#step-3-configure-start-node-trigger-condition" id="step-3-configure-start-node-trigger-condition"></a>

設定自動化的觸發條件。例如選擇「當新增記錄時觸發」，並指定對應的工作表。

![配置開始節點](/files/f07a80b2c1fb26d100fb8f2226bb52858f4322d6)
{% endstep %}

{% step %}

#### 步驟 4：添加調用 API 節點 <a href="#step-4-add-call-api-node" id="step-4-add-call-api-node"></a>

在自動化設計器中，點擊 `+` 號添加節點，在彈出的選單中選擇 **調用 API** 節點。

![調用 API 節點](/files/3c01fb2d60112d21cac38e0b1fd3893ff9f3595b)
{% endstep %}

{% step %}

#### 步驟 5：配置節點 — 選擇 API 連接與介面 <a href="#step-5-configure-node-select-api-connection-and-interface" id="step-5-configure-node-select-api-connection-and-interface"></a>

在節點的屬性面板中，依次選擇 **API 連接**（即授權管理中配置的令牌）及具體的 **API 介面**（例如：行程規劃）。

{% hint style="warning" %}
若未選擇 API，將無法配置後續參數，且無法保存該自動化節點。
{% endhint %}
{% endstep %}

{% step %}

#### 步驟 6：配置輸入參數 <a href="#step-6-configure-input-parameters" id="step-6-configure-input-parameters"></a>

選擇好 API 後，系統會自動根據該 API 的要求展示所需的輸入參數列表。您可以為每個參數指定 **固定值**，或引用自動化中 **其他節點的動態欄位值**（如開始節點中的「出發日期」、「目的地」等欄位）。

![配置節點](/files/121bb75c98da57f1abda51640c22b6dae86642b3)

支援的動態值欄位類型包括：文本、地區、郵箱、電話、證件、數字、評分、日期、時間、單選、多選、成員、部門、富文本。
{% endstep %}

{% step %}

#### 步驟 7：配置後續節點 — 使用返回結果 <a href="#step-7-configure-subsequent-node-use-return-result" id="step-7-configure-subsequent-node-use-return-result"></a>

調用 API 節點執行完成後，其返回結果可在後續節點中作為變數使用。例如，添加一個 **更新資料** 節點，將「行程安排」欄位的值設定為「調用 API 節點」的輸出結果（如 `回答`）。

![更新資料節點](/files/19b21dec70fa72bb633f56034f06a51fb17f592a)
{% endstep %}
{% endstepper %}

***

## 四、運行效果 <a href="#execution-effect" id="execution-effect"></a>

自動化配置完成並啟用後，每當有新記錄被建立時，自動化將自動觸發。

**觸發前：** 使用者在表單中填寫出發日期、返回日期、目的地等基礎資訊後，提交新建記錄。此時「行程安排」欄位為空。

![新建記錄](/files/d171db4b9bf82e0922722900382ccc553d2db23e)

**觸發後：** 自動化自動執行，調用 AI 應用生成行程規劃，並將結果自動回填至「行程安排」欄位中。

![生成結果](/files/afd5b43f80dc83d19afdd3397275f396b1031855)

***

## 五、查看運行日誌 <a href="#view-execution-log" id="view-execution-log"></a>

您可以透過自動化的 **運行日誌** 查看每次調用的詳細情況，包括各節點的執行狀態、實際傳遞的輸入參數，以及 API 返回的具體結果，有助於在配置初期進行除錯與排錯。

![運行日誌](/files/a73503087a450ed8af0f4376cbbdf49c724464c6)

***

## 六、注意事項 <a href="#notes" id="notes"></a>

| 事項         | 說明                                                                   |
| ---------- | -------------------------------------------------------------------- |
| **請求失敗處理** | 可設定「繼續執行（預設）」或「中止流程」。選擇繼續執行時，後續節點使用該 API 的返回資料將為空；選擇中止流程時，日誌中將記錄中止原因 |
| **應用匯出限制** | 目前系統在進行應用匯出時，不支援將「調用 API」節點的配置一併匯出                                   |
| **參數變更規則** | 若更改了選擇的 API，輸入參數列表將重新載入；若新 API 的參數與舊 API 不同，原有配置將被清空                 |
| **返回參數類型** | Agent 或聊天應用通常只返回一個名為「回答」的文本參數；自動化類型應用則根據其輸出配置返回對應的參數及類型              |


---

# 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 dynamically by asking a question.

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

```
GET https://docs.coreway.com/yoov-plus/worksheet/automation/automation-callapi.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
