> 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/chatbot/render_text.md).

# 文字模板測試

### 函數提示

使用{{ }} 可以使用函數，大多數參數會自行autocomplete

* input前後要包含{{ }} 才會做函數計算

例如

```
{{ '今天氣溫' + data.conversation.temperature_today + '度c' }}
```

* textarea可以在內文包含{{ }}

例如

```
今天氣溫 {{data.conversation.temperature_today}} 度c
明天氣溫 {{data.conversation.temperature_tomorrow}} 度c
```

### 觸發器

* 若是input 關鍵字假如只有一個數值會自動拆箱，例如\["a"]=>a，兩個以上不會
* 若placeholder有寫使用','分隔，關鍵字會自動分離，不需要','
* 其他與函數提示相同

### 閒聊角色預提示詞設參數

* cur\_time 會同時提供日期時間以及星期幾
* user\_profile 會同時包含信箱、手機以及使用者名稱
* 其餘參數根據傳遞變數傳送(一個領域目前支援三個傳遞變數)

提示詞目前不支援函數，僅支援文字替換。

例如: 你傳遞的變數為

```
{
  "test" : "1234"
}
```

```
提示詞為 {{ test }}   會轉為 提示詞為1234
```

### 機器人流程

* 開始節點和回覆節點，同textarea
* 其餘節點必須要使用constant 前綴才可啟動{{ }}函數使用，且一定要前後要包含{{ }}，才可以使用
* 機器人流程的參數多為data.user, data.sys\_user, data.converssation, data.session 開頭。

### 資源

* 機器人資源constant 前綴可使用{{ }}作為函數使用，領域的資源暫時不支援函數。
* 網址路徑除了domain外，皆可以用{{ }}取代
* 例如:

```
https://app.dmflow.chat/{{ path }}  ====> ok!
https://{{ domain }}/test           ====> 不能
```

且domain不能使用IP或是一些通用網路伺服器提供的網域，若是使用雲端伺服器建議綁定自己的domain，否則可能會無法運作。

當機器人運作後一旦發現網域無法使用將會自動關閉該資源節點功能。

### 預設函數

* Utils.generateSignature(body:string, secret:string, algo:string)
* &#x20;   algo \['HMACSHA256', 'HMACSHA1', 'HMACSHA384', 'HMACSHA512', 'HMACMD5'] 也可以去掉HMAC
* Utils.hash(text:string)
* &#x20; 使用MurmurHash，轉成number，hash有負數
* Utils.atob(text:string)
* &#x20; 文字轉成Base64
* Utils.toSeconds(date: string)
* &#x20; 將yyyy-MM-ddTHH:mm:ssZZZ 轉成秒數&#x20;
* Utils.randomValue(length: number)
* &#x20; ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789隨機取length位數
* Utils.extractTime(value: number | string, format: string, offset: string)
* &#x20; value需要是秒數， format 請用yyyy-MM-ddTHH:mm:ssZZZ模式填寫，offset請用+08:00填寫
* Utils.extractTime(value: number | string, format: string)
* &#x20; 機器人流程使用有預設時區，可以直接使用這個函數
* Utils.now(offset: string)
* &#x20; 會將現在時間轉為時間模式yyyy-MM-ddTHH:mm:ssZZZ
* Utils.format(dateString: string, format:string)
* &#x20; 會將時間模式為yyyy-MM-ddTHH:mm:ssZZZ轉為其他模式
* Utils.encrypt(text: string)
* &#x20; 根據機器人和領域建立時產生的密鑰加密
* Utils.decrypt(text: string)
* &#x20; 根據機器人和領域建立時產生的密鑰解密

以上為目前提供的函數，若有新增財補充 可參考 [觸發器](/domain/formqa/trigger.md#qi-ta-han-shu-shi-yong)

### 時間格式

領域的時間以yyyy-MM-ddTHH:mm:ssZZZ為主

機器人的時間是以UTC 秒數為主


---

# 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/chatbot/render_text.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.
