{
  "name": "Automated Facebook message response with GPT-4o and Airtable inventory matching",
  "nodes": [
    {
      "id": "3cd8c821-4745-4fa9-b8fb-7c951fdf1c54",
      "name": "Trigger – Fetch New Facebook Messages (Every Hour)",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1024,
        -64
      ]
    },
    {
      "id": "3dc4a4a2-f9cd-4d01-80a2-22a078457b12",
      "name": "Fetch Inventory Records from Airtable",
      "type": "n8n-nodes-base.airtable",
      "position": [
        576,
        -32
      ]
    },
    {
      "id": "7b9c823a-351a-4bea-94e7-a215bb9d1f6c",
      "name": "Fetch Facebook Conversation List",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        -752,
        -64
      ]
    },
    {
      "id": "f2d57f59-96b3-4c83-820c-8d2175f11352",
      "name": "Fetch Facebook Conversation Messages",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        -512,
        -64
      ]
    },
    {
      "id": "fcf51051-636f-44d6-99fa-7dd4c8855635",
      "name": "AI – Extract Product & Customer Intent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        496,
        -704
      ]
    },
    {
      "id": "a63c4fcb-905b-422e-8df9-1d554ea26066",
      "name": "Extract Latest Facebook Message",
      "type": "n8n-nodes-base.code",
      "position": [
        80,
        -64
      ]
    },
    {
      "id": "359cd61d-2dbd-48e5-a1b6-a24ef3dca8fb",
      "name": "Configure GPT-4o — Message Classification Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatAzureOpenAi",
      "position": [
        416,
        -480
      ]
    },
    {
      "id": "d858ed3d-7af7-4c2b-a7f5-4630f994ce76",
      "name": "Merge AI Output With Inventory Dataset",
      "type": "n8n-nodes-base.merge",
      "position": [
        912,
        -48
      ]
    },
    {
      "id": "e09616bd-9039-4c0b-87f7-142b638385ad",
      "name": "Build Combined AI + Inventory Payload (",
      "type": "n8n-nodes-base.code",
      "position": [
        1152,
        -48
      ]
    },
    {
      "id": "3b9f0cd9-7fac-45c1-b283-5f3ed5a9ec87",
      "name": "AI – Match Requested Product in Inventory",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1376,
        -48
      ]
    },
    {
      "id": "39d742d9-b27e-4a9e-b2e3-8e1b6b06aa02",
      "name": "Configure GPT-4o — Product Matching Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatAzureOpenAi",
      "position": [
        1344,
        192
      ]
    },
    {
      "id": "19f65054-e2fb-4edc-9773-c15695179784",
      "name": "Parse AI Product Match JSON",
      "type": "n8n-nodes-base.code",
      "position": [
        1760,
        -48
      ]
    },
    {
      "id": "80acdcee-a973-4587-b452-717fc212f361",
      "name": "Check If Product Exists",
      "type": "n8n-nodes-base.if",
      "position": [
        2000,
        -48
      ]
    },
    {
      "id": "9d6bb1c0-6bde-4d24-9a9a-7d35649fcf78",
      "name": "Send Facebook Reply — Product Found",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        2304,
        -208
      ]
    },
    {
      "id": "0831b1aa-f439-45dc-8045-9c93e3f84f8a",
      "name": "Send Facebook Reply — Product Not Found",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        2352,
        144
      ]
    },
    {
      "id": "e1d901bd-1c0c-494f-9acd-4512fe4d5e0f",
      "name": "Log Invalid Records to Google Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -32,
        208
      ]
    },
    {
      "id": "b431757c-da8b-43b2-8a0f-2999087637ce",
      "name": "Validate Record Structure",
      "type": "n8n-nodes-base.if",
      "position": [
        -224,
        -64
      ]
    },
    {
      "id": "b7009a76-16c1-4acd-97d1-ef6fec236dd7",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1616,
        -1040
      ],
      "parameters": {
        "width": 704,
        "height": 544,
        "content": "## 🤖 AI-Driven Facebook DM → Inventory Matching & Automated Messaging System\n\nThis workflow automatically fetches new Facebook messages, extracts the customer’s intent,\nmatches product names against A"
      }
    },
    {
      "id": "c4e1c663-b5f7-4f39-939b-132e287a4cb7",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -848,
        -288
      ],
      "parameters": {
        "width": 1088,
        "height": 720,
        "content": "## Intake & Validation — Facebook Messages  \nFetches new customer conversations every hour and retrieves the latest message.  \nValidates message structure (id, fields).  \nIf invalid → logs to Google S"
      }
    },
    {
      "id": "91d8cb01-c909-4d23-a14e-1d6de85e0903",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        -880
      ],
      "parameters": {
        "width": 656,
        "height": 560,
        "content": "## AI Intent Understanding — Message Analysis  \nUses GPT-4o to identify the product mentioned, customer intent,  \nand generate a clean structured JSON output.  \nEnsures consistent extraction even with"
      }
    },
    {
      "id": "059a7ff8-b797-42c7-9f47-c05fb5ce4b89",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        512,
        -256
      ],
      "parameters": {
        "width": 1632,
        "height": 608,
        "content": "## Inventory Matching — AI + Airtable Dataset  \nCombines interpreted customer query with full Airtable inventory.  \nAI checks if the requested product exists using clean product-name comparison.  \nOut"
      }
    },
    {
      "id": "757f5e84-57ab-49d0-8da8-f78e6c071c12",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2176,
        -432
      ],
      "parameters": {
        "width": 480,
        "height": 848,
        "content": "## Auto-Reply Delivery — Facebook Messenger  \nSends a real-time automated Messenger reply based on product availability.  \nIf matched → sends product details;  \nIf not → replies with a polite “not ava"
      }
    }
  ],
  "connections": {
    "Check If Product Exists": {
      "main": [
        [
          {
            "node": "Send Facebook Reply — Product Found",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Facebook Reply — Product Not Found",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Record Structure": {
      "main": [
        [
          {
            "node": "Extract Latest Facebook Message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log Invalid Records to Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse AI Product Match JSON": {
      "main": [
        [
          {
            "node": "Check If Product Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Latest Facebook Message": {
      "main": [
        [
          {
            "node": "AI – Extract Product & Customer Intent",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch Inventory Records from Airtable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Facebook Conversation List": {
      "main": [
        [
          {
            "node": "Fetch Facebook Conversation Messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Facebook Conversation Messages": {
      "main": [
        [
          {
            "node": "Validate Record Structure",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Inventory Records from Airtable": {
      "main": [
        [
          {
            "node": "Merge AI Output With Inventory Dataset",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge AI Output With Inventory Dataset": {
      "main": [
        [
          {
            "node": "Build Combined AI + Inventory Payload (",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Combined AI + Inventory Payload (": {
      "main": [
        [
          {
            "node": "AI – Match Requested Product in Inventory",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI – Extract Product & Customer Intent": {
      "main": [
        [
          {
            "node": "Merge AI Output With Inventory Dataset",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI – Match Requested Product in Inventory": {
      "main": [
        [
          {
            "node": "Parse AI Product Match JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Configure GPT-4o — Product Matching Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI – Match Requested Product in Inventory",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Configure GPT-4o — Message Classification Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI – Extract Product & Customer Intent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Trigger – Fetch New Facebook Messages (Every Hour)": {
      "main": [
        [
          {
            "node": "Fetch Facebook Conversation List",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}