Webhook et modèle de message pour le modérateur Facebook

Avancé

Ceci est unAI Chatbot, Multimodal AIworkflow d'automatisation du domainecontenant 23 nœuds.Utilise principalement des nœuds comme If, Set, Code, Notion, Webhook. Assistant pour les commentaires et messages privés de Facebook (intégration Notion) alimenté par Gemini

Prérequis
  • Clé API Notion
  • Point de terminaison HTTP Webhook (généré automatiquement par n8n)
  • Peut nécessiter les informations d'identification d'authentification de l'API cible
  • Informations d'identification Facebook Graph API
  • Clé API Google Gemini
Aperçu du workflow
Visualisation des connexions entre les nœuds, avec support du zoom et du déplacement
Exporter le workflow
Copiez la configuration JSON suivante dans n8n pour importer et utiliser ce workflow
{
  "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": "Agent 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": "Supprimer communications",
      "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": "Répondre",
      "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": "Répondre1",
      "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": "Analyser communications",
      "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": "Vérifier base de données",
      "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": "Extraire base de connaissances",
      "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": "Organiser base de connaissances",
      "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 est là ?",
      "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": "Commentaire",
      "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": "Approprié ?",
      "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": "Séparer réponse/sentiment",
      "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": "Ajouter à la base de données",
      "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": "Ajouter à la base de données1",
      "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": "Si2",
      "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": "Si3",
      "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": "Supprimer communications1",
      "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": "Code2",
      "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": "Messages",
      "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": "Messages1",
      "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": "Si4",
      "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
          }
        ]
      ]
    }
  }
}
Foire aux questions

Comment utiliser ce workflow ?

Copiez le code de configuration JSON ci-dessus, créez un nouveau workflow dans votre instance n8n et sélectionnez "Importer depuis le JSON", collez la configuration et modifiez les paramètres d'authentification selon vos besoins.

Dans quelles scénarios ce workflow est-il adapté ?

Avancé - Chatbot IA, IA Multimodale

Est-ce payant ?

Ce workflow est entièrement gratuit et peut être utilisé directement. Veuillez noter que les services tiers utilisés dans le workflow (comme l'API OpenAI) peuvent nécessiter un paiement de votre part.

Informations sur le workflow
Niveau de difficulté
Avancé
Nombre de nœuds23
Catégorie2
Types de nœuds9
Description de la difficulté

Adapté aux utilisateurs avancés, avec des workflows complexes contenant 16+ nœuds

Auteur
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.

Liens externes
Voir sur n8n.io

Partager ce workflow

Catégories

Catégories: 34