> For the complete documentation index, see [llms.txt](https://docs.dmflow.chat/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dmflow.chat/domain/formqa/trigger/http.md).

# HTTP

HTTP節點需要先在外面的**資源管理**和**便數管理**處理。

<figure><img src="/files/Y4pM2T0MR43eCnfZM0MT" alt=""><figcaption><p>http節點</p></figcaption></figure>

## 變數以及資源管理 <a href="#bian-shu-yi-ji-zi-yuan-guan-li" id="bian-shu-yi-ji-zi-yuan-guan-li"></a>

* 變數管理：在對話流程中，您可以使用變數來管理和存儲資源所需的參數。變數用於傳遞資源參數，或是代表回傳參數。
* 資源管理：在對話流程中，資源節點用於管理資源的使用和連接對外的API，以實現業務邏輯的交互。資源節點可以執行特定的操作，例如調用外部API進行數據查詢、修改資源狀態、存取外部資料庫等。通過資源節點的使用，您可以在對話流程中實現與外部系統的集成，提供更豐富和個性化的服務。藉由資源管理，您可以有效利用現有的資源和外部服務來擴展對話系統的功能和能力。

### 變數管理

![DMflow新增變數](https://docs-on-prem.dmflow.chat/images/tw/bot-resource-var.png)

* 1.名稱：變數的名稱，通常使用英文來命名。名稱應具有描述性，以便在對話流程中識別和使用該變數。
* 2.指定變數的數據類型，可選的屬性有：
  * 字串（string）：用於存儲文字信息。
  * 數字（number）：用於存儲數值。
  * 日期時間（datetime）：用於存儲日期和時間。
  * 布林（bool）：用於存儲真假值。
  * 物件（object）：用於存儲複雜的結構化數據。
  * 陣列（array）：用於存儲多個值的集合。
* 3.描述：對變數的說明和解釋，可以提供更詳細的信息，以幫助開發人員理解該變數的用途和功能。
* 4.別名：這是一個可選的屬性，用於為變數指定別名，以便更容易理解和辨識該變數。例如，如果變數名稱是"price"，您可以為其指定別名"價格"或"價錢"，這樣在對話流程中使用該變數時，可以更直觀地理解其含義。

### 資源管理

![DMflow新增資源](https://docs-on-prem.dmflow.chat/images/tw/bot-resource-add.png)

* 1.資源名稱：該資源的名稱，使用英文進行命名。
* 2.描述：對該資源的說明和解釋，可以提供更詳細的信息，以幫助開發人員理解該資源的用途和功能。
* 3.請求地址：資源的業務邏輯地址，請填寫完整的URL，並確保已包含https協定。
* 4.請求型態：指定資源的請求方法，目前支援GET、POST、PATCH、PUT、DELETE請求方式。
* 5.Content-Type：指定請求的內容類型，可選擇URL編碼或JSON格式（application/json）。
* 6.請求頭欄位：填寫請求的標頭信息，根據不同的前綴指定不同的標頭類型，可選擇常數（constant）、使用者參數（user）\[目前僅支援閒聊對話，暫時不支援表單]。
* 7.參數：根據請求的Content-Type填寫相應的參數，這些參數將被注入到請求中。\[延伸2]
* 8.回傳值：指定該請求的回傳值，您可以指定要提取的JSON路徑，並將其值注入到指定的變數中。\[延伸3]

#### 延伸1

* constant:後面可放任何文字，不用理會前綴。

#### 延伸2

假設有一參數city=>城市

* URL:直接作為參數\&city=urlEncode(城市) 方式傳遞。
* JSON:則是 {"city":"城市"} 方式傳遞。

#### 延伸3

假設地址回應為{"city":"城市"}，有一參數city=>城市

那JSON路徑為city，鍵選擇變數city即可。而數值將會在"對話流程"中的"資源節點"做注入。

#### JSON路徑教學

JSON路徑：範例地址回應為{"city":"城市", "obj":{"apple":"蘋果"}, "order":\["訂單"]}

* 假如我們要拿城市則路徑為city
* 假如我們要拿蘋果則路徑為obj\['apple']
* 假如我們要拿訂單則路徑為order\[0]


---

# 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.dmflow.chat/domain/formqa/trigger/http.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.
