{"workflow":{"id":14299,"name":"Automatic AI reply when mentioned in a Liveblocks comment","views":0,"recentViews":0,"totalViews":0,"createdAt":"2026-03-24T16:49:11.306Z","description":"## Automatic AI reply when mentioned in a Liveblocks comment\n \nThis example uses [Liveblocks Comments](https://liveblocks.io/comments), collaborative commenting components for React. When an AI assistant is mentioned in a thread  (e.g. \"@AI Assistant\"), it will automatically leave a response.\n\nUsing [webhooks](https://liveblocks.io/docs/platform/webhooks), this workflow is triggered when a comment is created in a thread. If the agent's ID (`\"__AI_AGENT\"`) was mentioned, an AI agent is given the entire thread context, and asked to create a response. This response is then added, and users will see it appear in their apps in real time.\n\n### Set up\nThis workflow requires a Comments app installed and webhooks set up in the Liveblocks dashboard. You can try it with a demo application:\n\n1. Download the [Next.js comments example](https://liveblocks.io/examples/comments/nextjs-comments), and run it with a secret key.\n2. Find `database.ts` inside the example and uncomment the AI assistant user.\n3. Insert the secret key from the project into n8n nodes: \"Get a comment\", \"Get a thread\", \"Create a comment\".\n4. Go to the [Liveblocks dashboard](https://liveblocks.io/dashboard), open your project and go to \"Webhooks\". Create a new webhook in your project using a placeholder URL, and selecting \"commentCreated\" events.\n5. Copy your webhook secret from this page and paste it into the \"Liveblocks Trigger\" node.\n6. Expose the webhook URL from the trigger, for example with `localtunnel` or `ngrok`. Copy the production URL from the \"Liveblocks Trigger\" and replace `localhost:5678` with the new URL.\n6. Your workflow is now set up! Tag @AI Assistant in the application to trigger it.\n\n\n#### Localtunnel\nThe easiest way to expose your webhook URL:\n```\nnpx localtunnel --port 5678 --subdomain your-name-here\n```\nThis creates a URL like:\n```\nhttps://honest-months-fix.loca.lt\n```\nThe URL you need for the dashboard looks like this:\n```\nhttps://honest-months-fix.loca.lt/webhook/9cc66974-aaaf-4720-b557-1267105ca78b/webhook\n```","workflow":{"id":"1_j9-Bxn13fiv-hp8cAeG","meta":{"instanceId":"fdd58b028250e4811c462e28c5cbca067bcbfe46a2f4e6fd38647ade19e87602","templateCredsSetupCompleted":true},"name":"Automatic AI reply when mentioned in a Liveblocks comment","tags":[],"nodes":[{"id":"55c5a866-a618-4fdb-9d66-d898217f6003","name":"Liveblocks Trigger","type":"CUSTOM.liveblocksTrigger","position":[-64,0],"webhookId":"9cc66974-aaaf-4720-b557-1267105ca78b","parameters":{"events":["commentCreated"],"additionalFields":{}},"credentials":{"liveblocksWebhookSigningSecretApi":{"id":"49QSVYMe8ZioziMa","name":"Liveblocks Webhook Signing Secret account 3"}},"typeVersion":1},{"id":"1a0c859b-7ea5-4198-a861-83f6df0afbaf","name":"Get a comment","type":"CUSTOM.liveblocks","position":[176,0],"parameters":{"roomId":"={{ $json.event.data.roomId }}","resource":"comment","threadId":"={{ $json.event.data.threadId }}","commentId":"={{ $json.event.data.commentId }}","operation":"getComment"},"credentials":{"liveblocksApi":{"id":"aSBO1Lf4YrGYH0Qq","name":"Liveblocks account"}},"typeVersion":1},{"id":"73646402-4f8b-4817-af91-4b88242c9cef","name":"If","type":"n8n-nodes-base.if","position":[368,0],"parameters":{"options":{},"conditions":{"options":{"version":3,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"3a4b15ca-e141-4096-8081-bbe359f59733","operator":{"type":"array","operation":"contains","rightType":"any"},"leftValue":"={{ $json.mentionedUserIds }}","rightValue":"__AI_AGENT"}]}},"typeVersion":2.3},{"id":"e53009ce-0aa9-4630-a728-49c6f6755c2e","name":"Get a thread","type":"CUSTOM.liveblocks","position":[592,0],"parameters":{"roomId":"={{ $json.roomId }}","resource":"thread","threadId":"={{ $json.threadId }}","operation":"getThread"},"credentials":{"liveblocksApi":{"id":"aSBO1Lf4YrGYH0Qq","name":"Liveblocks account"}},"typeVersion":1},{"id":"50982aa6-8fc1-4f33-bb9a-e1b8860dc462","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[800,0],"parameters":{"text":"=You are an AI assistant that can reply to comments in a thread. You have been mentioned in the latest comment and must reply.\n\nHere is the entire thread:\n\n```\n{{ JSON.stringify($json.comments, null, 2) }}\n```\n\nYou were mentioned in the last comment. Write your reply as a string.","options":{},"promptType":"define"},"typeVersion":3.1},{"id":"9d18bb25-fa44-4238-807e-0b1685883d09","name":"Anthropic Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatAnthropic","position":[800,176],"parameters":{"model":{"__rl":true,"mode":"list","value":"claude-sonnet-4-6","cachedResultName":"Claude Sonnet 4.6"},"options":{}},"credentials":{"anthropicApi":{"id":"TLoCIyCNiIGbje8U","name":"Anthropic account"}},"typeVersion":1.3},{"id":"7d6ea1ce-ecd4-4a1c-8490-a5915c95d4d6","name":"Create a comment","type":"CUSTOM.liveblocks","position":[1136,0],"parameters":{"roomId":"={{ $('Get a comment').item.json.roomId }}","resource":"comment","threadId":"={{ $('Get a comment').item.json.threadId }}","createComment_userId":"__AI_AGENT","createComment_bodyMode":"plainText","createComment_bodyText":"={{ $json.output }}"},"credentials":{"liveblocksApi":{"id":"aSBO1Lf4YrGYH0Qq","name":"Liveblocks account"}},"typeVersion":1},{"id":"d414863b-9cf3-4e28-9888-a4ea6553dd67","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[544,-112],"parameters":{"color":7,"width":512,"height":432,"content":"## Fetch thread and generate\nIf `true`, fetch the entire comment thread, pass it to AI so it understands the full context, and ask it to write up a response."},"typeVersion":1},{"id":"016a250a-59d2-4cf0-9847-803b08bc9af6","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[-704,-112],"parameters":{"width":502,"height":944,"content":"## Automatic AI reply when mentioned in a Liveblocks comment\n \nThis example uses [Liveblocks Comments](https://liveblocks.io/comments), collaborative commenting components for React. When an AI assistant is mentioned in a thread  (e.g. \"@AI Assistant\"), it will automatically leave a response.\n\nUsing [webhooks](https://liveblocks.io/docs/platform/webhooks), this workflow is triggered when a comment is created in a thread. If the agent's ID (`\"__AI_AGENT\"`) was mentioned, an AI agent is given the entire thread context, and asked to create a response. This response is then added, and users will see it appear in their apps in real time.\n\n### Setup\nThis workflow requires a Comments app installed and webhooks set up in the Liveblocks dashboard. You can try it with a demo application:\n\n- [ ] Download the [Next.js comments example](https://liveblocks.io/examples/comments/nextjs-comments), and run it with a secret key.\n- [ ] Find `database.ts` inside the example and uncomment the AI assistant user.\n- [ ] Insert the secret key from the project into n8n nodes: \"Get a comment\", \"Get a thread\", \"Create a comment\".\n- [ ] Go to the [Liveblocks dashboard](https://liveblocks.io/dashboard), open your project and go to \"Webhooks\". Create a new webhook in your project using a placeholder URL, and selecting \"commentCreated\" events.\n- [ ] Copy your webhook secret from this page and paste it into the \"Liveblocks Trigger\" node.\n- [ ] Expose the webhook URL from the trigger, for example with `localtunnel` or `ngrok`. Copy the production URL from the \"Liveblocks Trigger\" and replace `localhost:5678` with the new URL.\n- [ ] Your workflow is now set up! Tag @AI Assistant in the application to trigger it.\n\n#### Localtunnel\nThe easiest way to expose your webhook URL:\n`npx localtunnel --port 5678 --subdomain your-name-here`\n\nThis creates a URL like:\n`https://honest-months-fix.loca.lt`\n\nThe URL you need for the dashboard looks like this:\n`https://honest-months-fix.loca.lt/webhook/9cc66974-aaaf-4720-b557-1267105ca78b/webhook`\n"},"typeVersion":1},{"id":"8bac501d-631f-43dc-aafa-7ebecaed2535","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[-128,-112],"parameters":{"color":7,"width":230,"height":272,"content":"## Comment created\nWhen a comment is created in a room."},"typeVersion":1},{"id":"00f027b5-c4cb-4643-b0b7-ebe4d80a075d","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[128,-112],"parameters":{"color":7,"width":384,"height":272,"content":"## Check if AI mentioned\nCheck if a comment mentions the AI agent. Their ID is `\"__AI_AGENT\"` in this demo."},"typeVersion":1},{"id":"85d1fc00-7999-4328-a19d-810167084e2e","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[1088,-112],"parameters":{"color":7,"width":368,"height":272,"content":"## Add response to thread\nThe response is then added as a comment in the same thread. The user ID is set to `\"__AI_AGENT\"`."},"typeVersion":1}],"active":true,"pinData":{},"settings":{"availableInMCP":false,"executionOrder":"v1"},"versionId":"d37e40e2-49e8-470e-8a13-c687497a2d3a","connections":{"If":{"main":[[{"node":"Get a thread","type":"main","index":0}]]},"AI Agent":{"main":[[{"node":"Create a comment","type":"main","index":0}]]},"Get a thread":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"Get a comment":{"main":[[{"node":"If","type":"main","index":0}]]},"Liveblocks Trigger":{"main":[[{"node":"Get a comment","type":"main","index":0}]]},"Anthropic Chat Model":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]}}},"lastUpdatedBy":51,"workflowInfo":{"nodeCount":12,"nodeTypes":{"CUSTOM.liveblocks":{"count":3},"n8n-nodes-base.if":{"count":1},"CUSTOM.liveblocksTrigger":{"count":1},"n8n-nodes-base.stickyNote":{"count":5},"@n8n/n8n-nodes-langchain.agent":{"count":1},"@n8n/n8n-nodes-langchain.lmChatAnthropic":{"count":1}}},"status":"published","readyToDemo":null,"user":{"name":"Liveblocks","username":"liveblocks","bio":"Liveblocks provides the infrastructure to handle concurrent edits on shared data, so people and AI agents can collaborate without breaking your app.","verified":true,"links":["https://liveblocks.io"],"avatar":"https://gravatar.com/avatar/2a107b003f338bc7a30a56e2be40b53c2f3ea3a8718db975beaa202f9e3cc3db?r=pg&d=retro&size=200"},"nodes":[{"id":20,"icon":"fa:map-signs","name":"n8n-nodes-base.if","codex":{"data":{"alias":["Router","Filter","Condition","Logic","Boolean","Branch"],"details":"The IF node can be used to implement binary conditional logic in your workflow. You can set up one-to-many conditions to evaluate each item of data being inputted into the node. That data will either evaluate to TRUE or FALSE and route out of the node accordingly.\n\nThis node has multiple types of conditions: Bool, String, Number, and Date & Time.","resources":{"generic":[{"url":"https://n8n.io/blog/learn-to-automate-your-factorys-incident-reporting-a-step-by-step-guide/","icon":"🏭","label":"Learn to Automate Your Factory's Incident Reporting: A Step by Step Guide"},{"url":"https://n8n.io/blog/2021-the-year-to-automate-the-new-you-with-n8n/","icon":"☀️","label":"2021: The Year to Automate the New You with n8n"},{"url":"https://n8n.io/blog/why-business-process-automation-with-n8n-can-change-your-daily-life/","icon":"🧬","label":"Why business process automation with n8n can change your daily life"},{"url":"https://n8n.io/blog/create-a-toxic-language-detector-for-telegram/","icon":"🤬","label":"Create a toxic language detector for Telegram in 4 step"},{"url":"https://n8n.io/blog/no-code-ecommerce-workflow-automations/","icon":"store","label":"6 e-commerce workflows to power up your Shopify s"},{"url":"https://n8n.io/blog/how-to-build-a-low-code-self-hosted-url-shortener/","icon":"🔗","label":"How to build a low-code, self-hosted URL shortener in 3 steps"},{"url":"https://n8n.io/blog/automate-your-data-processing-pipeline-in-9-steps-with-n8n/","icon":"⚙️","label":"Automate your data processing pipeline in 9 steps"},{"url":"https://n8n.io/blog/how-to-get-started-with-crm-automation-and-no-code-workflow-ideas/","icon":"👥","label":"How to get started with CRM automation (with 3 no-code workflow ideas"},{"url":"https://n8n.io/blog/5-tasks-you-can-automate-with-notion-api/","icon":"⚡️","label":"5 tasks you can automate with the new Notion API "},{"url":"https://n8n.io/blog/automate-google-apps-for-productivity/","icon":"💡","label":"15 Google apps you can combine and automate to increase productivity"},{"url":"https://n8n.io/blog/automation-for-maintainers-of-open-source-projects/","icon":"🏷️","label":"How to automatically manage contributions to open-source projects"},{"url":"https://n8n.io/blog/how-uproc-scraped-a-multi-page-website-with-a-low-code-workflow/","icon":" 🕸️","label":"How uProc scraped a multi-page website with a low-code workflow"},{"url":"https://n8n.io/blog/5-workflow-automations-for-mattermost-that-we-love-at-n8n/","icon":"🤖","label":"5 workflow automations for Mattermost that we love at n8n"},{"url":"https://n8n.io/blog/why-this-product-manager-loves-workflow-automation-with-n8n/","icon":"🧠","label":"Why this Product Manager loves workflow automation with n8n"},{"url":"https://n8n.io/blog/sending-automated-congratulations-with-google-sheets-twilio-and-n8n/","icon":"🙌","label":"Sending Automated Congratulations with Google Sheets, Twilio, and n8n "},{"url":"https://n8n.io/blog/how-to-set-up-a-ci-cd-pipeline-with-no-code/","icon":"🎡","label":"How to set up a no-code CI/CD pipeline with GitHub and TravisCI"},{"url":"https://n8n.io/blog/benefits-of-automation-and-n8n-an-interview-with-hubspots-hugh-durkin/","icon":"🎖","label":"Benefits of automation and n8n: An interview with HubSpot's Hugh Durkin"},{"url":"https://n8n.io/blog/aws-workflow-automation/","label":"7 no-code workflow automations for Amazon Web Services"}],"primaryDocumentation":[{"url":"https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.if/"}]},"categories":["Core Nodes"],"nodeVersion":"1.0","codexVersion":"1.0","subcategories":{"Core Nodes":["Flow"]}}},"group":"[\"transform\"]","defaults":{"name":"If","color":"#408000"},"iconData":{"icon":"map-signs","type":"icon"},"displayName":"If","typeVersion":2,"nodeCategories":[{"id":9,"name":"Core Nodes"}]},{"id":565,"icon":"fa:sticky-note","name":"n8n-nodes-base.stickyNote","codex":{"data":{"alias":["Comments","Notes","Sticky"],"categories":["Core Nodes"],"nodeVersion":"1.0","codexVersion":"1.0","subcategories":{"Core Nodes":["Helpers"]}}},"group":"[\"input\"]","defaults":{"name":"Sticky Note","color":"#FFD233"},"iconData":{"icon":"sticky-note","type":"icon"},"displayName":"Sticky Note","typeVersion":1,"nodeCategories":[{"id":9,"name":"Core Nodes"}]},{"id":1119,"icon":"fa:robot","name":"@n8n/n8n-nodes-langchain.agent","codex":{"data":{"alias":["LangChain","Chat","Conversational","Plan and Execute","ReAct","Tools"],"resources":{"primaryDocumentation":[{"url":"https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.agent/"}]},"categories":["AI","Langchain"],"subcategories":{"AI":["Agents","Root Nodes"]}}},"group":"[\"transform\"]","defaults":{"name":"AI Agent","color":"#404040"},"iconData":{"icon":"robot","type":"icon"},"displayName":"AI Agent","typeVersion":3,"nodeCategories":[{"id":25,"name":"AI"},{"id":26,"name":"Langchain"}]},{"id":1145,"icon":"file:anthropic.svg","name":"@n8n/n8n-nodes-langchain.lmChatAnthropic","codex":{"data":{"alias":["claude","sonnet","opus"],"resources":{"primaryDocumentation":[{"url":"https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmchatanthropic/"}]},"categories":["AI","Langchain"],"subcategories":{"AI":["Language Models","Root Nodes"],"Language Models":["Chat Models (Recommended)"]}}},"group":"[\"transform\"]","defaults":{"name":"Anthropic Chat Model"},"iconData":{"type":"file","fileBuffer":"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0NiIgaGVpZ2h0PSIzMiIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iIzdEN0Q4NyIgZD0iTTMyLjczIDBoLTYuOTQ1TDM4LjQ1IDMyaDYuOTQ1ek0xMi42NjUgMCAwIDMyaDcuMDgybDIuNTktNi43MmgxMy4yNWwyLjU5IDYuNzJoNy4wODJMMTkuOTI5IDB6bS0uNzAyIDE5LjMzNyA0LjMzNC0xMS4yNDYgNC4zMzQgMTEuMjQ2eiIvPjwvc3ZnPg=="},"displayName":"Anthropic Chat Model","typeVersion":1,"nodeCategories":[{"id":25,"name":"AI"},{"id":26,"name":"Langchain"}]}],"categories":[{"id":40,"name":"Support Chatbot"},{"id":47,"name":"AI Chatbot"}],"image":[]}}