# 從即時聊天 URL 添加數據

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

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

![](https://842546780-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MNRu7dk70ei7JV9HlW9%2Fuploads%2FgEw4rxyel4nWTBZvocap%2F%E6%88%AA%E5%9C%96%202022-03-11%2013.16.33.png?alt=media\&token=50c2ab27-abf7-4ffa-a4a3-f4d58a179c33)

## 將變數新增至嵌入網址 <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>

![](https://842546780-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MNRu7dk70ei7JV9HlW9%2Fuploads%2FP5CyIyngsBE1RKQZjRoG%2F%E6%88%AA%E5%9C%96%202022-03-11%2013.30.02.png?alt=media\&token=de141020-f1c2-4d0d-8da9-2b1e87a34e45)
