# (7) 設定觸發條件

### 本篇教您的重點

觸發條件是使機器人產出特定回應節點的條件規則，「觸發」機器人將 **自然語意** 和 **腳本編輯** 的細節，對應並銜接在一起。簡單來說，就是設定機器人聽到什麼樣的內容時，做什麼樣的回應。

### 操作步驟

1. 到左欄機器人編輯點選 **`節點`**
2. 選擇需要設定觸發的 **節點**
3. 點選上方 **`觸發條件`**，點選右上 **`＋觸發條件`**
4. 在 **`判讀方式`** 選擇要使用的類型，輸入所需的規則（請往下看設定類型說明）

![](/files/-LbW-GIdGD644Xr3-i90)

### 觸發條件判讀方式

1. 自然語意（意圖、抽換詞的搭配等）
2. 關鍵字比對（一或多組關鍵字）
3. 正規表達式

最常見的使用方式是 1 與 2 ，以下分別進行說明。

#### 1. 用自然語意設定觸發條件

利用意圖（或意圖＆抽換詞類）來設定。\
例如用&#x20;

a.  意圖 **外送**\
b.  意圖 **價格** ＆ 抽換詞類 **飲品**

![](/files/-LbW-MNRGZgoSWtDNF68)

![](/files/-LbW-PQYrxXzc4m09qZ-)

#### 2. 用關鍵字設定觸發條件

例如輸入 「外送」「訂購」等關鍵字來觸發回應。只要句子內包含任一項關鍵字，都會被觸發，進而回應該節點的內容。

![](/files/-LbW-TQ06MC-3mdS37Ut)

#### 3. 用正規表達式設定觸發條件

正規表達式是描述某種規則的表達式 ，用來檢索、搜尋或替換符合某個模式或特定排列組合的文字。 舉例我們想要含有「訂購」或「外送」字眼的句子都可以被搜尋到，就可以用正規表達式來設定。\
\
**我想要訂購飲料**\
**要外送飲料**\
**有外送嗎**\
**可以訂購飲料嗎**\
\
上面幾個句子，透過一組正規表達式，都可以被列入搜尋範圍內：\
\&#xNAN;**^我?(需|想)?要?可以?有?(訂購|外送)(飲料)?嗎?$**\
\
您可以利用此方式來設定觸發條件，詳情可參考[正規表達式](https://docs.yoctol.ai/term/regex)教學。

![](/files/-LbW1OOMv2C93BknCpaF)

{% hint style="danger" %}
一種觸發條件，只能接在單一節點。但一個節點，可以有多種觸發條件。

例如我們有「外送」意圖，可以設定一組使用 **意圖** 的觸發條件，\
只要意圖判斷為『外送』，就導到這個節點回應：\
「訂單滿兩百元即可外送，外送請來電 1234-5678」\
同時也可以設定一組用 **關鍵字** 的觸發條件，只要聽到「外送」，就會回應上方的內容。
{% endhint %}

![](/files/-LbW8cuHmGFdZbhI3URM)

![](/files/-LbW8f1UZCKf-r1wvw2H)


---

# 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-tw.yoctol.ai/guide/edit_trigger.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.
