Log inStart Free Trial
easyCoexistence Official APIs

Reply to TikTok comments with AI in n8n

An n8n workflow replies to TikTok comments with AI in four steps: a Webhook node receives each comment.update event that easyCoexistence forwards, signed; a Code node keeps new top-level comments; a chat model writes the reply; and an MCP Client node posts it with reply_to_comment, in public under the comment, through TikTok's API for Business. easyCoexistence automations can also reply without a workflow.

5 minutes

Time within which TikTok fires comment.update after a comment is created on an owned photo post or public video.

1,200

Characters of UTF-8 text TikTok's /business/comment/reply/create/ accepts in one reply.

40 a minute

Calls TikTok allows per authorized account on each Accounts API endpoint, the reply endpoint included.

At least once

TikTok's delivery promise for webhooks, retried for up to 72 hours, so the same comment can arrive twice.

10,000

Values n8n's Remove Duplicates node remembers by default to drop items seen in earlier executions.

150

Characters easyCoexistence's automations allow in a TikTok reply, cutting longer AI text at a word.

How does a TikTok comment reach n8n?

As a signed POST to a Webhook node. Set it to POST, turn on Raw Body, leave Respond on Immediately, publish the workflow and copy the Production URL. Point the TikTok account at it with set_social_webhook_destination, asked of Claude or ChatGPT or run once from an MCP Client node, or with PUT /api/v1/channels/:id/webhook on the Partner API, and store the signing secret that comes back. TikTok reports a new comment to easyCoexistence within five minutes, and easyCoexistence passes the comment.update event on at once, with content already parsed and its IDs as strings. Check X-EC-Signature first, as the n8n social media guide shows.

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?"
    }
  }
}

Which comments should the workflow reply to?

New top-level comments, and each of them once. comment.update also reports deletions, hidden comments and visibility changes, and replies arrive as comment_type reply, the account's own replies among them, so a Code node keeps only comment_action insert with comment_type comment. TikTok delivers its webhooks at least once and retries for up to 72 hours, so the same comment can come through twice; a Remove Duplicates node set to Remove Items Processed in Previous Executions, with Value Is New on comment_id, lets only the first copy through. By default it remembers 10,000 values, so a redelivery is caught unless more than 10,000 new comments arrive within TikTok's 72 hours of retries.

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;

How does the AI write the reply?

With a chat model in an AI Agent node, or in a Basic LLM Chain node when it only writes. Put the business facts people ask about in the system message, with the rules of a public reply: short, in the commenter's language, nothing personal, and different wording each time, because TikTok can hide many largely similar replies posted in a short time as spam. Set the prompt by expression to the comment's text. The API accepts up to 1,200 characters, but a few sentences read better under a video; easyCoexistence's own automations stop at 150. The model can also return SKIP for comments that need no reply, which an If node then drops.

How does the workflow post the reply?

With an MCP Client node on the easyCoexistence server, which keeps TikTok's token out of n8n. Give it https://easycoexistence.com/api/mcp as the endpoint, the Streamable HTTP transport and OAuth2 authentication, choose reply_to_comment as the tool, and in Manual input mode map the four parameters below from the Code node and the model. The reply goes out in public under the comment, as the TikTok account. To call TikTok yourself, an HTTP Request node posts to business/comment/reply/create/ under the api_base that get_social_credentials returns, with the token in an Access-Token header and business_id, video_id, comment_id and text in the body; a code of 0 in the answer means it worked.

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

What limits does TikTok set on replies?

TikTok's API for Business sets these, whoever writes the text:

  • Public only: a TikTok connection sends no DMs, so the answer is visible to anyone who opens the comments.
  • Length: up to 1,200 characters of UTF-8 text per reply, or an image instead of text.
  • Rate: 40 calls a minute per authorized account on each Accounts API endpoint, the reply endpoint included.
  • Spam: many replies with largely similar content in a short time can be flagged and hidden.
  • Scope: comment.update covers photo posts and public videos on the connected account, and arrives within five minutes.

When do easyCoexistence automations reply without n8n?

When one line of steps is enough. An automation on the TikTok account starts on comment_received, for any comment or a keyword, on one video or all of them, and runs up to 12 steps: reply_comment with fixed text, ai_reply with your own Anthropic, OpenAI or OpenRouter key, hide_comment, call_webhook, wait and stop. Replies stay public and within 150 characters, test_automation tries the automation without posting, and a keyword comment rule replies before any automation does. A call_webhook step can also hand the comment to an n8n workflow, wait up to 20 seconds and post the reply field it returns.

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

How to set it up

  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.

Common mistakes

  • Keeping an easyCoexistence automation or comment rule on the same account as the workflow. Both act on the same comment, so the commenter gets two replies; let one of them answer.
  • Leaving post_id out of reply_to_comment. A TikTok reply names the video as well as the comment, so map the event's video_id into post_id or the call is refused.
  • Parsing comment_id or video_id as numbers. They are 64-bit values that JavaScript rounds, and easyCoexistence forwards them as strings, so keep them as text through the workflow.
  • Replying to replies as well as comments. The account's own replies come back as comment_type reply, so a workflow that replies to them ends up replying to itself.
Doing this with EasyCoexistence

easyCoexistence puts the AI in your n8n workflows in front of TikTok commenters, and of customers on Instagram, Facebook and more channels, through each network's official API: signed comment.update events, MCP Client tools that reply as the account, and automations that reply with no workflow to run, with every connection monitored 24/7. US$ 9 to US$ 0.75 per connection per month, falling as you add connections, with the first 3 days free.

easyCoexistence is a multichannel API and MCP server that connects AI agents such as Claude and ChatGPT to WhatsApp, Instagram, TikTok, Facebook and more. On WhatsApp it uses Coexistence: the business keeps using its number in the WhatsApp Business app while the AI works through Meta's official API.

Frequently asked questions

Can the workflow reply by DM instead of in public?

No. There are no DMs on TikTok through easyCoexistence, so each reply is public, under the comment; keep order numbers and anything personal out of it.

Does the forwarded event carry the comment's text?

Yes. TikTok's comment.update content includes the text, the comment and video IDs, the action and the commenter's unique_identifier, and easyCoexistence forwards it parsed, with the IDs as strings.

Can the same workflow reply to Instagram comments?

Yes. Branch on platform with a Switch node: Instagram comments arrive as changes with field comments, and the Instagram recipe for n8n covers their private replies and DMs.

How much does easyCoexistence cost for a TikTok account in n8n?

US$ 9 to US$ 0.75 per connection per month, falling as you add connections, the same on each network. The forwarded events, the MCP server and the automations are included, with the first 3 days free.

Keep reading

Connect your first channel in two minutes.

No platform reviews to wait for. Connect WhatsApp, Instagram, TikTok or another channel, then ask your AI to post, reply or report, and watch it work.

  • 3 days free
  • Cancel any time
  • Official APIs only
  • Monitored 24/7

Verified on