登录开始免费试用
easyCoexistence 官方 API

使用 AI 在 n8n 中回复 TikTok 评论

n8n 工作流分四步用 AI 回复 TikTok 评论:Webhook 节点接收 easyCoexistence 转发的已签名 comment.update 事件;Code 节点保留新的顶层评论;聊天模型撰写回复;MCP Client 节点通过 TikTok API for Business,以 reply_to_comment 在评论下公开发布回复。easyCoexistence 的自动化也可以不借助工作流直接回复。

5 minutes

在您拥有的照片帖子或公开视频上创建评论后,TikTok 触发 comment.update 事件的时限。

1,200

TikTok /business/comment/reply/create/ 单次回复接受的 UTF-8 文本字符数。

40 a minute

每个已授权账户在每个 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(向 Claude 或 ChatGPT 提出请求,或从 MCP Client 节点运行一次),或在 Partner API 上使用 PUT /api/v1/channels/:id/webhook,将 TikTok 账户指向该地址,并保存返回的签名密钥。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 涵盖已连接账户上的照片帖子和公开视频,并在五分钟内送达。

不借助 n8n,easyCoexistence 自动化何时直接回复?

当一条步骤链就足够时。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 事件、以账户身份回复的 MCP Client 工具,以及无需运行工作流即可回复的自动化,并全天候监控每个连接。每个连接每月 US$ 9 起,连接越多越便宜,最低降至 US$ 0.75,前 3 天免费试用。

常见问题

工作流能否通过私信而非公开回复?

不能。easyCoexistence 无法在 TikTok 上发送私信,因此每条回复都是公开的,显示在评论下方;请勿在回复中包含订单号或任何个人信息。

转发的事件是否包含评论文本?

包含。TikTok 的 comment.update 内容包括文本、评论和视频 ID、操作以及评论者的 unique_identifier,easyCoexistence 会将其解析后转发,ID 以字符串形式提供。

同一工作流能否回复 Instagram 评论?

可以。使用 Switch 节点按 platform 分流:Instagram 评论以 field 为 comments 的 changes 形式送达,n8n 的 Instagram 指南涵盖其私信回复。

在 n8n 中为 TikTok 账户使用 easyCoexistence 需要多少费用?

每个连接每月 US$ 9 起,连接越多越便宜,最低降至 US$ 0.75,各网络收费相同。转发的事件、MCP 服务器和自动化均包含在内,并提供前 3 天免费试用。

继续阅读

两分钟连接您的第一个渠道。

无需等待平台审核。连接 WhatsApp、Instagram、TikTok 或其他渠道,然后让您的 AI 发布、回复或生成报告,看它如何运作。

  • 免费试用 3 天
  • 随时取消
  • 仅使用官方 API
  • 全天候 24/7 监控

验证时间