Workflow: comentarios automaticos
Integrations: filter, httpRequest, respondToWebhook, set, stickyNote, webhook

{"id": "4rXRDurF4mQKrHyB", "meta": {"instanceId": "6d46e25379ef430a7067964d1096b885c773564549240cb3ad4c087f6cf94bd3", "templateCredsSetupCompleted": true}, "name": "comentarios automaticos", "tags": [], "nodes": [{"id": "5c5322a4-10cf-43a1-8286-101c96d8c356", "name": "Webhook", "type": "n8n-nodes-base.webhook", "position": [40, 100], "webhookId": "ea7d37ac-9e82-40d7-bbb3-e9b7ce180fc9", "parameters": {"path": "ea7d37ac-9e82-40d7-bbb3-e9b7ce180fc9", "options": {}, "responseMode": "responseNode"}, "typeVersion": 2}, {"id": "c281b25f-4f5a-46a3-b2ca-c9fba1cf98e1", "name": "Sticky Note", "type": "n8n-nodes-base.stickyNote", "position": [-980, 0], "parameters": {"width": 1440, "height": 320, "content": "# Webhook Verification\nDescription:\nHandles the initial verification handshake with Instagram's Webhook API.\nInstructions:\n\nEnsure the hub.verify_token matches the token configured in your Instagram App settings.\n\nThe response should echo the hub.challenge parameter to confirm the webhook setup.\u200b\n\n"}, "typeVersion": 1}, {"id": "f890a4d2-f897-4103-a52f-48fa3555f9a6", "name": "Respond to Webhook", "type": "n8n-nodes-base.respondToWebhook", "position": [260, 100], "parameters": {"options": {}, "respondWith": "text", "responseBody": "={{ $json.query['hub.challenge'] }}"}, "typeVersion": 1.1}, {"id": "4afb4f9b-7f0f-41b8-afd0-d5c134a6a622", "name": "AI Agent", "type": "@n8n/n8n-nodes-langchain.agent", "position": [140, 1200], "parameters": {"text": "=### CONTEXTO E PERSONA ###\nVoc\u00ea \u00e9 um assistente de IA especialista, respons\u00e1vel por gerenciar os coment\u00e1rios de um perfil no Instagram focado em Intelig\u00eancia Artificial e Automa\u00e7\u00f5es. O objetivo do perfil \u00e9 educar e engajar a comunidade sobre esses temas. Seu tom deve ser amig\u00e1vel, acess\u00edvel, mas tamb\u00e9m demonstrar conhecimento e profissionalismo. Responda sempre em portugu\u00eas brasileiro.\n\n### DADOS DE ENTRADA ###\n- Nome de Usu\u00e1rio: {{ $('data').item.json.usuario.name }}\n- Texto do Coment\u00e1rio:{{ $('data').item.json.usuario.message.text }}\n- Contexto da Publicacao\n\n### TAREFA ###\nAnalise o coment\u00e1rio fornecido e gere uma resposta apropriada, seguindo estas diretrizes:\n\n1.  **An\u00e1lise e Filtragem:**\n    * **Identifique a Inten\u00e7\u00e3o:** \u00c9 uma pergunta t\u00e9cnica? Uma d\u00favida simples? Um elogio? Uma cr\u00edtica construtiva? Um pedido de ajuda? Spam? Conte\u00fado irrelevante?\n    * **Relev\u00e2ncia:** O coment\u00e1rio est\u00e1 relacionado a IA, automa\u00e7\u00e3o ou ao conte\u00fado do perfil?\n\n2.  **Gera\u00e7\u00e3o da Resposta:**\n    * **Personaliza\u00e7\u00e3o:** Comece a resposta mencionando o nome de usu\u00e1rio (ex: \"Ol\u00e1 @{{ $('data').item.json.usuario.name }},\").\n    * **Perguntas Relevantes:** Se for uma pergunta sobre IA/automa\u00e7\u00e3o que voc\u00ea pode responder, forne\u00e7a uma resposta clara e \u00fatil. Se for muito complexa, agrade\u00e7a a pergunta e sugira buscar um post espec\u00edfico no perfil, ou diga que o tema \u00e9 interessante para um futuro conte\u00fado.\n    * **Elogios:** Agrade\u00e7a sinceramente o elogio e, se poss\u00edvel, conecte-o a um aspecto do perfil ou do conte\u00fado sobre IA/automa\u00e7\u00e3o.\n    * **Cr\u00edticas Construtivas:** Agrade\u00e7a o feedback, mostre que ele foi considerado e responda polidamente.\n    * **Pedidos de Ajuda Espec\u00edficos (n\u00e3o relacionados a conte\u00fado):** Se for um pedido de suporte t\u00e9cnico n\u00e3o relacionado ao tema central, direcione para o canal adequado ou explique educadamente que n\u00e3o pode ajudar com isso ali.\n    * **Coment\u00e1rios Vagos ou de Engajamento Simples (ex: \"Legal!\", \"\ud83d\udc4d\"):** Responda de forma curta e amig\u00e1vel, talvez com um emoji relevante ou incentivando a continuar acompanhando.\n    * **Spam ou Irrelevante:** Se o coment\u00e1rio for claramente spam, promocional n\u00e3o solicitado, ofensivo ou totalmente fora do t\u00f3pico de IA/automa\u00e7\u00e3o, N\u00c3O gere uma resposta. Neste caso, retorne APENAS a palavra `[IGNORE]`.\n\n3.  **Tom e Estilo:**\n    * Mantenha o tom amig\u00e1vel, \u00fatil e alinhado com um perfil de tecnologia/educa\u00e7\u00e3o.\n    * Evite respostas gen\u00e9ricas demais quando uma espec\u00edfica for poss\u00edvel.\n    * Mantenha as respostas relativamente concisas, adequadas para coment\u00e1rios do Instagram.\n\n### SA\u00cdDA ESPERADA ###\nRetorne APENAS o texto da resposta a ser publicada no Instagram. Se o coment\u00e1rio for classificado como spam/irrelevante conforme a regra 2.7, retorne APENAS a palavra `[IGNORE]`. N\u00e3o inclua nenhuma outra explica\u00e7\u00e3o ou texto adicional fora da resposta ou da palavra `[IGNORE]`.", "options": {}, "promptType": "define"}, "typeVersion": 1.8}, {"id": "e56a220b-f4aa-4505-9157-31980ccb547b", "name": "OpenRouter Chat Model", "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter", "position": [60, 1340], "parameters": {"model": "google/gemini-2.0-flash-exp:free", "options": {}}, "credentials": {"openRouterApi": {"id": "eGPA8rbskZCfFPBn", "name": "OpenRouter account"}}, "typeVersion": 1}, {"id": "9f318cf1-d99f-482d-a6d4-03ec4f603c05", "name": "Sticky Note1", "type": "n8n-nodes-base.stickyNote", "position": [-980, 380], "parameters": {"color": 5, "width": 1440, "height": 320, "content": "# Data Extraction\nDescription:\nExtracts relevant data from the incoming webhook payload.\nInstructions:\n\nVerify that all necessary fields (e.g., entry.id, from.id, from.username, message.id, message.text, media.id) are correctly mapped.\n\nThis data will be used in subsequent steps for processing and responding.\n"}, "typeVersion": 1}, {"id": "a413c839-fa19-44b9-ae33-2638dd45436e", "name": "Sticky Note2", "type": "n8n-nodes-base.stickyNote", "position": [-980, 780], "parameters": {"color": 6, "width": 1440, "height": 320, "content": "# User Validation\nDescription:\nChecks if the comment originates from a user other than the account owner.\nInstructions:\n\nCompare conta.id with usuario.id.\n\nProceed only if they differ, indicating the comment is from another user."}, "typeVersion": 1}, {"id": "b19d4891-5f7e-478b-9458-464af1fd409c", "name": "Sticky Note3", "type": "n8n-nodes-base.stickyNote", "position": [-980, 1160], "parameters": {"color": 2, "width": 1440, "height": 320, "content": "# AI Response Generation\nDescription:\nUtilizes an AI agent to generate a context-aware response to the user's comment.\nInstructions:\n\nEnsure the AI model is properly configured and has access to the necessary input data.\n\nThe prompt should guide the AI to produce responses that are friendly, informative, and aligned with the profile's focus on AI and automation."}, "typeVersion": 1}, {"id": "1f8b05ee-0380-4dc7-8671-f0ae87a7d08f", "name": "Sticky Note4", "type": "n8n-nodes-base.stickyNote", "position": [-980, 1560], "parameters": {"color": 3, "width": 1440, "height": 320, "content": "# Sending the Response\nDescription:\nSends the AI-generated reply back to the user via Instagram's API.\nInstructions:\n\nConfirm that the HTTP request is correctly formatted with the appropriate endpoint and authentication headers.\n\nHandle any potential errors or exceptions that may arise during the API call."}, "typeVersion": 1}, {"id": "ff54a7c0-40b9-4ad8-a3de-47a8a20cd3e1", "name": "Get post data", "type": "n8n-nodes-base.httpRequest", "position": [-80, 880], "parameters": {"url": "=https://graph.instagram.com/v22.0/{{ $json.usuario.media.id }}?fields=id,caption", "options": {}, "authentication": "genericCredentialType", "genericAuthType": "httpHeaderAuth"}, "credentials": {"httpHeaderAuth": {"id": "6H4syU3wzaoNBy2k", "name": "Header Auth account"}, "facebookGraphApi": {"id": "z7CU24qbafckHljY", "name": "Facebook Graph account"}}, "typeVersion": 4.2}, {"id": "d7a66f78-83f2-4173-8602-c34210364149", "name": "get_new_comments", "type": "n8n-nodes-base.webhook", "position": [40, 480], "webhookId": "ea7d37ac-9e82-40d7-bbb3-e9b7ce180fc9", "parameters": {"path": "ea7d37ac-9e82-40d7-bbb3-e9b7ce180fc9", "options": {}, "httpMethod": "POST"}, "typeVersion": 2}, {"id": "0924d70a-45a2-49c9-9459-eb6e7261005e", "name": "data", "type": "n8n-nodes-base.set", "position": [280, 480], "parameters": {"options": {}, "assignments": {"assignments": [{"id": "1a3c5a2e-115d-4072-9d27-9baa47e84d6f", "name": "endpoint", "type": "string", "value": "https://graph.instagram.com/v22.0"}, {"id": "ae83344d-abe5-43d6-991f-e757965e4557", "name": "conta.id", "type": "string", "value": "={{ $json.body.entry[0].id }}"}, {"id": "d18887fa-b882-4d69-a1c0-d161291fe5fb", "name": "usuario.id", "type": "string", "value": "={{ $json.body.entry[0].changes[0].value.from.id }}"}, {"id": "000f2d0e-6fbf-4e58-ae9c-cac4a3c54b33", "name": "usuario.name", "type": "string", "value": "={{ $json.body.entry[0].changes[0].value.from.username }}"}, {"id": "d6fa2b24-abbe-48f7-96ff-2fc69f17b61b", "name": "usuario.message.id", "type": "string", "value": "={{ $json.body.entry[0].changes[0].value.id }}"}, {"id": "605e9c4c-f2fc-49eb-8639-573c60ef33bb", "name": "usuario.message.text", "type": "string", "value": "={{ $json.body.entry[0].changes[0].value.text }}"}, {"id": "198afc5d-3fd1-4d9d-aa5a-8baf75f06d29", "name": "usuario.media.id", "type": "string", "value": "={{ $json.body.entry[0].changes[0].value.media.id }}"}]}}, "typeVersion": 3.4}, {"id": "2836ec33-b19f-4875-bfeb-08d9f9feae49", "name": "its me?", "type": "n8n-nodes-base.filter", "position": [200, 880], "parameters": {"options": {}, "conditions": {"options": {"version": 2, "leftValue": "", "caseSensitive": true, "typeValidation": "strict"}, "combinator": "and", "conditions": [{"id": "54c0a2d1-f812-4d6a-b50b-c272cfbba772", "operator": {"type": "string", "operation": "notEquals"}, "leftValue": "={{ $('data').item.json.conta.id }}", "rightValue": "={{ $('data').item.json.usuario.id }}"}]}}, "typeVersion": 2.2}, {"id": "fdf8ff5e-9c17-43f3-a747-79228ca68e03", "name": "Post comment", "type": "n8n-nodes-base.httpRequest", "position": [260, 1660], "parameters": {"url": "={{ $('data').item.json.endpoint }}/{{ $('data').item.json.usuario.message.id }}/replies", "method": "POST", "options": {}, "sendBody": true, "authentication": "genericCredentialType", "bodyParameters": {"parameters": [{"name": "message", "value": "={{ $json.output }}"}]}, "genericAuthType": "httpHeaderAuth"}, "credentials": {"httpHeaderAuth": {"id": "6H4syU3wzaoNBy2k", "name": "Header Auth account"}}, "typeVersion": 4.2}], "active": true, "pinData": {"get_new_comments": [{"json": {"body": {"entry": [{"id": "17841458749050638", "time": 1745696027, "changes": [{"field": "comments", "value": {"id": "17992882022637707", "from": {"id": "1797582914152092", "username": "luchiogutierrez"}, "text": "\ud83d\ude0d", "media": {"id": "17969449379894182", "media_product_type": "FEED"}}}]}], "object": "instagram"}, "query": {}, "params": {}, "headers": {"host": "host.docker.internal:5678", "accept": "*/*", "x-scheme": "https", "forwarded": "by=_exposr;for=173.252.95.16;host=engaging-seahorse-19.rshare.io;proto=https", "x-real-ip": "173.252.95.16", "connection": "keep-alive", "exposr-via": "77940acbe1755f6fca18880bd02e462ee55d0cde,0374ae5bede6d70d299155239dbb7e045533e1f4", "user-agent": "Webhooks/1.0 (https://fb.me/webhooks)", "content-type": "application/json", "x-request-id": "b0c4e9d6dd2baa18bab7eab283ad4788", "content-length": "316", "x-forwarded-for": "173.252.95.16", "x-hub-signature": "sha1=b3d396ac784244a020268dd9599e708b21688b75", "x-forwarded-host": "engaging-seahorse-19.rshare.io", "x-forwarded-port": "443", "x-forwarded-proto": "https", "x-forwarded-scheme": "https", "x-hub-signature-256": "sha256=40e1e91b67c7fa82afca10c81ff4b1200d9561384ee5ba690bf9bc22814cb09b"}, "webhookUrl": "https://engaging-seahorse-19.rshare.io/webhook/ea7d37ac-9e82-40d7-bbb3-e9b7ce180fc9", "executionMode": "production"}}], "Respond to Webhook": [{"json": {"body": {}, "query": {"hub.mode": "subscribe", "hub.challenge": "219585499", "hub.verify_token": "teste"}, "params": {}, "headers": {"host": "host.docker.internal:5678", "accept": "*/*", "x-scheme": "https", "forwarded": "by=_exposr;for=173.252.107.25;host=actual-beagle-88.rshare.io;proto=https", "x-real-ip": "173.252.107.25", "connection": "keep-alive", "exposr-via": "b37bd560bd173ee1195fceaef48a1468e8fa83f0,f06a3ed204e476a5915fc6fff7228b77c1c9e1d3", "user-agent": "facebookplatform/1.0 (+http://developers.facebook.com)", "x-request-id": "037b358cf28db9e3bffdf52703fd9069", "accept-encoding": "deflate, gzip", "x-forwarded-for": "173.252.107.25", "x-forwarded-host": "actual-beagle-88.rshare.io", "x-forwarded-port": "443", "x-forwarded-proto": "https", "x-forwarded-scheme": "https"}, "webhookUrl": "http://localhost:5678/webhook-test/ea7d37ac-9e82-40d7-bbb3-e9b7ce180fc9", "executionMode": "test"}}]}, "settings": {"executionOrder": "v1"}, "versionId": "2a39918c-36c8-486e-acb3-3420a4a8b8b1", "connections": {"data": {"main": [[{"node": "Get post data", "type": "main", "index": 0}]]}, "Webhook": {"main": [[{"node": "Respond to Webhook", "type": "main", "index": 0}]]}, "its me?": {"main": [[{"node": "AI Agent", "type": "main", "index": 0}]]}, "AI Agent": {"main": [[{"node": "Post comment", "type": "main", "index": 0}]]}, "Get post data": {"main": [[{"node": "its me?", "type": "main", "index": 0}]]}, "get_new_comments": {"main": [[{"node": "data", "type": "main", "index": 0}]]}, "OpenRouter Chat Model": {"ai_languageModel": [[{"node": "AI Agent", "type": "ai_languageModel", "index": 0}]]}}}