> For the complete documentation index, see [llms.txt](https://docs.maiagent.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.maiagent.ai/tech/serve/whatislineliff/setting.md).

# LINE LIFF：如何串接

LINE LIFF 串接步驟：在 LINE Developers 建立 LIFF app、把對話平台公開網址設為 Endpoint URL，讓 Web Chat 在 LINE 聊天視窗內開啟。

### <mark style="color:blue;">使用前提：</mark>

* 已經在 [MaiAgent 平台](https://admin.maiagent.ai/)上建立好一個 「Website」 的對話平台，
* 已經在 [LINE Developers](https://developers.line.biz/zh-hant/) 的 console 平台建立好一個 「Provider」 以及 「LINE Login」 的 channel

<figure><img src="https://527168072-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F38pkhhqHl1oA6yyE9R2n%2Fuploads%2Fgit-blob-dd3350c5121d7228cf1e7f5b7de7a63f86c2ff5b%2Fimage%20(4).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://527168072-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F38pkhhqHl1oA6yyE9R2n%2Fuploads%2Fgit-blob-3a561089a06f504505da12ec371b943e79e2a24d%2Fimage%20(2)%20(1)%20(1).png?alt=media" alt=""><figcaption></figcaption></figure>

### <mark style="color:blue;">設定步驟：</mark>

1\. 在在 [LINE Developers](https://developers.line.biz/zh-hant/) 的 LINE Developers console 平台， LIFF detail 的頁面 「**LIFF app name**」 欄位為您的 **LIFF app** 命名。

**2. Size** 欄位選擇 **Full**

**3. Endpoint URL** 欄位

將對話平台的 「**公開訪問URL**」 複製到 「**Endpoint URL**」 欄位，加上「**/line-liff/」**

4\. **Scopes** 欄位同時勾選 **openid** 與 **profile**

{% hint style="warning" %}
**openid** 必須勾選。MaiAgent 會用 LINE 簽發的 ID token 向 LINE 驗證使用者身分，驗證通過才把對話記到該 LINE 使用者名下；沒勾 openid 時，LIFF 頁面仍可對話，但對話會以匿名聯絡人記錄，後台看不到 LINE 使用者的名稱與頭像。已經上線的 LIFF app 請回到 LIFF detail 頁面補勾 openid 並按「Update」。
{% endhint %}

5\. **Add friend option** 欄位選擇 \*\*\*\*On (normal)

6\. 按下 頁面下方的「 Save」按鈕，再回到剛剛的 LIFF detail 頁面，此時您會看到 系統已產生一個 **LIFF ID，將該 ID 填入到** 「Endpoint URL」 欄位中網址「.../line-liff/」的後面，並按下「 **Update**」

7\. 最後到最上方，將此 **LIFF** <mark style="color:blue;">**Published**</mark>，即完成設定與上線。

<figure><img src="https://527168072-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F38pkhhqHl1oA6yyE9R2n%2Fuploads%2Fgit-blob-f3f2b36fbf9047e6fe13237a1e5ae7b01fc53eda%2Fimage%20(7).png?alt=media" alt=""><figcaption></figcaption></figure>

### <mark style="color:blue;">開始使用！</mark>

1. 「**LIFF URL**」 就是這個 **LIFF** 的連結網址。
2. LINE 的聊天室中點開 「**LIFF URL**」 連結的使用者（圖文選單）便會被導向到 Web Chat 頁面使用 Agent 對話，MaiAgent 的後台就可以收到用戶、對話資訊。

<figure><img src="https://527168072-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F38pkhhqHl1oA6yyE9R2n%2Fuploads%2Fgit-blob-6abe39cd45ce7f907a720c43bac23b24365d18a8%2Fimage%20(9).png?alt=media" alt="" width="188"><figcaption></figcaption></figure>

### <mark style="color:blue;">聯絡人同步行為與限制</mark> <a href="#contact-sync-behavior" id="contact-sync-behavior"></a>

1. **聯絡人如何建立**：使用者透過 LIFF 開啟 Web Chat 並送出訊息時，MaiAgent 會以該使用者的 **LINE User ID** 在這個對話平台建立聯絡人；之後同一位使用者再次對話，會更新該聯絡人的**名稱**與**頭像**。
2. **只取得 openid 與 profile 範圍的資料**：LIFF 只取得驗證身分用的 ID token 與 LINE 的 profile（LINE User ID、顯示名稱、頭像），**拿不到電話、Email** 等其他個人資料。
3. **聯絡人在各自的對話平台中比對**：聯絡人只會在同一個對話平台內以 LINE User ID 比對，不會跨對話平台合併。同一位使用者從 **LINE 官方帳號**（LINE 對話平台）和 **LIFF 網頁**（Website 對話平台）進來，在後台會是**兩筆聯絡人**。
4. **LINE Login channel 與 Messaging API channel 要放在同一個 Provider**：LINE User ID 依 Provider 區分，同一位使用者在不同 Provider 底下會拿到不同的 LINE User ID。請將 LIFF 所在的 LINE Login channel 與 LINE 官方帳號的 Messaging API channel 建在同一個 Provider 底下，兩邊的聯絡人才會是同一個 LINE User ID，方便您比對同一位使用者。

{% hint style="info" %}
需要同步會員資料（例如會員編號、等級）到聯絡人，請參考 [聯絡人 (Contact) 介紹及串接](/tech/serve/contacts.md) 與 [聯絡人身分同步與 Token 更新](/tech/serve/contacts/contact-credentials-sync.md)。
{% endhint %}

### <mark style="color:blue;">適用場景</mark>

建立在官方帳號的圖文選單連結、線上商店整合、會員系統串接、活動報名系統、客戶服務系統


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.maiagent.ai/tech/serve/whatislineliff/setting.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
