# 從即時聊天 URL 添加數據

## 啟用**相關**設定

至單一即時聊天管理頁面，選擇「傳遞變數至腳本」頁籤，啟用允許透過網址傳入變數設定後，進行儲存。

![](/files/x5yj5VbpWa6v6NBKxzmi)

## 將變數新增至嵌入網址 <a href="#to-add-the-variable-to-an-embedded-bot" id="to-add-the-variable-to-an-embedded-bot"></a>

將變數附加 URL 做為查詢字串參數(Query string)，如 contact\_name=bruce.wayne，每組參數都是用「&」區隔開來。

例如：

* 您有一個名為 location 的變數。
* 您的即時聊天網址 URL 或嵌入代碼是 ：

```html
<div class=div id="firstline-livechat-app"><iframe-app/></div>
<script src="https://yourwebsite.firstline.cc/livechat.js</script>
```

* 若要在進入腳本交談時傳入資訊，您可以於網址附加 location`=`查詢字串：

```html
<div class=div id="firstline-livechat-app"><iframe-app/></div>
<script src="https://yourwebsite.firstline.cc/livechat.js?location=Tokyo</script>
```

* 每次進入腳本前，都以當前即時聊天作為傳遞資訊依據為主，前一次傳入的資訊將會清除。

{% hint style="warning" %}
**避免傳遞敏感資訊與使用保留字**

此功能為配合機器人流程應用場景能更加豐富，請勿用於透過此方式傳遞敏感性資訊，如信用卡號碼、密碼等資訊。且避免使用系統預設的變數名，包含 **uuid、token、once\_code**，將不會作用。
{% endhint %}

## **對話腳本或 Webhook 腳本使用變數**

若要在腳本中使用變數，如傳遞訊息，需加入前綴詞 extra\_settings.，如 extra\_settings.contact\_name 或 extra\_settings.location 來使用。

`嗨！來自 {{ extra_settings.location }} 的 {{ extra_settings.contact_name }} 先生/小姐，您好！👋`<br>

![](/files/GkT9ZkGxdVqTqBTNbZj2)


---

# 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/chatbot/scenario/add-data-from-url-parameters.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.
