# API

大致上跟下面網址API一致

API密鑰產生後，可以複製密鑰，並在Header的Authorization帶入'Bearer ' + {{token}}即可，注意產生密鑰後查看請複製該密鑰，十五分鐘後將會無法再查詢到。

{% embed url="<https://docs.communeify.com/tw/products/dmflow/tutorials/docs/bot-restapi.html>" %}

另新增

### 閒聊角色

更新產品

PATCH /\_api/v1/roleqa/product/info/{id}

| HEADER KEY    | HEADER VALUE |
| ------------- | ------------ |
| Authorization | {{auth}}     |

REQUEST JSON

```json
{
	"title": "",
	"description": "",
	"rating": 0.0f,
	"enabled": false
}
```

<table><thead><tr><th>REQUEST_PATH</th><th data-type="checkbox">必填</th><th>型態</th><th>說明</th></tr></thead><tbody><tr><td>title</td><td>false</td><td>string</td><td>若填寫則會覆蓋</td></tr><tr><td>description</td><td>false</td><td>string</td><td>若填寫則會覆蓋</td></tr><tr><td>rating</td><td>false</td><td>number</td><td>0~5</td></tr><tr><td>enabled</td><td>false</td><td>boolean</td><td>是否</td></tr></tbody></table>

RESPONSE JSON

```json
{
	"rc" : 0
}
```

### 表單問答

#### 查詢表單

POST /\_api/v1/formqa/search

| HEADER KEY    | HEADER VALUE |
| ------------- | ------------ |
| Authorization | {{auth}}     |

REQUEST JSON

```json
{
	"id": "",
	"tableId": "",
	"index": 0,
	"onlyReturnCount": false,
	"wheres": [{
			"name": "",
			"compare": "",
			"value": ""
		}
	]
}
```

<table><thead><tr><th>REQUEST_PATH</th><th data-type="checkbox">必填</th><th>型態</th><th>說明</th></tr></thead><tbody><tr><td>id</td><td>false</td><td>string</td><td>主鍵ID，有ID將不會理會wheres</td></tr><tr><td>tableId</td><td>true</td><td>string</td><td>表單ID</td></tr><tr><td>index</td><td>true</td><td>number</td><td>頁碼</td></tr><tr><td>onlyReturnCount</td><td>false</td><td>boolean</td><td>是否只要count</td></tr><tr><td>wheres</td><td>false</td><td>array</td><td>conditions</td></tr><tr><td>wheres[0].name</td><td>true</td><td>string</td><td>欄位鍵(不能使用於text欄位)</td></tr><tr><td>wheres[0].compare</td><td>true</td><td>enum</td><td>eq(關鍵字使用eq等同in), gt, lt, lte, gte</td></tr><tr><td>wheres[0].value</td><td>true</td><td>string</td><td>如果是日期欄位請使用(秒數)，數字則請用數字</td></tr></tbody></table>

暫時不支援order以及size，預設每次size為20

RESPONSE JSON

```json
{
	"rc" : 0
	"error": "",
	"data": {
		"total_element": 0,
		"docs": []
	}
}
```

#### 表單觸發動作

POST /\_api/v1/formqa/action

Trigger action API限制每個trigger每小時執行100次包含(迴圈次數)，但不會因為100次而停止，假設已經運行了99次，最後一次如果有100次包含迴圈則仍會執行最後一次，而不是執行一半停止。

| HEADER KEY    | HEADER VALUE |
| ------------- | ------------ |
| Authorization | {{auth}}     |

REQUEST JSON

```json
{
	"parameters": {},
	"triggerId": "",
	"tableId": "",
	"guestId": ""
}
```

<table><thead><tr><th>REQUEST_PATH</th><th data-type="checkbox">必填</th><th>型態</th><th>說明</th></tr></thead><tbody><tr><td>parameters</td><td>true</td><td>object</td><td><p>{</p><p>    "product": "產品名",</p><p>    "price": 200,</p><p>    "quantity": 5</p><p>}</p></td></tr><tr><td>triggerId</td><td>true</td><td>string</td><td>觸發器ID</td></tr><tr><td>tableId</td><td>true</td><td>string</td><td>表單ID</td></tr><tr><td>guestId</td><td>false</td><td>string</td><td>匿名使用者ID</td></tr></tbody></table>

RESPONSE JSON

```json
{
	"rc" : 0
	"error": "",
	"data": {
		"error": false,
		"success": true,
		"response": ""
	}
}
```

data.error 代表觸發器觸發了錯誤節點

data.success 代表觸發器成功抵達END節點

rc不為零為錯誤訊息，此錯誤可能是因為API KEY不對，或是參數不正確，而error是告知你為何錯誤。

### 使用須知

目前伺服器採用使用才啟動，若第一次呼叫API可能會需要一點時間，但後面就會恢復正常時間。

### 已棄用

/\_api/v1/bot/chat


---

# 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.dmflow.chat/api.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.
