登入開始免費試用
easyCoexistence 官方 API

用 n8n 以 AI 回覆 TikTok 留言

以 n8n 工作流程回覆 TikTok 留言,分為四個步驟:Webhook 節點接收 easyCoexistence 轉發、已簽署的 comment.update 事件;Code 節點保留新的頂層留言;聊天模型撰寫回覆;MCP Client 節點以 reply_to_comment 發出回覆,公開顯示在留言之下,經由 TikTok 的 API for Business。easyCoexistence 的自動化也可以不經工作流程直接回覆。

5 minutes

TikTok 在自有相片貼文或公開影片上建立留言後,觸發 comment.update 的時限。

1,200

TikTok 的 /business/comment/reply/create/ 在單則回覆中接受的 UTF-8 文字字元數。

40 a minute

TikTok 對每個已授權帳戶,在每個 Accounts API 端點(包括回覆端點)允許的呼叫次數。

At least once

TikTok 對 webhook 的遞送保證:失敗會重試最多 72 小時,因此同一則留言可能送達兩次。

10,000

n8n 的 Remove Duplicates 節點預設會記住的數值,用於捨棄先前執行中見過的項目。

150

easyCoexistence 自動化在 TikTok 回覆中允許的字元數,較長的 AI 文字會在字詞處截斷。

TikTok 留言如何送到 n8n?

以簽署的 POST 送至 Webhook 節點。將節點設為 POST,開啟 Raw Body,將 Respond 設為 Immediately,發布工作流程後複製 Production URL。用 set_social_webhook_destination 將 TikTok 帳戶指向該網址,可以向 Claude 或 ChatGPT 提出要求,或在 MCP Client 節點中執行一次,也可以在 Partner API 上呼叫 PUT /api/v1/channels/:id/webhook,並儲存回傳的簽署密鑰。TikTok 會在五分鐘內向 easyCoexistence 回報新留言,easyCoexistence 隨即轉發 comment.update 事件,內容已解析,ID 以字串形式傳送。請先檢查 X-EC-Signature,如 n8n 社群媒體指南所示。

A forwarded TikTok comment
{
  "platform": "tiktok",
  "account_id": "<ACCOUNT_ID>",
  "external_id": "<TIKTOK_OPEN_ID>",
  "entry": {
    "event": "comment.update",
    "create_time": 1793318400,
    "content": {
      "comment_id": "<COMMENT_ID>",
      "video_id": "<VIDEO_ID>",
      "comment_type": "comment",
      "comment_action": "insert",
      "parent_comment_id": null,
      "timestamp": 1793318399000,
      "unique_identifier": "<UNIQUE_IDENTIFIER>",
      "text": "Does this come in a bigger size?"
    }
  }
}

工作流程應回覆哪些留言?

新的頂層留言,且每則只回覆一次。comment.update 也會回報刪除、已隱藏留言及可見性變更,而回覆會以 comment_type reply 送達,當中包括帳戶本身的回覆,因此 Code 節點只保留 comment_action 為 insert 且 comment_type 為 comment 的事件。TikTok 的 webhook 至少送達一次,並最多重試 72 小時,因此同一則留言可能送達兩次。將 Remove Duplicates 節點設為 Remove Items Processed in Previous Executions,並以 comment_id 設定 Value Is New,只讓第一份副本通過。預設會記住 10,000 個值,所以除非在 TikTok 的 72 小時重試期內有超過 10,000 則新留言,否則重複送達都能被攔截。

Code node: one item per new top-level comment
// Run Once for All Items, after the signature check.
// json.data holds the raw body as text, from Extract From File.
const out = [];
for (const item of $input.all()) {
  const { platform, account_id, entry } = JSON.parse(item.json.data);
  const c = entry?.content ?? {};
  if (platform !== "tiktok" || entry.event !== "comment.update") continue;
  // Replies, the account's own among them, arrive as comment_type "reply"
  if (c.comment_action !== "insert" || c.comment_type !== "comment") continue;
  out.push({ json: { account_id, comment_id: c.comment_id, video_id: c.video_id, text: c.text ?? "" } });
}
return out;

AI 如何撰寫回覆?

使用 AI Agent 節點中的聊天模型,若只負責撰寫,則使用 Basic LLM Chain 節點。將人們會詢問的業務資料放入系統訊息,並遵守公開回覆的規則:簡短、以留言者的語言撰寫、不涉及個人資料,且每次措辭不同,因為 TikTok 可能會將短時間內大量相似的回覆視為垃圾訊息並隱藏。以表達式將提示詞設為留言的文字。API 接受最多 1,200 個字元,但數句話在影片下方會較易閱讀;easyCoexistence 自身的自動化則限制為 150 個字元。模型也可以對不需要回覆的留言回傳 SKIP,然後由 If 節點將其丟棄。

工作流程如何發出回覆?

使用 easyCoexistence 伺服器上的 MCP Client 節點,這樣 TikTok 的存取權杖便不會留在 n8n 中。端點填入 https://easycoexistence.com/api/mcp,傳輸方式選 Streamable HTTP,認證選 OAuth2 認證,工具選 reply_to_comment,並在 Manual input 模式下,從 Code 節點與模型對應下列四個參數。回覆會以 TikTok 帳戶的身分,公開顯示在留言之下。若要自行呼叫 TikTok,可用 HTTP Request 節點,依 get_social_credentials 回傳的 api_base 向 business/comment/reply/create/ 發出 POST,權杖置於 Access-Token 標頭,主體包含 business_id、video_id、comment_id 與 text;回應中的代碼為 0 即表示成功。

account_idThe event's account_id, easyCoexistence's ID for the TikTok account
comment_idThe comment to answer, from entry.content
post_idThe video's ID, entry.content.video_id, which TikTok replies need
textThe model's answer

TikTok 對回覆設有哪些限制?

TikTok 的 API for Business 設有以下限制,無論由誰撰寫文字:

  • 僅限公開:TikTok 連接不會發送私訊,因此任何打開留言區的人都能看到回覆。
  • 長度:每則回覆最多 1,200 個 UTF-8 文字字元,或以圖片取代文字。
  • 速率:每個已授權帳戶在每個 Accounts API 端點(包括回覆端點)每分鐘 40 次呼叫。
  • 垃圾訊息:短時間內大量內容相似的回覆可能被標記並隱藏。
  • 範圍:comment.update 涵蓋已連接帳戶上的相片貼文與公開影片,並在五分鐘內送達。

何時 easyCoexistence 自動化無需 n8n 即可回覆?

當一行步驟便已足夠時。TikTok 帳戶上的自動化會由 comment_received 觸發,可針對任何留言或關鍵字,適用於單一影片或所有影片,最多可執行 12 個步驟:reply_comment(固定文字)、ai_reply(使用你自己的 Anthropic、OpenAI 或 OpenRouter 金鑰)、hide_comment、call_webhook、wait 與 stop。回覆保持公開,且不超過 150 個字元;test_automation 可在不發布的情況下試行自動化,而關鍵字留言規則會先於任何自動化回覆。call_webhook 步驟也可以把留言交給 n8n 工作流程,最多等待 20 秒,然後發布其回傳的 reply 欄位。

n8n workfloweasyCoexistence automation
Starts onA forwarded comment.update, signedcomment_received, on any comment or a keyword
Writes the replyYour chat model in an AI nodeai_reply with your Anthropic, OpenAI or OpenRouter key
Reply lengthUp to TikTok's 1,200 charactersUp to 150 characters, longer AI text cut at a word
LogicBranches, lookups and other appsUp to 12 steps in a straight line
Runs onYour n8n instanceeasyCoexistence, with no workflow to host

設定方法

  1. Connect the TikTok accountIn the easyCoexistence dashboard, choose New connection, pick TikTok and authorize the permissions it asks for.
  2. Forward its comments to n8nPublish a workflow that starts with a Webhook node, then point set_social_webhook_destination at its Production URL.
  3. Write and post the replyAdd the Code, Remove Duplicates and chat model nodes, then an MCP Client node that runs reply_to_comment.

常見錯誤

  • 在同一帳戶上同時保留 easyCoexistence 自動化或留言規則與該工作流程。兩者作用於同一則留言,留言者會收到兩次回覆;請只讓其中一方回覆。
  • 在 reply_to_comment 中遺漏 post_id。TikTok 的回覆同時指明影片與留言,因此請將事件的 video_id 對應到 post_id,否則呼叫會被拒絕。
  • 將 comment_id 或 video_id 解析為數字。它們是 64 位元數值,JavaScript 會將其捨入,而 easyCoexistence 以字串形式轉發,因此整個工作流程中都應保持為文字。
  • 回覆了回覆,而不只是留言。帳戶本身的回覆會以 comment_type reply 回傳,因此若工作流程回覆它們,最終會回覆自己。
使用 EasyCoexistence 完成這項設定

easyCoexistence 透過各網絡的官方 API,把 AI 帶進你的 n8n 工作流程,服務 TikTok 留言者,以及 Instagram、Facebook 與更多渠道的客戶:提供簽署的 comment.update 事件、以 TikTok 帳戶身分回覆的 MCP Client 工具,以及無需工作流程即可回覆的自動化,並 24/7 監察每個連接。每個連接每月 US$ 9 至 US$ 0.75,連接越多越便宜,並提供 3 天免費試用。

常見問題

工作流程可否改用私訊而非公開回覆?

不可。透過 easyCoexistence 的 TikTok 連接並無私訊功能,因此每則回覆都是公開的,顯示在留言之下;請勿在回覆中放入訂單編號或任何個人資料。

轉發的事件是否包含留言的文字?

包含。TikTok 的 comment.update 內容包括文字、留言與影片 ID、動作以及留言者的 unique_identifier,easyCoexistence 會以解析後的形式轉發,且 ID 為字串。

同一工作流程能否回覆 Instagram 留言?

可以。用 Switch 節點依平台分支:Instagram 留言會以 field 為 comments 的 changes 形式送達,而 n8n 的 Instagram 教學涵蓋其私人回覆與私訊。

在 n8n 中為一個 TikTok 帳戶使用 easyCoexistence 要多少錢?

每個連接每月 US$ 9 至 US$ 0.75,連接越多越便宜,各網絡價格相同。轉發的事件、MCP 伺服器與自動化均包括在內,並提供 3 天免費試用。

繼續閱讀

兩分鐘內連接您的第一個頻道。

無需等待平台審核。連接 WhatsApp、Instagram、TikTok 或其他頻道,然後請您的 AI 發佈貼文、回覆訊息或匯報數據,並看着它運作。

  • 免費試用 3 天
  • 隨時取消
  • 只用官方 API
  • 24/7 監察

驗證日期