> 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/build/choose-channel/line.md).

# 串接對話平台：LINE

串接 LINE 官方帳號：取得 Channel ID、Channel Secret 與 Channel Access Token、設定 Webhook URL，並可在 LINE 內用 LIFF 開啟 Web Chat。

## <mark style="color:blue;">串接前確認</mark> <a href="#pre-integration-checklist" id="pre-integration-checklist"></a>

* 已在 [MaiAgent 平台](https://admin.maiagent.ai/)上建立好一個「AI 助理」
* 已經在 [LINE Developers](https://developers.line.biz/zh-hant/) 的 console 平台建立好一個 「Provider」 以及一個 LINE 官方帳號 (Official Account)

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-4c57afd0e778526737fc9ac2313136c151427ec5%2F%E6%88%AA%E5%9C%96%202025-04-23%20%E4%B8%8B%E5%8D%884.47.49.png?alt=media" alt=""><figcaption></figcaption></figure>

## <mark style="color:blue;">開始串接</mark> <a href="#start-integration" id="start-integration"></a>

### 1. 到 <https://manager.line.biz/> 選擇您想要串接的官方帳號 <a href="#step-select-line-official-account" id="step-select-line-official-account"></a>

點選 MaiAgent Testing：

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-b259661331628fb8d70751be73bf58b1ff1363e7%2F%E6%88%AA%E5%9C%96%202025-04-23%20%E4%B8%8B%E5%8D%885.01.45.png?alt=media" alt=""><figcaption></figcaption></figure>

點選後會進入官方帳號設定的畫面：

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

### 2. 點選右上角的設定 (Settings) <a href="#step-open-settings" id="step-open-settings"></a>

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

接著進入以下的畫面，點選左側 Messaging API 列表：

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

### 3. 啟用 Messaging API 服務 <a href="#step-enable-messaging-api" id="step-enable-messaging-api"></a>

a. 進入後，點按 <mark style="color:blue;">Enable Messaging API</mark>

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

b. 選擇剛剛建立好的 Provider (若您剛剛尚未建立，仍可在這個頁面建立 Provider)

選擇完成後按下<mark style="color:blue;">確認(Agree)</mark>

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

c. 傳入隱私權政策等文件 (可選)

下一步，您可以傳入您公司內部的隱私政策等文件網址，完成後按下 「ok」 前往下一步最終確認。

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

{% hint style="danger" %}
最後按下 ok 前請再次確認您連接的 Provider 是否正確，按下 ok 後即無法回復
{% endhint %}

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

### 4. 取得 <mark style="color:blue;">Channel ID</mark>、<mark style="color:blue;">Channel Secret</mark>、<mark style="color:blue;">Channel Access Token</mark> <a href="#step-get-channel-credentials" id="step-get-channel-credentials"></a>

a. 按下 OK 後，您就可以取得該 Messaging API 服務的 <mark style="color:blue;">Channel ID</mark> 和 <mark style="color:blue;">Channel secret</mark>：

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

b. 回到 [LINE Developers ](https://developers.line.biz/console/)頁面，取得 Channel Access Token

進入剛剛創建的 MaiAgent Provider 中

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

c. 找到剛剛建立的 MaiAgent Testing Channel，點選進入

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

d. 切換至 Messaging API 頁面，並往下捲動至 Channel access token 區域

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-7c72c96f2bb978a7fdf9137fa491da3f05ac8f66%2F%E8%9E%A2%E5%B9%95%E6%93%B7%E5%8F%96%E7%95%AB%E9%9D%A2%202025-08-21%20113719.png?alt=media" alt=""><figcaption></figcaption></figure>

e. 發行 <mark style="color:blue;">Channel access token</mark> 並複製

{% hint style="danger" %}
官方帳號原本接在其他 LINE 後台時，Console 上通常已有一組 long-lived token。請直接複製沿用，**不要按 Reissue**：重新發行後舊 token 會失效（最多只能多保留 24 小時），原本的後台會無法回覆。見 [從其他後台搬到 MaiAgent](#migrate-from-other-line-service)。
{% endhint %}

若您尚未發行 <mark style="color:blue;">Channel access token</mark>，請點選 <mark style="color:blue;">Issue</mark>：

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

接著就能得到您的 <mark style="color:blue;">Channel access token</mark> 並複製使用：

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

### 5. 到您的 MaiAgent 的對話平台，選擇 LINE <a href="#step-select-line-in-maiagent" id="step-select-line-in-maiagent"></a>

a. 點選右上角<mark style="color:blue;">串接對話平台</mark>

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-45051526831861d07352f6b1084732e923c9fa5b%2Fimage%20(102).png?alt=media&amp;token=79b5d3df-f535-41a3-9d1b-4405925b1bd0" alt=""><figcaption></figcaption></figure>

b. 選擇 LINE 作為串接平台

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-cb4498bb59b5516d1074ed0de41f6a5d03b07d41%2F%E6%88%AA%E5%9C%96%202025-05-07%20%E4%B8%8B%E5%8D%882.43.54.png?alt=media" alt=""><figcaption></figcaption></figure>

### 6. 填入名稱、選擇 Agent，貼上**剛取得的 Channel ID、Channel Secret、**&#x43;hannel Access Token <a href="#step-fill-channel-credentials" id="step-fill-channel-credentials"></a>

建立表單有三個分頁：<mark style="color:blue;">基本設定</mark>、<mark style="color:blue;">功能設定</mark>、<mark style="color:blue;">權限設定</mark>。<mark style="color:blue;">基本設定</mark> 要填：

| 欄位                                                                            | 說明                                                                                                                                                       |
| ----------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <mark style="color:blue;">名稱</mark>                                           | 這個對話平台在後台顯示的名稱                                                                                                                                           |
| <mark style="color:blue;">AI 助理</mark>                                        | 選擇要串接的 Agent（標示「預設」的為組織預設 Agent）；可以留空，留空時 AI 不回覆，見 [只用真人客服、不開 AI](/build/choose-channel/web-chat/website.md#human-only-mode)                             |
| <mark style="color:blue;">LINE 頻道</mark>                                      | 貼上剛取得的 <mark style="color:blue;">Channel ID</mark>、<mark style="color:blue;">Channel Secret</mark>、<mark style="color:blue;">Channel Access Token</mark> |
| <mark style="color:blue;">聊天室設定</mark> › 群組中僅在被 @ 提及時回應                       | 開啟後，Agent 在 LINE 群組裡只回應被 @ 提及的訊息；關閉則回應群組內所有訊息，見[在 LINE 群組中使用](#line-group)                                                                               |
| <mark style="color:blue;">AI 助理思考中動畫</mark>                                   | 預設開啟。使用者在一對一聊天室送出訊息後，LINE 立即顯示載入動畫，直到 Agent 的回覆送出為止（最長 60 秒）；畫面註明此功能僅在單人聊天室中生效，群組不會顯示，見[AI 助理思考中動畫](#line-loading-animation)                             |
| <mark style="color:blue;">啟用重置命令</mark>、<mark style="color:blue;">重置命令</mark> | 開啟後可新增一到多個指令文字（例如「重新開始」）；使用者在 LINE 傳送這些文字時，會為他另開一段新對話                                                                                                    |

<mark style="color:blue;">功能設定</mark> 分頁有 <mark style="color:blue;">AI 互動功能</mark>（啟用 OCR）與 <mark style="color:blue;">AI 感知設定</mark>（使用系統時間回答＋時區、使用傳送者名稱回答），意義見[功能設定](/build/conversation-settings/platform-settings/function-settings.md#messaging-platform-switches)；<mark style="color:blue;">權限設定</mark> 分頁選擇哪些角色看得到這個平台，見[對話平台設定總覽](/build/conversation-settings/platform-settings.md#tab-map)。這些建立後都還能在平台設定頁修改。

填好憑證後可先按 <mark style="color:blue;">串接測試</mark> 確認 LINE 端接受這組憑證（成功顯示「串接成功」），再按右下角的 「<mark style="color:blue;">串接對話平台</mark>」 按鈕，對話平台即準備就緒。

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-44bf92a7f547e51f5f75fe14faf29cca9eabbbae%2Fline-create-form-loading-animation.png?alt=media" alt="LINE 建立表單的基本設定分頁：名稱、AI 助理、Webhook 提醒、LINE 頻道三個憑證欄位，聊天室設定的群組 @ 提及開關為關閉、AI 助理思考中動畫為開啟、啟用重置命令為關閉"><figcaption><p>建立 LINE 對話平台時，AI 助理思考中動畫預設為開啟</p></figcaption></figure>

#### AI 助理思考中動畫 <a href="#line-loading-animation" id="line-loading-animation"></a>

這是 LINE 官方提供的載入動畫：使用者在一對一聊天室傳訊息給官方帳號後，對話畫面會先出現載入中的動畫，讓使用者知道 Agent 正在處理，不會在等待回覆時以為沒有反應。動畫在 Agent 的回覆送出時消失，最長顯示 60 秒。

* **預設開啟**：新建立的 LINE 對話平台預設開啟；既有的 LINE 對話平台也已一併改為開啟。
* **只在 Agent 自動回覆時顯示**：對話已由真人客服接手、自動回覆被關閉，或目前不在自動回覆時段內時，不會顯示動畫。
* **群組不會顯示**：LINE 只支援在一對一聊天室顯示這個動畫，群組與多人聊天室不受影響。

不想顯示動畫時，到 <mark style="color:blue;">對話平台</mark> 點開該 LINE 平台，在 <mark style="color:blue;">基本設定</mark> 分頁關閉 <mark style="color:blue;">AI 助理思考中動畫</mark>，再按 <mark style="color:blue;">儲存</mark>。

### 7. 取得 Webhook 網址 <a href="#step-get-webhook-url" id="step-get-webhook-url"></a>

建立對話平台時，系統會自動把 LINE 官方帳號的 Webhook URL 設成 MaiAgent 的網址並驗證；建立成功畫面顯示「已自動設定並驗證 Webhook URL」時，可略過步驟 8，直接到步驟 9 檢查回應設定。畫面顯示「已自動設定 Webhook URL，但 LINE 的 Use webhook 尚未開啟」時，網址已設好，到步驟 9 開啟 <mark style="color:blue;">Webhook</mark> 即可。畫面顯示「Webhook URL 自動設定未完成」時，再依下列方式手動設定。

至對話平台選取剛建立的 LINE 頻道，點選操作，於 API 區塊取得 Webhook 網址

### 8. 在 <https://manager.line.biz/> 點選 「Settings/Messaging API」，貼上剛取得的Webhook 網址 <a href="#step-set-webhook-url-in-line" id="step-set-webhook-url-in-line"></a>

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-eecf83c718171a6d06cac20257140ab7f41668e1%2F%E8%9E%A2%E5%B9%95%E6%93%B7%E5%8F%96%E7%95%AB%E9%9D%A2%202025-08-21%20122044.png?alt=media" alt=""><figcaption></figcaption></figure>

### 9. 調整回應設定：開啟 Webhook、關閉自動回應訊息 <a href="#step-configure-messaging-api-channel" id="step-configure-messaging-api-channel"></a>

LINE 官方帳號預設會開啟自動回應訊息。沒有關掉的話，使用者傳訊息時 LINE 會先回一段預設文字（例如「很抱歉，本帳號無法個別回覆用戶的訊息」），見[收到 LINE 的自動回應訊息](#line-auto-response)。

到 [LINE Official Account Manager](https://manager.line.biz/) 點右上角 <mark style="color:blue;">設定</mark>，再點左側 <mark style="color:blue;">回應設定</mark>。也可以從 [LINE Developers](https://developers.line.biz/console/) 該頻道的 <mark style="color:blue;">Messaging API</mark> 分頁，在 Auto-reply messages 點 <mark style="color:blue;">Edit</mark> 進入同一頁。

依下表設定：

| 項目                                                                                  | 設定                                                                                                                      | 說明                                         |
| ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
| <mark style="color:blue;">Webhook</mark>                                            | 開啟                                                                                                                      | 關閉時 LINE 不會把訊息轉給 MaiAgent                  |
| <mark style="color:blue;">自動回應訊息</mark>（<mark style="color:blue;">聊天</mark> 關閉時的開關） | 關閉                                                                                                                      | 開啟時 LINE 會自己回覆預設文字                         |
| <mark style="color:blue;">回應方式</mark>（<mark style="color:blue;">聊天</mark> 開啟時的選項）   | <mark style="color:blue;">回應時間</mark> 與 <mark style="color:blue;">非回應時間</mark> 都選 <mark style="color:blue;">手動聊天</mark> | 選了含「自動回應訊息」的選項，該時段 LINE 會自己回覆              |
| <mark style="color:blue;">加入好友的歡迎訊息</mark>                                          | 依需要                                                                                                                     | 使用者加入好友時由 LINE 送出，內容在 LINE 後台編輯，與 Agent 無關 |

<mark style="color:blue;">聊天</mark> 開或關都可以搭配 MaiAgent。開啟時，客服人員能在 LINE 後台看到對話並手動回覆，Agent 仍會照常回覆同一則訊息。

{% hint style="warning" %} <mark style="color:blue;">回應時間</mark> 開關打開時，回應方式會分成「回應時間」與「非回應時間」兩組。兩組都要選 <mark style="color:blue;">手動聊天</mark>；只改回應時間的話，晚上和假日仍會出現自動回應訊息。
{% endhint %}

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-b0620ef7416611f019d89ca5676f4f2e981c63a8%2F%E6%88%AA%E5%9C%96%202025-04-23%20%E4%B8%8B%E5%8D%885.51.33.png?alt=media" alt="LINE Official Account Manager 的回應設定頁：聊天、加入好友的歡迎訊息與 Webhook 開啟，回應時間的回應方式選手動聊天"><figcaption><p>聊天開啟時的設定：Webhook 開啟、回應方式選手動聊天；往下捲動確認非回應時間也是手動聊天</p></figcaption></figure>

### **10. 確認串接是否成功** <a href="#step-verify-integration" id="step-verify-integration"></a>

您可以試著加入您自己的 LINE 官方帳號，與 Agent 進行對話

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-d3f81c1c9b7e84203137e9f54aef019209f73860%2F%E6%88%AA%E5%9C%96%202025-04-23%20%E4%B8%8B%E5%8D%886.34.27.png?alt=media" alt=""><figcaption></figcaption></figure>

如果相關對話可在 <https://manager.line.biz/> 和 MaiAgent 的所有對話中查看，就表示已成功串接！

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-4d59bf9fc4fe7c1f8ac476d18bab8b515766f9dc%2F%E6%88%AA%E5%9C%96%202025-04-23%20%E4%B8%8B%E5%8D%886.43.12.png?alt=media" alt=""><figcaption></figcaption></figure>

## 在 LINE 裡開啟 Web Chat（LINE LIFF） <a href="#line-liff" id="line-liff"></a>

若希望使用者在 LINE 內直接開啟網頁版對話視窗（例如從圖文選單點開、帶入 LINE 身分），可以用 LINE LIFF 嵌入 Web Chat。這需要在 LINE Developers 建立 LIFF App 並設定網址，步驟請參考技術手冊的 [LINE LIFF：什麼是 LINE LIFF](https://docs.maiagent.ai/tech/serve/whatislineliff)。

## 本月訊息額度 <a href="#line-monthly-quota" id="line-monthly-quota"></a>

LINE 官方帳號每月可推送的訊息數有上限（依您在 LINE 購買的方案而定）。進入 LINE 對話平台的 <mark style="color:blue;">基本設定</mark> 分頁，最上方的 <mark style="color:blue;">本月訊息額度</mark> 卡會即時向 LINE 查詢並顯示 <mark style="color:blue;">本月額度</mark>、<mark style="color:blue;">本月已用量</mark> 與 <mark style="color:blue;">剩餘</mark>（無上限方案顯示「無上限」）。額度用完時卡片會變成紅色警示「LINE 本月訊息額度已用完」：**這段期間 AI 與真人客服的回覆都無法送達 LINE 使用者**，對話頁的對應訊息會標示 [未送達](/serve/daily-operations/reply.md#delivery-failed)。請到 LINE Official Account Manager 升級方案，或等待下月重置。

例如電商在月底促銷期間，客服主管發現有客戶抱怨在 LINE 問訂單卻沒收到回覆。到 <mark style="color:blue;">所有對話</mark> 一看，Agent 的回覆下方顯示「未送達：LINE 本月訊息額度已用完」；再到 LINE 對話平台的 <mark style="color:blue;">基本設定</mark> 確認本月訊息額度已用完，於是到 LINE Official Account Manager 升級方案，之後的回覆就能正常送出。

## 訊息格式與連續訊息 <a href="#message-format-and-merging" id="message-format-and-merging"></a>

* **Markdown 自動轉純文字**：LINE 不會渲染 Markdown，Agent 回覆中的標題、粗斜體、連結、表格、程式碼等語法在送到 LINE 前會自動轉成乾淨的純文字（連結變成「文字 網址」、表格每列變成一行條列），不需要在角色指令裡要求 Agent 不用 Markdown；真人客服打的字、Flex 卡片與快速回覆按鈕不受影響。細節見 [訊息內容渲染優化：通訊軟體通道](/build/choose-channel/web-chat/markdown-rendering.md#messaging-channels-plain-text)
* **連續訊息合併成一輪**：使用者在一對一聊天連續傳多張圖片、或先傳圖再打字時，Agent 會等這一串訊息到齊後一次回答（只含圖片或檔案的訊息，最後一則後約 4 秒沒有新訊息才回答，最長約 20 秒，收到文字就立刻回；一次選多張圖時等整組到齊），不再每張圖各回一次；同一對話一次只處理一輪，上一輪沒結束前的新訊息會排在後面。語音、貼圖、影片、位置視同文字立刻回覆，群組對話維持原本行為

## 在 LINE 群組中使用 <a href="#line-group" id="line-group"></a>

把官方帳號加入 LINE 群組後，Agent 預設會回覆群組中的每一則訊息。要讓 Agent 只在被叫到時才回覆，請到 <mark style="color:blue;">所有對話</mark> 開啟這個群組對話，打開輸入框上方的「群組中僅在被 @ 提及時回應」開關，見 [所有對話](/serve/daily-operations/reply.md)。

開啟後，群組成員有兩種方式呼叫 Agent：

| 方式   | 怎麼做                               | 說明                                  |
| ---- | --------------------------------- | ----------------------------------- |
| @ 提及 | 訊息中包含「@官方帳號的顯示名稱」                 | 名稱需與 LINE 官方帳號的顯示名稱完全相同             |
| 引用回覆 | 對 Agent 先前送出的訊息按 LINE 的「回覆」，再輸入文字 | 不必另外 @。電腦版 LINE 無法 @ 官方帳號時，用這個方式最方便 |

引用回覆的規則：

* 只有引用 **Agent 送出的訊息**才算呼叫；引用其他成員的訊息不會觸發。
* 只有**文字訊息**算呼叫。對 Agent 的訊息回一張貼圖不會觸發回覆，也不會扣 Credits。
* Agent 在群組中的回覆會以引用的方式接在提問的那則訊息下方，方便分辨是在回答誰。回覆較慢、超過 LINE 允許的即時回覆時間時，會改為一般訊息送出，不帶引用。
* 一對一聊天不受這些規則影響，Agent 會回覆每一則訊息，回覆也不帶引用。

## Agent 沒有回覆時依序檢查 <a href="#no-reply-checklist" id="no-reply-checklist"></a>

使用者在 LINE 傳了訊息、Agent 卻沒有回覆時，先到 MaiAgent 的 <mark style="color:blue;">所有對話</mark> 看這則訊息有沒有進來，再依結果往下查。

**訊息沒有出現在「所有對話」**（MaiAgent 沒收到）：

1. LINE Official Account Manager 的 <mark style="color:blue;">Messaging API</mark> 設定中，Webhook 網址是否為 MaiAgent 提供的網址，且沒有被其他服務改掉，見 [步驟 8](#step-set-webhook-url-in-line)。一個官方帳號只能設定一個 Webhook 網址。
2. LINE 回應設定的 <mark style="color:blue;">Webhook</mark> 是否開啟，見 [步驟 9](#step-configure-messaging-api-channel)。
3. MaiAgent 對話平台填寫的 <mark style="color:blue;">Channel ID</mark>、<mark style="color:blue;">Channel Secret</mark>、<mark style="color:blue;">Channel Access Token</mark> 是否與 LINE Developers 上的一致。在 LINE 端重新核發過 Token 或 Secret 後，要回 MaiAgent 更新。

**訊息有進來，但 Agent 沒有回覆**：

1. 這則對話的 <mark style="color:blue;">自動回覆</mark> 是否被關閉，或對話已由真人客服接手。接手期間 Agent 不會回覆，處理完要轉回 AI，見 [所有對話](/serve/daily-operations/reply.md#handoff-actions)。
2. 目前時間是否在對話平台設定的自動回覆時段內，見 [網站：自動回覆設定](/build/choose-channel/web-chat/website.md#auto-reply-settings)。
3. 群組對話是否開啟了「群組中僅在被 @ 提及時回應」。開啟時要 @ 官方帳號或引用 Agent 的訊息才會回覆，見 [在 LINE 群組中使用](#line-group)。
4. 對話平台的 <mark style="color:blue;">是否啟用</mark> 是否被關閉，見 [功能設定](/build/conversation-settings/platform-settings/function-settings.md#basic-functions)。
5. 組織 Credits 或這個對話平台的額度是否用完。對話平台額度用完時 Agent 暫停回覆，使用者只會收到額度提示訊息，見 [對話平台 Credits 額度管理](/others/credits/inbox-credit-quota.md#quota-exceeded-behavior)。
6. 有設定 [Hook 訊息攔截](/build/hook.md) 時，到 [Hook 執行紀錄](/build/hook/execution-logs.md) 確認訊息是否被攔下。

以上都正常仍不回覆時，請記下對話時間與對話網址，洽 MaiAgent 窗口協助查詢。

## 收到 LINE 的自動回應訊息 <a href="#line-auto-response" id="line-auto-response"></a>

使用者傳訊息後收到下面這段文字，代表 LINE 官方帳號的自動回應訊息還開著。這段文字是 LINE 送出的，不是 Agent：

> 感謝您的訊息！\
> 很抱歉，本帳號無法個別回覆用戶的訊息。\
> 敬請期待我們下次發送的內容喔

處理方式：

1. 依 [步驟 9](#step-configure-messaging-api-channel) 關閉 <mark style="color:blue;">自動回應訊息</mark>。<mark style="color:blue;">聊天</mark> 開啟時，把 <mark style="color:blue;">回應時間</mark> 與 <mark style="color:blue;">非回應時間</mark> 的回應方式都改成 <mark style="color:blue;">手動聊天</mark>。
2. 確認 <mark style="color:blue;">Webhook</mark> 仍是開啟。
3. 再傳一則訊息測試。設定正確時，只會收到 Agent 的回覆。

Webhook 開著時 MaiAgent 仍會收到訊息並回覆，所以設定修正前，使用者可能同時看到這段文字和 Agent 的回覆。

## 使用者分享位置 <a href="#location-messages" id="location-messages"></a>

使用者在 LINE 用「位置資訊」分享地點時，MaiAgent 會把它當成一則訊息收進對話：訊息內容是地點名稱與地址（LINE 沒有提供時顯示「📍 已分享位置」），經緯度另外記在這則訊息的 metadata（`latitude`、`longitude`）。

要讓 Agent 依使用者的位置回答（例如推薦最近的門市），請在這個 LINE 對話平台的 [功能設定 → 使用位置資訊回答](/build/conversation-settings/platform-settings/function-settings.md#gps-location) 打開開關。開啟後，Agent 的回覆會附上「📍 分享位置」快速回覆按鈕，使用者點一下就能把目前位置傳給 Agent。

## ⚠️ 重要注意事項 <a href="#important-notes" id="important-notes"></a>

**限制說明**

* LINE 群組僅能加入一個 Agent
* 新加入的 Agent 會導致之前的被自動移除

### 與其他 LINE 後台服務共用官方帳號 <a href="#share-line-official-account-with-other-services" id="share-line-official-account-with-other-services"></a>

LINE 官方帳號一次只能設定一個 Webhook 網址。若將 Webhook 直接設定為 MaiAgent，LINE 的事件會直接傳給 MaiAgent，不會同時傳到原有的第三方後台。因此，第三方後台原本依賴 Webhook 的功能（例如加入／封鎖事件、關鍵字過濾與貼標、送達事件或對話紀錄）可能無法取得資料；實際影響仍取決於該服務的實作。

MaiAgent 收到並處理的對話會保留在 MaiAgent 的「所有對話」中。若原有第三方後台也必須保留上述功能，建議在正式切換前先確認整合架構。常見作法是由第三方服務作為 LINE Webhook 入口，先完成事件與關鍵字處理，再將需要 AI 回覆的訊息轉送給 MaiAgent。此作法需要客製串接，並須保留 LINE 原始請求內容與 `X-Line-Signature` 標頭；同一個 reply token 也只能使用一次，請避免兩套服務重複回覆同一事件。

#### 從其他後台搬到 MaiAgent <a href="#migrate-from-other-line-service" id="migrate-from-other-line-service"></a>

在 MaiAgent 按下 <mark style="color:blue;">串接對話平台</mark> 建立 LINE 對話平台的當下，系統就會自動把這個官方帳號的 Webhook URL 改成 MaiAgent 的網址，訊息隨即改送 MaiAgent、不再送到原本的後台（LINE 端最多約一分鐘生效；自動設定未完成時以手動設定為準，建立表單上也有這段提醒）。所以**建立對話平台就是切換的那一刻**，請在預計切換的時間再建立，並依下列順序操作：

1. **先記下原本的 Webhook 網址**：到 [LINE Developers](https://developers.line.biz/console/) 該頻道的 <mark style="color:blue;">Messaging API</mark> 分頁，把 <mark style="color:blue;">Webhook settings</mark> 的 <mark style="color:blue;">Webhook URL</mark> 複製保存。沒有記下來，之後就無法改回原後台。
2. **沿用現有的 long-lived token，不要按 Reissue**：同一頁 <mark style="color:blue;">Channel access token</mark> 區塊已有的 token 直接複製使用。按 Reissue 後舊 token 會失效（最多只能多保留 24 小時），原後台會無法回覆。
3. **在預計切換的時間建立 LINE 對話平台**：依 [步驟 5–6](#step-select-line-in-maiagent) 填入 Channel ID、Channel Secret 與剛複製的 token。暫時只要真人客服回覆的話，<mark style="color:blue;">AI 助理</mark> 先不要選，建立後立刻到 <mark style="color:blue;">自動回覆設定</mark> 把七天都關閉，見 [只用真人客服、不開 AI](/build/choose-channel/web-chat/website.md#human-only-mode)；這樣從切換那一刻起 AI 就不會回覆。
4. **確認 Webhook 已自動設定**：建立成功的畫面顯示「已自動設定並驗證 Webhook URL」就完成了。若顯示「Use webhook 尚未開啟」或「Webhook URL 自動設定未完成」，依畫面說明開啟 Webhook（見 [步驟 9](#step-configure-messaging-api-channel)），或手動貼上 MaiAgent 的網址並按 <mark style="color:blue;">Verify</mark>（見 [步驟 7–8](#step-get-webhook-url)）。
5. **確認自動回應訊息已關閉並測試**：依 [步驟 9](#step-configure-messaging-api-channel) 檢查，約一分鐘後用個人 LINE 傳一則訊息，確認出現在 MaiAgent 的 <mark style="color:blue;">所有對話</mark>。LINE 換網址後最多約一分鐘內仍可能送到舊網址。

要退回原後台時，到 Console 把 Webhook URL 改回第 1 步記下的網址並按 <mark style="color:blue;">Verify</mark>；MaiAgent 的對話平台可以先保留，但之後若在 MaiAgent 重新建立同一個官方帳號的對話平台，Webhook 會再次被自動切過來。

例如一家連鎖店的官方帳號原本接在其他客服後台，管理員白天先在 Console 把原 Webhook 網址存進交接文件，並確認 Channel access token 已經有值。晚上客服下班後才在 MaiAgent 建立對話平台：貼上原有的 token（沒有按 Reissue）、AI 助理留空，建立後馬上把自動回覆時段七天全關，畫面顯示「已自動設定並驗證 Webhook URL」，一分鐘後用個人 LINE 測試就進到 MaiAgent。隔天發現原後台的會員綁定功能仍需要，便把 Webhook 改回原網址，幾分鐘內就恢復原狀。

連同 Messenger、Instagram 一起搬的完整準備清單與順序，見 [從其他客服系統搬到 MaiAgent](/build/choose-channel/migrate-from-other-platform.md)。

MaiAgent 的 LINE 回覆不限於純文字。除了文字與圖片，也支援由 Agent UI 設定的 [FlexMessage 卡片與互動按鈕](/build/tools/agent-ui.md)，可用圖文選項引導使用者。實際呈現內容取決於 Agent 及 Agent UI 的設定。


---

# 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/build/choose-channel/line.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.
