Validador de Facebook Webhook y plantillas de mensaje

Avanzado

Este es unAI Chatbot, Multimodal AIflujo de automatización del dominio deautomatización que contiene 23 nodos.Utiliza principalmente nodos como If, Set, Code, Notion, Webhook. Asistente de comentarios y mensajes privados de Facebook impulsado por Gemini (integrado con Notion)

Requisitos previos
  • Clave de API de Notion
  • Punto final de HTTP Webhook (n8n generará automáticamente)
  • Pueden requerirse credenciales de autenticación para la API de destino
  • Credenciales de Graph API de Facebook
  • Clave de API de Google Gemini
Vista previa del flujo de trabajo
Visualización de las conexiones entre nodos, con soporte para zoom y panorámica
Exportar flujo de trabajo
Copie la siguiente configuración JSON en n8n para importar y usar este flujo de trabajo
{
  "id": "[YOUR_WORKFLOW_ID]",
  "meta": {
    "instanceId": "[YOUR_INSTANCE_ID]",
    "templateCredsSetupCompleted": false
  },
  "name": "Facebook Moderator Webhook & Message Template",
  "tags": [],
  "nodes": [
    {
      "id": "d695c988-e0ad-4726-a446-f29c84ce343c",
      "name": "Agente de IA",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        4288,
        560
      ],
      "parameters": {
        "text": "=You are a helpful customer support agent for [COMPANY_NAME], a [INDUSTRY_TYPE] company in [COUNTRY/REGION].  \nRead the customer's comment and output a JSON with 3 fields: reply, sentiment, dm_message.  \n\nGuidelines:\n- Write in [TARGET_LANGUAGE] ([LANGUAGE_DIALECT]), unisex, short, warm, natural.\n- Never use [REGIONAL_WORDS_TO_AVOID] or filler intros ([\"GREETING_1\"], [\"GREETING_2\"], etc).\n- Always start directly with the subject.\n\nRules:\n- For any **question, inquiry, complaints, or price/product request** → \n  reply: short public message like \"[STANDARD_DM_REDIRECT_MESSAGE] 🙏\" (variations allowed).  \n  dm_message: use the relevant answer from the database ({{ $('Arrange KB').item.json.databaseText }}).\n  sentiment: \"normal\" or \"price\".\n- For **compliments/positive only** → \n  reply: short thanks (e.g., \"[THANK_YOU_MESSAGE] 💙\").  \n  dm_message: \"\"  \n  sentiment: \"complement\".\n- For **complaints (no swears)** → \n  reply: short apology + mention DM (e.g., \"[APOLOGY_MESSAGE] 🙏 [DM_MENTION]\").  \n  dm_message: \"[COMPLAINT_RESPONSE_TEMPLATE]\" \n- For unclear or not understandable words/comments (e.g., \"hm\", \"ok\", \"??\") →\n  reply: \"[CLARIFICATION_REQUEST_MESSAGE] 🙏\"\n  dm_message: \"\". (empty)\n  sentiment: \"normal\".\n  sentiment: \"negative\".\n- For **offensive words, spam, or links** → \n  reply: \"\"  \n  dm_message: \"\"  \n  sentiment: \"negative\".\n\nOutput only valid JSON:  \n{\n  \"reply\": \"...\",\n  \"sentiment\": \"normal | price | negative | complement\",\n  \"dm_message\": \"...\"\n}\n\nCustomer comment: \"{{ $('Parse Comms').item.json.comment_message }}\"\n",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2.1
    },
    {
      "id": "d376462a-637e-41d4-a58f-144ca11285f7",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        4192,
        784
      ],
      "parameters": {
        "options": {
          "temperature": 0.1
        }
      },
      "credentials": {
        "googlePalmApi": {
          "id": "[YOUR_GEMINI_API_CREDENTIAL_ID]",
          "name": "[YOUR_GEMINI_API_CREDENTIAL_NAME]"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e200441c-1757-4106-8727-e3a3ad130b6e",
      "name": "Eliminar Comunicaciones",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        5264,
        832
      ],
      "parameters": {
        "node": "={{ $('Webhook1').item.json.body.entry[0].changes[0].value.comment_id }}",
        "options": {
          "queryParameters": {
            "parameter": [
              {
                "name": "is_hidden",
                "value": "true"
              }
            ]
          }
        },
        "graphApiVersion": "v23.0",
        "httpRequestMethod": "POST"
      },
      "credentials": {
        "facebookGraphApi": {
          "id": "[YOUR_FACEBOOK_API_CREDENTIAL_ID]",
          "name": "[YOUR_FACEBOOK_API_CREDENTIAL_NAME]"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7f5b68d5-070f-4573-ac83-50b8d12bb1f1",
      "name": "Responder",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        4880,
        336
      ],
      "parameters": {
        "edge": "comments",
        "node": "={{ $('Webhook1').item.json.body.entry[0].changes[0].value.comment_id }}",
        "options": {
          "queryParameters": {
            "parameter": [
              {
                "name": "message",
                "value": "={{ $('Separate rep&sent').item.json.reply }}"
              }
            ]
          }
        },
        "graphApiVersion": "v23.0",
        "httpRequestMethod": "POST"
      },
      "credentials": {
        "facebookGraphApi": {
          "id": "[YOUR_FACEBOOK_API_CREDENTIAL_ID]",
          "name": "[YOUR_FACEBOOK_API_CREDENTIAL_NAME]"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "385719df-bd5f-40f7-ac86-5f3ad3170585",
      "name": "Responder1",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        5104,
        832
      ],
      "parameters": {
        "edge": "comments",
        "node": "={{ $('Webhook1').item.json.body.entry[0].changes[0].value.comment_id }}",
        "options": {
          "queryParameters": {
            "parameter": [
              {
                "name": "message",
                "value": "={{ $('Separate rep&sent').item.json.reply }}"
              }
            ]
          }
        },
        "graphApiVersion": "v23.0",
        "httpRequestMethod": "POST"
      },
      "credentials": {
        "facebookGraphApi": {
          "id": "[YOUR_FACEBOOK_API_CREDENTIAL_ID]",
          "name": "[YOUR_FACEBOOK_API_CREDENTIAL_NAME]"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "cd5cb95d-3a21-42b5-a679-5fcac06759c2",
      "name": "Webhook1",
      "type": "n8n-nodes-base.webhook",
      "position": [
        2656,
        560
      ],
      "webhookId": "[YOUR_WEBHOOK_ID]",
      "parameters": {
        "path": "[YOUR_WEBHOOK_PATH]",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2.1
    },
    {
      "id": "b342831b-72e8-4749-8589-0bdf280e1018",
      "name": "Analizar Comunicaciones",
      "type": "n8n-nodes-base.set",
      "position": [
        3040,
        544
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "c6332299-eda4-4602-a43a-a703574694cb",
              "name": "page_id",
              "type": "string",
              "value": "={{ $json.body.entry[0].id }}"
            },
            {
              "id": "55f0414b-399c-4bcd-bb40-782e84f844d8",
              "name": "post_id",
              "type": "string",
              "value": "={{ $json.body.entry[0].changes[0].value.post_id }}"
            },
            {
              "id": "52ff90c7-1c35-4755-a0fa-a2e7c3539e64",
              "name": "comment_id",
              "type": "string",
              "value": "={{ $json.body.entry[0].changes[0].value.comment_id }}"
            },
            {
              "id": "5ea9cb24-8e33-477d-b39d-9dd20faa6e89",
              "name": "comment_message",
              "type": "string",
              "value": "={{ $json.body.entry[0].changes[0].value.message }}"
            },
            {
              "id": "b0e64cf7-6b84-4efd-a8a0-a6a8a91ff245",
              "name": "parent_id",
              "type": "string",
              "value": "={{ $json.body.entry[0].changes[0].value.parent_id }}"
            },
            {
              "id": "57cc15a0-fe14-45c6-abc3-b65d033904d6",
              "name": "comm_time",
              "type": "string",
              "value": "={{ $json.body.entry[0].changes[0].value.created_time }}"
            },
            {
              "id": "ae4a2f1a-35f3-4b92-b8fc-3bab16338c8f",
              "name": "field",
              "type": "string",
              "value": "={{ $json.body.entry[0].changes[0].field }}"
            },
            {
              "id": "7492664e-bde3-4618-8f8a-4afc78db218a",
              "name": "sender_id",
              "type": "string",
              "value": "={{ $json.body.entry[0].changes[0].value.from.id }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "81631f15-f9b6-4bdb-a40b-a9705c88b159",
      "name": "Verificar Base de Datos",
      "type": "n8n-nodes-base.notion",
      "position": [
        3440,
        544
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "key": "Comment ID|rich_text",
              "condition": "equals",
              "richTextValue": "={{ $json.comment_id }}"
            },
            {
              "key": "sender id|rich_text",
              "condition": "equals",
              "richTextValue": "[YOUR_PAGE_ID]"
            }
          ]
        },
        "options": {},
        "resource": "databasePage",
        "matchType": "allFilters",
        "operation": "getAll",
        "databaseId": {
          "__rl": true,
          "mode": "list",
          "value": "[YOUR_PROCESSED_COMMENTS_DATABASE_ID]",
          "cachedResultUrl": "[YOUR_NOTION_DATABASE_URL]",
          "cachedResultName": "Processed Facebook Comments"
        },
        "filterType": "manual"
      },
      "credentials": {
        "notionApi": {
          "id": "[YOUR_NOTION_API_CREDENTIAL_ID]",
          "name": "[YOUR_NOTION_API_CREDENTIAL_NAME]"
        }
      },
      "typeVersion": 2.2,
      "alwaysOutputData": true
    },
    {
      "id": "6a13ad96-70da-4e42-a6ca-76cf4a74f785",
      "name": "Obtener Base de Conocimiento",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3584,
        544
      ],
      "parameters": {
        "url": "https://api.notion.com/v1/databases/[YOUR_KNOWLEDGE_BASE_DATABASE_ID]/query",
        "method": "POST",
        "options": {},
        "jsonBody": "{\n  \"page_size\": 100\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "notionApi"
      },
      "credentials": {
        "notionApi": {
          "id": "[YOUR_NOTION_API_CREDENTIAL_ID]",
          "name": "[YOUR_NOTION_API_CREDENTIAL_NAME]"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "6e798d06-ea8e-455f-9d68-0eae00051f51",
      "name": "Organizar Base de Conocimiento",
      "type": "n8n-nodes-base.code",
      "position": [
        3744,
        544
      ],
      "parameters": {
        "jsCode": "// Get the response from Notion API\nconst notionResponse = $input.first().json;\nconst pages = notionResponse.results || [];\n\n// Helper function to extract text from Notion properties\nfunction extractText(property) {\n  if (!property) return '';\n\n  switch (property.type) {\n    case 'title':\n      return property.title?.map(t => t.plain_text).join('\\n') || '';\n    case 'rich_text':\n      return property.rich_text?.map(t => t.plain_text).join('\\n') || '';\n    case 'select':\n      return property.select?.name || '';\n    case 'multi_select':\n      return property.multi_select?.map(item => item.name).join(', ') || '';\n    case 'number':\n      return property.number?.toString() || '';\n    case 'checkbox':\n      return property.checkbox ? '[YES_TEXT]' : '[NO_TEXT]';\n    case 'date':\n      return property.date?.start || '';\n    case 'email':\n      return property.email || '';\n    case 'phone_number':\n      return property.phone_number || '';\n    case 'url':\n      return property.url || '';\n    default:\n      return '';\n  }\n}\n\n// Process data into clean JSON\nconst database = pages.map(page => {\n  const item = {};\n  for (const [propName, propData] of Object.entries(page.properties)) {\n    item[propName] = extractText(propData);\n  }\n  return item;\n}).filter(item => Object.values(item).some(value => value.length > 0));\n\n// Build databaseText (preserve newlines inside values; do NOT collapse \\n)\nconst databaseText = database.map(item => {\n  return Object.entries(item)\n    .filter(([key, value]) => value && value.trim() !== '')\n    .map(([key, value]) => {\n      let clean = value\n        .replace(/[\\\"\"\"«»„]/g, '')   // remove quotes\n        .replace(/[ \\t]+/g, ' ')    // collapse spaces/tabs only; keep \\n\n        .replace(/\\r\\n/g, '\\n')     // normalize Windows newlines\n        .trim();\n      return `${key}: ${clean}`;\n    })\n    .join(' | ');\n}).join('\\n\\n');\n\n// Build databaseRaw (keeps full formatting for Messenger DMs)\nconst databaseRaw = database.map(item => {\n  return Object.entries(item)\n    .filter(([key, value]) => value && value.trim() !== '')\n    .map(([key, value]) => `${key}: ${value}`)\n    .join('\\n');\n}).join('\\n\\n');\n\n// Build databaseRawList (array per entry, verbatim)\nconst databaseRawList = database.map(item => {\n  return Object.entries(item)\n    .filter(([key, value]) => value && value.trim() !== '')\n    .map(([key, value]) => `${key}: ${value}`)\n    .join('\\n');\n});\n\n// Return multiple formats\nreturn [{\n  json: {\n    database,                                   // Original array (for processing)\n    databaseJSON: JSON.stringify(database, null, 2), // Pretty formatted JSON string\n    databaseText,                               // Cleaned & flattened text (for AI), keeps \\n\n    databaseRaw,                                // Raw text with formatting (for DM)\n    databaseRawList,                            // Array of verbatim entries\n    databaseString: JSON.stringify(database)    // Compact JSON string\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "81827b17-d190-46fa-9630-955b7476a7d2",
      "name": "¿Quién está ahí?",
      "type": "n8n-nodes-base.if",
      "position": [
        3904,
        544
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "3fe76f48-77f6-42fd-b62f-8e038aec355e",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $('Parse Comms').item.json.sender_id }}",
              "rightValue": "[YOUR_PAGE_ID]"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "34265ef0-ddb3-4e32-950e-e81899ceab57",
      "name": "Comentario",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        4112,
        560
      ],
      "parameters": {
        "edge": "comments",
        "node": "={{ $('Webhook1').item.json.body.entry[0].changes[0].value.comment_id }}",
        "options": {},
        "graphApiVersion": "v23.0"
      },
      "credentials": {
        "facebookGraphApi": {
          "id": "[YOUR_FACEBOOK_API_CREDENTIAL_ID]",
          "name": "[YOUR_FACEBOOK_API_CREDENTIAL_NAME]"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "be7ffc10-8ccb-4d87-88a7-668eb914f87c",
      "name": "¿Apropiado?",
      "type": "n8n-nodes-base.if",
      "position": [
        4864,
        560
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "b5250fd7-6814-4ed9-9252-502ddfcfe3b0",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.sentiment }}",
              "rightValue": "normal"
            },
            {
              "id": "206c8aaf-5d2c-40ca-a528-d3fea28f7d6b",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.sentiment }}",
              "rightValue": "price"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "a7d9d1e3-de37-4e06-b0b6-de26914fbb0b",
      "name": "Separar respuestas y enviados",
      "type": "n8n-nodes-base.set",
      "position": [
        4592,
        560
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a66c9423-7860-447d-9770-a25f969e1188",
              "name": "=reply",
              "type": "string",
              "value": "={{ JSON.parse($json[\"output\"].replace(/```json|```/g, \"\").trim()).reply }}"
            },
            {
              "id": "f20c73de-ad95-40d0-8e52-23c335af9858",
              "name": "sentiment",
              "type": "string",
              "value": "={{ JSON.parse($json[\"output\"].replace(/```json|```/g, \"\").trim()).sentiment }}"
            },
            {
              "id": "c87acc41-657d-4009-8c39-38b13d73ccc0",
              "name": "dm_message",
              "type": "string",
              "value": "={{ JSON.parse($json[\"output\"].replace(/```json|```/g, \"\").trim()).dm_message }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "4675cd80-c5f4-41e6-b982-448cf9081d85",
      "name": "Añadir a BD",
      "type": "n8n-nodes-base.notion",
      "position": [
        5040,
        336
      ],
      "parameters": {
        "options": {},
        "resource": "databasePage",
        "databaseId": {
          "__rl": true,
          "mode": "list",
          "value": "[YOUR_PROCESSED_COMMENTS_DATABASE_ID]",
          "cachedResultUrl": "[YOUR_NOTION_DATABASE_URL]",
          "cachedResultName": "Processed Facebook Comments"
        },
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Comment ID|rich_text",
              "textContent": "={{ $('Webhook1').item.json.body.entry[0].changes[0].value.comment_id }}"
            },
            {
              "key": "Response Status|status",
              "statusValue": "Done"
            }
          ]
        }
      },
      "credentials": {
        "notionApi": {
          "id": "[YOUR_NOTION_API_CREDENTIAL_ID]",
          "name": "[YOUR_NOTION_API_CREDENTIAL_NAME]"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "124ff942-ca28-44a9-a7f1-a7eca1c7ec02",
      "name": "Añadir a BD1",
      "type": "n8n-nodes-base.notion",
      "position": [
        5456,
        832
      ],
      "parameters": {
        "options": {},
        "resource": "databasePage",
        "databaseId": {
          "__rl": true,
          "mode": "list",
          "value": "[YOUR_PROCESSED_COMMENTS_DATABASE_ID]",
          "cachedResultUrl": "[YOUR_NOTION_DATABASE_URL]",
          "cachedResultName": "Processed Facebook Comments"
        },
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Comment ID|rich_text",
              "textContent": "={{ $('Webhook1').item.json.body.entry[0].changes[0].value.comment_id }}"
            },
            {
              "key": "Response Status|status",
              "statusValue": "Done"
            }
          ]
        }
      },
      "credentials": {
        "notionApi": {
          "id": "[YOUR_NOTION_API_CREDENTIAL_ID]",
          "name": "[YOUR_NOTION_API_CREDENTIAL_NAME]"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "534e917b-f881-4fa2-904b-3c8a7bb67084",
      "name": "If2",
      "type": "n8n-nodes-base.if",
      "position": [
        2816,
        560
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "b73a48f5-cbc2-4885-9e4e-115b6a74f320",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.body.entry[0].changes[0].value.item }}",
              "rightValue": "comment"
            },
            {
              "id": "59f72c78-dd87-47f4-8c69-328013f52a4f",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.body.entry[0].changes[0].value.verb }}",
              "rightValue": "add"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "e808bf8f-d20d-4ed5-ac4a-fd7dd7576b60",
      "name": "If3",
      "type": "n8n-nodes-base.if",
      "position": [
        4768,
        848
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "3e37d022-3aff-4906-8aa6-57b287222dac",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.reply }}",
              "rightValue": ""
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "8fd26449-f990-43db-bf9e-7dfe0c306084",
      "name": "Eliminar Comunicaciones1",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        4784,
        1088
      ],
      "parameters": {
        "node": "={{ $('Webhook1').item.json.body.entry[0].changes[0].value.comment_id }}",
        "options": {
          "queryParameters": {
            "parameter": [
              {
                "name": "is_hidden",
                "value": "true"
              }
            ]
          }
        },
        "graphApiVersion": "v23.0",
        "httpRequestMethod": "POST"
      },
      "credentials": {
        "facebookGraphApi": {
          "id": "[YOUR_FACEBOOK_API_CREDENTIAL_ID]",
          "name": "[YOUR_FACEBOOK_API_CREDENTIAL_NAME]"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ebdc35ce-6f95-4bdd-91e7-89e5c5840e00",
      "name": "Código2",
      "type": "n8n-nodes-base.code",
      "position": [
        3248,
        544
      ],
      "parameters": {
        "jsCode": "const fullId = $json.comment_id;\nreturn [{\n  json: {\n    ...$json,\n    comment_id_raw: fullId.split('_').pop()  // keep only the last part\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "7dbbc96b-c5b7-4d78-9bac-7305436e27c6",
      "name": "Mensajes",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        5520,
        352
      ],
      "parameters": {
        "url": "=https://graph.facebook.com/v23.0/{{ $('Parse Comms').item.json.page_id }}/messages",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "recipient.comment_id",
              "value": "={{ $('Parse Comms').item.json.comment_id }}"
            },
            {
              "name": "message.text",
              "value": "={{ $('Separate rep&sent').item.json.dm_message }}"
            }
          ]
        },
        "nodeCredentialType": "facebookGraphApi"
      },
      "credentials": {
        "facebookGraphApi": {
          "id": "[YOUR_FACEBOOK_MESSAGES_API_CREDENTIAL_ID]",
          "name": "[YOUR_FACEBOOK_MESSAGES_API_CREDENTIAL_NAME]"
        }
      },
      "typeVersion": 4.2,
      "alwaysOutputData": false
    },
    {
      "id": "8525ac2e-1ef7-44d0-97f1-bc9a1963f0be",
      "name": "Mensajes1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        5648,
        832
      ],
      "parameters": {
        "url": "=https://graph.facebook.com/v23.0/{{ $('Parse Comms').item.json.page_id }}/messages",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"recipient\": {\n    \"comment_id\": \"{{ $('Parse Comms').item.json.comment_id }}\"\n  },\n  \"message\": {\n    \"text\": \"{{ $json.dm_message }}\"\n  }\n}\n ",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "facebookGraphApi"
      },
      "credentials": {
        "facebookGraphApi": {
          "id": "[YOUR_FACEBOOK_MESSAGES_API_CREDENTIAL_ID]",
          "name": "[YOUR_FACEBOOK_MESSAGES_API_CREDENTIAL_NAME]"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "6406e117-bcfe-46fc-8f4b-5b0774927387",
      "name": "If4",
      "type": "n8n-nodes-base.if",
      "position": [
        5264,
        336
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "1195e00d-4cc8-45f5-8970-e6a79c169b03",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $('Separate rep&sent').item.json.sentiment }}",
              "rightValue": "complement"
            }
          ]
        }
      },
      "typeVersion": 2.2
    }
  ],
  "active": false,
  "pinData": {
    "Webhook1": [
      {
        "json": {
          "body": {
            "entry": [
              {
                "id": "[YOUR_PAGE_ID]",
                "time": 1756308512,
                "changes": [
                  {
                    "field": "feed",
                    "value": {
                      "from": {
                        "id": "[SAMPLE_USER_ID]",
                        "name": "[SAMPLE_USER_NAME]"
                      },
                      "item": "comment",
                      "post": {
                        "id": "[SAMPLE_POST_ID]",
                        "status_type": "added_photos",
                        "is_published": true,
                        "updated_time": "2025-08-27T15:28:27+0000",
                        "permalink_url": "[SAMPLE_POST_URL]",
                        "promotion_status": "ineligible"
                      },
                      "verb": "add",
                      "message": "[SAMPLE_COMMENT_MESSAGE]",
                      "post_id": "[SAMPLE_POST_ID]",
                      "parent_id": "[SAMPLE_PARENT_ID]",
                      "comment_id": "[SAMPLE_COMMENT_ID]",
                      "created_time": 1756308507
                    }
                  }
                ]
              }
            ],
            "object": "page"
          },
          "query": {},
          "params": {},
          "headers": {
            "host": "[YOUR_WEBHOOK_HOST]",
            "accept": "*/*",
            "user-agent": "Webhooks/1.0 (https://fb.me/webhooks)",
            "content-type": "application/json",
            "content-length": "781",
            "accept-encoding": "gzip",
            "x-forwarded-for": "[IP_ADDRESS]",
            "x-hub-signature": "[WEBHOOK_SIGNATURE]",
            "x-forwarded-host": "[YOUR_WEBHOOK_HOST]",
            "x-forwarded-proto": "https",
            "x-hub-signature-256": "[WEBHOOK_SIGNATURE_256]"
          },
          "webhookUrl": "[YOUR_WEBHOOK_URL]",
          "executionMode": "production"
        }
      }
    ]
  },
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "[YOUR_VERSION_ID]",
  "connections": {
    "534e917b-f881-4fa2-904b-3c8a7bb67084": {
      "main": [
        [
          {
            "node": "b342831b-72e8-4749-8589-0bdf280e1018",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "e808bf8f-d20d-4ed5-ac4a-fd7dd7576b60": {
      "main": [
        [
          {
            "node": "385719df-bd5f-40f7-ac86-5f3ad3170585",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "8fd26449-f990-43db-bf9e-7dfe0c306084",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6406e117-bcfe-46fc-8f4b-5b0774927387": {
      "main": [
        [],
        [
          {
            "node": "7dbbc96b-c5b7-4d78-9bac-7305436e27c6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ebdc35ce-6f95-4bdd-91e7-89e5c5840e00": {
      "main": [
        [
          {
            "node": "81631f15-f9b6-4bdb-a40b-a9705c88b159",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7f5b68d5-070f-4573-ac83-50b8d12bb1f1": {
      "main": [
        [
          {
            "node": "4675cd80-c5f4-41e6-b982-448cf9081d85",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "385719df-bd5f-40f7-ac86-5f3ad3170585": {
      "main": [
        [
          {
            "node": "e200441c-1757-4106-8727-e3a3ad130b6e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "34265ef0-ddb3-4e32-950e-e81899ceab57": {
      "main": [
        [
          {
            "node": "d695c988-e0ad-4726-a446-f29c84ce343c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d695c988-e0ad-4726-a446-f29c84ce343c": {
      "main": [
        [
          {
            "node": "a7d9d1e3-de37-4e06-b0b6-de26914fbb0b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6a13ad96-70da-4e42-a6ca-76cf4a74f785": {
      "main": [
        [
          {
            "node": "6e798d06-ea8e-455f-9d68-0eae00051f51",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7dbbc96b-c5b7-4d78-9bac-7305436e27c6": {
      "main": [
        [],
        []
      ]
    },
    "cd5cb95d-3a21-42b5-a679-5fcac06759c2": {
      "main": [
        [
          {
            "node": "534e917b-f881-4fa2-904b-3c8a7bb67084",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4675cd80-c5f4-41e6-b982-448cf9081d85": {
      "main": [
        [
          {
            "node": "6406e117-bcfe-46fc-8f4b-5b0774927387",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "124ff942-ca28-44a9-a7f1-a7eca1c7ec02": {
      "main": [
        [
          {
            "node": "8525ac2e-1ef7-44d0-97f1-bc9a1963f0be",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6e798d06-ea8e-455f-9d68-0eae00051f51": {
      "main": [
        [
          {
            "node": "81827b17-d190-46fa-9630-955b7476a7d2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "b342831b-72e8-4749-8589-0bdf280e1018": {
      "main": [
        [
          {
            "node": "ebdc35ce-6f95-4bdd-91e7-89e5c5840e00",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "be7ffc10-8ccb-4d87-88a7-668eb914f87c": {
      "main": [
        [
          {
            "node": "7f5b68d5-070f-4573-ac83-50b8d12bb1f1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "e808bf8f-d20d-4ed5-ac4a-fd7dd7576b60",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "e200441c-1757-4106-8727-e3a3ad130b6e": {
      "main": [
        [
          {
            "node": "124ff942-ca28-44a9-a7f1-a7eca1c7ec02",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "81827b17-d190-46fa-9630-955b7476a7d2": {
      "main": [
        [],
        [
          {
            "node": "34265ef0-ddb3-4e32-950e-e81899ceab57",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "81631f15-f9b6-4bdb-a40b-a9705c88b159": {
      "main": [
        [
          {
            "node": "6a13ad96-70da-4e42-a6ca-76cf4a74f785",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a7d9d1e3-de37-4e06-b0b6-de26914fbb0b": {
      "main": [
        [
          {
            "node": "be7ffc10-8ccb-4d87-88a7-668eb914f87c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d376462a-637e-41d4-a58f-144ca11285f7": {
      "ai_languageModel": [
        [
          {
            "node": "d695c988-e0ad-4726-a446-f29c84ce343c",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}
Preguntas frecuentes

¿Cómo usar este flujo de trabajo?

Copie el código de configuración JSON de arriba, cree un nuevo flujo de trabajo en su instancia de n8n y seleccione "Importar desde JSON", pegue la configuración y luego modifique la configuración de credenciales según sea necesario.

¿En qué escenarios es adecuado este flujo de trabajo?

Avanzado - Chatbot de IA, IA Multimodal

¿Es de pago?

Este flujo de trabajo es completamente gratuito, puede importarlo y usarlo directamente. Sin embargo, tenga en cuenta que los servicios de terceros utilizados en el flujo de trabajo (como la API de OpenAI) pueden requerir un pago por su cuenta.

Información del flujo de trabajo
Nivel de dificultad
Avanzado
Número de nodos23
Categoría2
Tipos de nodos9
Descripción de la dificultad

Adecuado para usuarios avanzados, flujos de trabajo complejos con 16+ nodos

Autor
Abdullah Alshiekh

Abdullah Alshiekh

@abdullah01

🚀 Automation pro building AI-powered workflows with n8n. 💼 Special focus on real use cases 🔧 Love clean, flexible, and business-ready automations.

Enlaces externos
Ver en n8n.io

Compartir este flujo de trabajo

Categorías

Categorías: 34