# 交談腳本變數

## 概述

在交談腳本中，除了「即時聊天」管道外，您可以透過外部設定腳本變數來控制交談流程。此外，還有許多預設的交談變數可供使用。這些預設變數可以在交談過程中使用，以個性化和自定義您的回答。

這些預設交談變數可以涵蓋用戶的名稱、客戶名稱等相關資訊。您可以根據這些變數提供更加個人化和即時的回應。同樣地，這些變數也可以在「Webhook 交談腳本」中使用，以進行呼叫傳遞。

透過設定腳本變數和使用預設交談變數，您可以根據需求和情境來定制交談腳本，以提供更好的用戶體驗和解決方案。無論是在即時聊天還是透過 Webhook，這些變數都能助您打造更具個性化和互動性的交談。

{% hint style="warning" %}
**⚠️ 變數使用注意事項**

請特別留意，**變數並非在所有情境下都會帶有對應值**，實際是否可用，將取決於使用場景與來源條件：

1. **`contact_*` 相關變數**：需已建立或關聯具名聯絡人（Contact）資料，否則將無法帶入對應值。
2. **`page_*` 相關變數**：僅在使用者透過**即時聊天（Live Chat）進線**時才會產生，用於追蹤來源頁面等資訊。
3. **`contactable_liff_user_id`**：僅在整合 **LINE LIFF** 並由**即時聊天啟動**的情境下才會取得，其他管道或未啟用 LIFF 機制時則不會有值。
   {% endhint %}

## 預設變數

| 變數                          | 名稱              | 描述                                           |
| --------------------------- | --------------- | -------------------------------------------- |
| queue.length                | 佇列等待人數          | 當前交談佇列中等待、分派中的總數。                            |
| page.url                    | 來自網頁位址          | 即時聊天顧客來自網頁的位址。                               |
| page.title                  | 來自網頁標題          | 即時聊天顧客來自網頁的標題。                               |
| contactable\_user\_id       | 進線來源識別碼         | 進線來源對應的識別碼，如 LINE 、 Facebook 訊息 API 驗證用的 ID。 |
| contactable\_username       | 進線來源用戶姓名        | 進線來源對應的用戶顯示名稱，如 LINE 或 Facebook 個人檔案姓名。      |
| contactable\_liff\_user\_id | LIFF 用戶編號       | 若透過即時聊天並整合 LIFF，可透過此變數取得 LIFF 用戶的用戶編號。       |
| session\_id.session\_id     | 腳本 Session 系統代碼 | 當每一交談進入腳本時，將自動產生唯一代碼用於辨識。                    |
| contact.id                  | 客戶系統編號          | 進線來源關聯的客戶系統編號。                               |
| contact.name                | 客戶姓名            | 進線來源關聯的客戶姓名。                                 |
| contact.first\_name         | 客戶姓氏            | 進線來源關聯的客戶姓氏。                                 |
| contact.last\_name          | 客戶名字            | 進線來源關聯的客戶名字。                                 |
| contact.membership\_no      | 客戶會員編號          | 進線來源關聯的客戶會員編號。                               |
| contact.identity\_no        | 客戶身分證字號         | 進線來源關聯的客戶身分證字號。                              |

<figure><img src="/files/2eJEyNcwv7PaQjsCAgd1" alt=""><figcaption></figcaption></figure>


---

# 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://help.firstline.cc/feature/other/jiao-tan-jiao-ben-bian-shu.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.
