AutomationFlowsAI & RAG › Facebook Messenger Bot with Gpt-4 for Text, Image & Voice Processing

Facebook Messenger Bot with Gpt-4 for Text, Image & Voice Processing

ByStéphane Bordas @stephanebordas on n8n.io

This workflow lets you build a Messenger AI Agent capable of understanding text, images, and voice notes, and replying intelligently in real time.

Webhook trigger★★★★★ complexityAI-powered34 nodesOpenAI ChatMemory Buffer WindowTool CalculatorTool WikipediaHTTP RequestOpenAIAgent
AI & RAG Trigger: Webhook Nodes: 34 Complexity: ★★★★★ AI nodes: yes Added:

This workflow corresponds to n8n.io template #9347 — we link there as the canonical source.

This workflow follows the Agent → HTTP Request recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "bBJOoh6tRVSg50K5",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Agent IA Messenger",
  "tags": [],
  "nodes": [
    {
      "id": "2ccd1577-6b09-4dba-a008-382833689fab",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2016,
        704
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d588ba3b-d9db-481a-bfdb-dea8a0d0f275",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        2192,
        704
      ],
      "parameters": {
        "sessionKey": "={{ $('Webhook1').item.json.body.entry[0].messaging[0].sender.id }}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "e97f4fe7-b9fd-465b-8229-9a117ce46b81",
      "name": "Calculator",
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "position": [
        2352,
        704
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "6a045e89-c2c1-4bef-b8bd-35eb6d524ee1",
      "name": "Wikipedia",
      "type": "@n8n/n8n-nodes-langchain.toolWikipedia",
      "position": [
        2512,
        704
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "d7cb9060-af1b-4006-814f-d13d00406bd6",
      "name": "Download Audio",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        880,
        448
      ],
      "parameters": {
        "url": "={{ $json.url }}",
        "options": {},
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "facebookGraphApi"
      },
      "credentials": {
        "facebookGraphApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "43dc357f-2e94-4ca4-87dd-bc26c5ca516c",
      "name": "Audio Transcriber",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1248,
        448
      ],
      "parameters": {
        "options": {},
        "resource": "audio",
        "operation": "transcribe"
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "e891d603-5258-47b5-a4de-834a21145aef",
      "name": "Identify and ReRoute Message Types",
      "type": "n8n-nodes-base.switch",
      "position": [
        368,
        432
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "=Image Message",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "b12ff3af-0aae-4874-9c16-37f0337bf214",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.type === \"image\" }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Audio Message",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "584171c6-5842-41a4-ae70-b901457d1b43",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.type === \"audio\" }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Text Message",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "c1d29099-8a6f-4944-ad5c-a60926aabbd1",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.type === \"text\" }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "18493f65-52e0-4438-afba-daaac6f8fabe",
      "name": "Download Image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        880,
        112
      ],
      "parameters": {
        "url": "={{ $json.url }}",
        "options": {},
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "facebookGraphApi"
      },
      "credentials": {
        "facebookGraphApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "908a01ea-04ba-4711-8aeb-0326abb7b512",
      "name": "Identify Message Type",
      "type": "n8n-nodes-base.function",
      "position": [
        0,
        448
      ],
      "parameters": {
        "functionCode": "// \u2500\u2500\u2500 0. R\u00e9cup\u00e8re la racine utile (body si pr\u00e9sent) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nconst root = $json.body ?? $json;   // \u2190 marche avec ou sans \"body\"\n\n// \u2500\u2500\u2500 1. Cherche l'objet \"message\", quel que soit le chemin \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nlet msg;\n\nif (root.message) {\n  // cas o\u00f9 un Set/Split l\u2019a d\u00e9j\u00e0 extrait\n  msg = root.message;\n} else if (root.entry?.[0]?.messaging?.[0]?.message) {\n  // structure brute Facebook\n  msg = root.entry[0].messaging[0].message;\n} else {\n  throw new Error('Impossible de localiser le champ \"message\"');\n}\n\n// \u2500\u2500\u2500 2. Pr\u00e9pare la sortie standardis\u00e9e \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nlet result;\n\nif (msg.attachments?.[0]) {\n  const att = msg.attachments[0];\n  if (att.type === 'image') {\n    result = { type: 'image', url: att.payload?.url };\n  } else if (att.type === 'audio') {\n    result = { type: 'audio', url: att.payload?.url };\n  } else {\n    result = { type: att.type || 'attachment', url: att.payload?.url };\n  }\n} else if (msg.text) {\n  result = { type: 'text', text: msg.text };\n} else {\n  result = { type: 'unknown' };\n}\n\n// \u2500\u2500\u2500 3. Retourne l'objet pour les n\u0153uds suivants \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nreturn [ result ];"
      },
      "typeVersion": 1
    },
    {
      "id": "4c783fcc-48ab-4381-ba12-d730d7837c30",
      "name": "Edit Fields1",
      "type": "n8n-nodes-base.set",
      "position": [
        1248,
        784
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "5a5d4ec5-61d5-471c-bab7-135528008e6c",
              "name": "user_prompt",
              "type": "string",
              "value": "={{ $json.text }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "752e4920-7677-4e78-bef9-1ee55478b33a",
      "name": "Edit Fields2",
      "type": "n8n-nodes-base.set",
      "position": [
        1632,
        448
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "5a5d4ec5-61d5-471c-bab7-135528008e6c",
              "name": "user_prompt",
              "type": "string",
              "value": "={{ $json.text }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "391e29fb-4b60-407e-a1f1-db0740fddf14",
      "name": "Edit Fields3",
      "type": "n8n-nodes-base.set",
      "position": [
        1632,
        112
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "5a5d4ec5-61d5-471c-bab7-135528008e6c",
              "name": "user_prompt",
              "type": "string",
              "value": "={{ $json.content }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "66394ce4-5a3d-45a8-8929-a5fe5d8399be",
      "name": "Code1",
      "type": "n8n-nodes-base.code",
      "position": [
        3152,
        448
      ],
      "parameters": {
        "jsCode": "// -------- Build Messenger Payload ----------\n// 1) R\u00e9cup\u00e8re le PSID directement depuis ton webhook \u201cWebhook1\u201d\nconst psid = ($node[\"Webhook1\"].json.body?.entry ?? $node[\"Webhook1\"].json.entry)[0]\n               .messaging[0].sender.id;   // ID du client\n\nconst reply = $json.output || 'R\u00e9ponse vide';   // texte d\u00e9j\u00e0 nettoy\u00e9 par le 1er Code\n\nreturn [{\n  json: {\n    messaging_type: 'RESPONSE',\n    recipient: { id: String(psid) },      //  \u2190 cha\u00eene obligatoire\n    message:   { text: reply }\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "5536e5a6-5b84-4a37-bdd4-a4fa01dc4e2c",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        2784,
        448
      ],
      "parameters": {
        "jsCode": "/**\n * n8n \u2013 Code node\n * Mode : Run Once for All Items\n * Objectif :\n *   1. Rep\u00e8re **gras** ou *gras*\n *   2. Convertit le contenu en lettres \"Unicode Bold\"\n *   3. Supprime tous les ast\u00e9risques\n */\n\nconst FIELD = 'output'; // \u2190 mets ici le nom exact du champ texte\n\n// --- petite fonction de conversion ASCII \u2192 Unicode gras\nfunction toUnicodeBold(str) {\n  const upperOffset = 0x1D400 - 0x41;      // A \u2192 \ud835\udc00\n  const lowerOffset = 0x1D41A - 0x61;      // a \u2192 \ud835\udc1a\n  const digitOffset = 0x1D7CE - 0x30;      // 0 \u2192 \ud835\udfce\n\n  return str.split('').map(ch => {\n    const code = ch.charCodeAt(0);\n    if (code >= 0x41 && code <= 0x5A) return String.fromCodePoint(code + upperOffset); // A-Z\n    if (code >= 0x61 && code <= 0x7A) return String.fromCodePoint(code + lowerOffset); // a-z\n    if (code >= 0x30 && code <= 0x39) return String.fromCodePoint(code + digitOffset); // 0-9\n    return ch; // ponctuation, espaces\u2026\n  }).join('');\n}\n\nfor (const item of $input.all()) {\n  if (item.json[FIELD]) {\n    item.json[FIELD] = item.json[FIELD]\n      // \u25ba 1. **\u2026**  ou *\u2026*  \u2192 conversion + suppression d\u2019ast\u00e9risques\n      .replace(/\\*{1,2}([^*]+?)\\*{1,2}/gs, (_, txt) => toUnicodeBold(txt))\n\n      // \u25ba 2. S\u2019il reste des ast\u00e9risques isol\u00e9s \u2192 on les retire\n      .replace(/\\*/g, '');\n  }\n}\n\nreturn $input.all();"
      },
      "typeVersion": 2
    },
    {
      "id": "8e37259a-0d7f-40e6-87a5-d7eafe6c4913",
      "name": "Send Response",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3520,
        448
      ],
      "parameters": {
        "url": "https://graph.facebook.com/v17.0/me/messages?access_token=",
        "body": "={{ JSON.stringify($json, null, 0) }}",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "raw",
        "sendHeaders": true,
        "rawContentType": "application/json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "85bc2e7b-83d3-4481-948b-4e0444d52246",
      "name": "AI Agent Messenger",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2160,
        448
      ],
      "parameters": {
        "text": "={{ $json.user_prompt }}",
        "options": {
          "systemMessage": "Tu es un assistant sp\u00e9cialis\u00e9.\n- Si la demande n\u00e9cessite uniquement des calculs math\u00e9matiques, financiers ou statistiques : utilise toujours l\u2019outil Calculatrice.\n- Si la demande n\u00e9cessite une recherche d\u2019information externe (histoire, biographie, faits g\u00e9n\u00e9raux) : utilise l\u2019outil Wikip\u00e9dia.\n- Ne m\u00e9lange pas les deux outils sauf si c\u2019est absolument n\u00e9cessaire.\n- Lorsque la question contient un montant, un pourcentage, un taux ou une dur\u00e9e : c\u2019est un calcul \u2192 utilise uniquement l\u2019outil Calculatrice."
        },
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "a09429dd-8e6c-4c85-94c3-c73c8385a6c0",
      "name": "Analyze image",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1248,
        112
      ],
      "parameters": {
        "text": "Describe this image.",
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "GPT-4O"
        },
        "options": {},
        "resource": "image",
        "inputType": "base64",
        "operation": "analyze"
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "b838533f-1f70-45a1-9785-ea28aacc0822",
      "name": "Webhook1",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -368,
        448
      ],
      "parameters": {
        "path": "Messenger",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2.1
    },
    {
      "id": "bd67326b-ef8e-48fc-a9da-4c917ad88594",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        256
      ],
      "parameters": {
        "width": 336,
        "height": 384,
        "content": "## Webhook1 (Messenger Entry)\n\nReceives Messenger events and starts the processing. Reply \u201cImmediately\u201d to acknowledge fast, then let the flow continue."
      },
      "typeVersion": 1
    },
    {
      "id": "5fd271ca-be10-4830-bc24-7994b9cb74a8",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        256
      ],
      "parameters": {
        "width": 336,
        "height": 384,
        "content": "## Identify Message Type (Code)\n\nConverts the Messenger payload into a simple shape: text, image, audio, or unknown. This makes the rest of the flow predictable."
      },
      "typeVersion": 1
    },
    {
      "id": "a44151ae-4d95-47bb-8f9d-2ba746cfd1dd",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        256
      ],
      "parameters": {
        "width": 368,
        "height": 384,
        "content": "## Identify and ReRoute Message Types  (Router / Rules)\n\nSends each message down the right lane (image/audio/text). Add a default route for unsupported formats."
      },
      "typeVersion": 1
    },
    {
      "id": "0b132eb3-09ff-4fcf-a11b-4655128298a9",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        768,
        -48
      ],
      "parameters": {
        "color": 5,
        "width": 336,
        "height": 320,
        "content": "## Download Image\n\nDownloads the image from the provided URL. If Facebook blocks it, add the Page Token as query or Bearer YOUR_TOKEN_HERE"
      },
      "typeVersion": 1
    },
    {
      "id": "3ed9947b-4940-4d4e-a51e-826d4cdb3041",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1136,
        -48
      ],
      "parameters": {
        "color": 5,
        "width": 336,
        "height": 320,
        "content": "## Analyze image  (Vision)\n\nUses a vision model to describe the image and produce useful text. "
      },
      "typeVersion": 1
    },
    {
      "id": "8521e4c9-92ac-4e9f-beb0-150a84301a72",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1504,
        -48
      ],
      "parameters": {
        "color": 5,
        "width": 368,
        "height": 320,
        "content": "## Edit Fields3  (image \u2192 prompt)\n\nCopies the image description into user_prompt. Make sure other fields stay available if you need them."
      },
      "typeVersion": 1
    },
    {
      "id": "ef459985-d05b-41ed-b540-166ddfd8320c",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        768,
        304
      ],
      "parameters": {
        "color": 5,
        "width": 336,
        "height": 304,
        "content": "## Download Audio\n\nDownloads the audio file from the URL. As with images, add the Page Token if needed."
      },
      "typeVersion": 1
    },
    {
      "id": "b9482f90-0981-46b9-b07f-a95569ee6399",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1136,
        304
      ],
      "parameters": {
        "color": 5,
        "width": 336,
        "height": 304,
        "content": "## Audio Transcriber\n\nTranscribes the voice note into clean text. Let auto language detection work when possible."
      },
      "typeVersion": 1
    },
    {
      "id": "59be867f-e5f4-4252-a251-7f20c0654003",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1504,
        304
      ],
      "parameters": {
        "color": 5,
        "width": 368,
        "height": 304,
        "content": "## Edit Fields2  (audio \u2192 prompt)\n\nPuts the audio transcript into user_prompt. You can also trim extra whitespace here."
      },
      "typeVersion": 1
    },
    {
      "id": "26565c46-d336-4a12-a83d-fd06461edacb",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1136,
        640
      ],
      "parameters": {
        "color": 5,
        "width": 336,
        "height": 304,
        "content": "## Edit Fields1  (text \u2192 prompt)\n\nMaps the user\u2019s text into user_prompt. Optional: truncate overly long messages."
      },
      "typeVersion": 1
    },
    {
      "id": "338acd3a-73e1-479f-85a6-809daa4bca01",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2672,
        240
      ],
      "parameters": {
        "width": 336,
        "height": 368,
        "content": "## Code  (post-process bold)\n\nConverts ** \u2026 **/ * \u2026 * to Unicode bold in output and strips leftover asterisks. Use bold only for headings or key points to keep the message readable."
      },
      "typeVersion": 1
    },
    {
      "id": "4aa7b210-b885-407a-93cc-3c8ec9c1a150",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3040,
        240
      ],
      "parameters": {
        "width": 336,
        "height": 368,
        "content": "## Code1  (build Messenger payload)\n\nBuilds the Graph object with recipient.id = <PSID> and message.text = output (messaging_type: \"RESPONSE\"). Ensure the ID is a string and gracefully truncate if the text is too long."
      },
      "typeVersion": 1
    },
    {
      "id": "4d639833-bb9d-447a-9331-f44d20446864",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3408,
        240
      ],
      "parameters": {
        "color": 4,
        "width": 352,
        "height": 368,
        "content": "## Send Response  (HTTP \u2192 Graph API)\n\nPosts the JSON to /v17.0/me/messages?access_token=PAGE_TOKEN with Content-Type: application/json. On errors (401/403/429), check token/permissions and inspect the node logs."
      },
      "typeVersion": 1
    },
    {
      "id": "5a7944b5-13d4-4fc5-9c68-2430516912dd",
      "name": "Sticky Note14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1952,
        240
      ],
      "parameters": {
        "color": 3,
        "width": 688,
        "height": 624,
        "content": "## AI Agent + Chat Model + Memory + Tools\n\nThe agent reads user_prompt, applies your System Message, queries the chat model (pick the model and tune temperature / max tokens), and optionally calls Calculator/Wikipedia to produce output. Enable per-user memory (PSID) with sessionId = sender.id to keep context across turns."
      },
      "typeVersion": 1
    },
    {
      "id": "38a8016e-1df7-4337-a8a0-5db52b8e144d",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -976,
        -96
      ],
      "parameters": {
        "width": 416,
        "height": 1008,
        "content": "# Automate Messenger in 6 Steps \u2728\n\nBuild your first Messenger AI agent !\nIt reads text, photos, and voice notes, then answers like a pro.\n\n### 1) Connect credentials\nAdd your OpenAI API key and Facebook Page Access Token in n8n Credentials (keep them secret).\n\n### 2) Plug the webhook\nCopy the Webhook1 Test URL (POST /messenger) \u2192 paste it in Meta \u203a Messenger \u203a Webhooks, verify, and subscribe to messages. Send a test message to your Page.\n\n### 3) Personalize the agent\nIn the AI Agent, write a clear System Message (tone & guardrails), pick the chat model, and tune temperature / max tokens.\n\n### 4) Keep context & add tools\nEnable per-user memory using the PSID so chats persist, and switch on tools like Calculator or Wikipedia if needed.\n\n### 5) Style the replies\nUse asterisks for bold (the post-processor formats it). Keep answers crisp; if media won\u2019t download, ensure the request includes your Page token.\n\n### 6) Ship it\nTest text, photo, and voice note; switch to the Production URL and watch logs/permissions.\n\n## Need help customizing?\n\n\ud83d\udc49 [Get in touch](https://www.linkedin.com/in/st%C3%A9phane-bordas-3439b4179/)\n### Launch your first AI agent on Messenger today ! \ud83d\ude80"
      },
      "typeVersion": 1
    },
    {
      "id": "778d262f-5dfe-4986-9eb0-a94a46a3f771",
      "name": "Sticky Note15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3136,
        -192
      ],
      "parameters": {
        "width": 608,
        "height": 384,
        "content": "## [Video Tutorial](https://youtu.be/yHNPBDNgk88)  \n@[youtube](yHNPBDNgk88)"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "5b201e08-f698-418e-ad26-df60f327cd8a",
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code1": {
      "main": [
        [
          {
            "node": "Send Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook1": {
      "main": [
        [
          {
            "node": "Identify Message Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wikipedia": {
      "ai_tool": [
        [
          {
            "node": "AI Agent Messenger",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Calculator": {
      "ai_tool": [
        [
          {
            "node": "AI Agent Messenger",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields1": {
      "main": [
        [
          {
            "node": "AI Agent Messenger",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields2": {
      "main": [
        [
          {
            "node": "AI Agent Messenger",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields3": {
      "main": [
        [
          {
            "node": "AI Agent Messenger",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze image": {
      "main": [
        [
          {
            "node": "Edit Fields3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent Messenger",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Download Audio": {
      "main": [
        [
          {
            "node": "Audio Transcriber",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Image": {
      "main": [
        [
          {
            "node": "Analyze image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Audio Transcriber": {
      "main": [
        [
          {
            "node": "Edit Fields2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent Messenger",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent Messenger": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Identify Message Type": {
      "main": [
        [
          {
            "node": "Identify and ReRoute Message Types",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Identify and ReRoute Message Types": {
      "main": [
        [
          {
            "node": "Download Image",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download Audio",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow lets you build a Messenger AI Agent capable of understanding text, images, and voice notes, and replying intelligently in real time.

Source: https://n8n.io/workflows/9347/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

This workflow transforms WhatsApp into a powerful personal AI using n8n + Green-API. Send text or voice messages — the assistant understands intent and handles daily tasks automatically. 💰 Expense & i

Tool Calculator, Google Sheets Tool, OpenAI Chat +10
AI & RAG

Universal Expense tracker. Uses telegram, httpRequest, openAi, googleSheets. Webhook trigger; 33 nodes.

Telegram, HTTP Request, OpenAI +7
AI & RAG

LINE Assistant with Google Calendar and Gmail Integration. Uses agent, memoryBufferWindow, lmChatOpenAi, toolWikipedia. Webhook trigger; 14 nodes.

Agent, Memory Buffer Window, OpenAI Chat +5
AI & RAG

This workflow is for small business owners, personal assistants, or project managers who rely on multiple platforms for communication and scheduling. Ideal for users managing customer support, persona

Agent, Memory Buffer Window, OpenAI Chat +5
AI & RAG

My workflow 15. Uses httpRequest, memoryBufferWindow, agent, lmChatOpenAi. Webhook trigger; 74 nodes.

HTTP Request, Memory Buffer Window, Agent +5