{
  "name": "Book WhatsApp consultations and sync contacts with Airtable and Google Calendar",
  "nodes": [
    {
      "id": "c46f192b-d4f6-4227-979b-d257151a33d9",
      "name": "GET: Verify Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        80,
        144
      ]
    },
    {
      "id": "f70a36e8-e057-42ca-b3cc-a3b3dc868464",
      "name": "Verify Token",
      "type": "n8n-nodes-base.code",
      "position": [
        304,
        144
      ]
    },
    {
      "id": "32acd5a4-c26c-4bf8-9f40-9a49a19dfdac",
      "name": "Return Challenge",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        544,
        144
      ]
    },
    {
      "id": "6283825a-5b66-40d4-94b9-dc9dc24cefb5",
      "name": "Is Regular Message?",
      "type": "n8n-nodes-base.if",
      "position": [
        -128,
        560
      ]
    },
    {
      "id": "525cce30-ed11-4735-9bc3-536d2143efc1",
      "name": "Return 200 OK (Regular Message)",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        784,
        544
      ]
    },
    {
      "id": "d5aeb338-cab9-4e24-a216-cabb36213f46",
      "name": "POST: Receive Messages1",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -576,
        560
      ]
    },
    {
      "id": "c062dd3a-da07-4f8a-954d-d6672a8f422a",
      "name": "Decrypt WhatsApp Request1",
      "type": "n8n-nodes-base.code",
      "position": [
        -352,
        560
      ]
    },
    {
      "id": "b37944ec-53ee-4548-8b1f-7bc2c99a44e1",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -608,
        304
      ],
      "parameters": {
        "width": 416,
        "height": 480,
        "content": "## Whatsapp Single Entry Point: Webhook\n\nBecause of Meta's Single App to Single Webhook restriction, all messages come through the same webhook (GET / POST). \n\nConditional statements after this are th"
      }
    },
    {
      "id": "bfc3eb34-787e-4959-9402-73cc0d218f0a",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        16,
        1136
      ],
      "parameters": {
        "width": 3072,
        "height": 1280,
        "content": "## WhatsApp Flow: Booking\n\nFlows are attached to messaging templates and are activated by the WhatsApp User\n\nAt each stage of the WhatsApp Flow, data is being fed to the experience. E.g Services Avail"
      }
    },
    {
      "id": "d6f2ba59-2038-49ca-8057-1e379baeed25",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32,
        384
      ],
      "parameters": {
        "width": 1296,
        "height": 656,
        "content": "## Intelligent Templating Assignment & Responses\n\nWe want to be able to fire off our template messages and flows that make sense to the customers requests. If they want more information, we can send t"
      }
    },
    {
      "id": "b3551661-9a21-412b-a0b0-b6500d74c05b",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32,
        32
      ],
      "parameters": {
        "width": 704,
        "height": 304,
        "content": "## Utility: WhatsApp Webhook Check\nRequired for setting up your n8n webhook in Meta"
      }
    },
    {
      "id": "9b87e762-c71d-4073-adb5-265a8f262aa1",
      "name": "Return Ping Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        304,
        1312
      ]
    },
    {
      "id": "a9bc81f7-d4c5-4351-abf4-42be2a295e82",
      "name": "Handle INIT - Return Consultation Types",
      "type": "n8n-nodes-base.code",
      "position": [
        304,
        1472
      ]
    },
    {
      "id": "df7e496c-140b-49e8-89ca-e4cd68f07929",
      "name": "Handle Confirm Booking",
      "type": "n8n-nodes-base.code",
      "position": [
        336,
        2016
      ]
    },
    {
      "id": "f4321129-d5bc-4d7b-ae11-6b1e6d7f39d4",
      "name": "Send WhatsApp Confirmation",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2128,
        2224
      ]
    },
    {
      "id": "269f5e8b-ab1b-49cc-b6b1-e4615e79b74a",
      "name": "Merge Paths",
      "type": "n8n-nodes-base.code",
      "position": [
        2480,
        1824
      ]
    },
    {
      "id": "5c9e17c9-00e5-4d04-82ee-6adaed550ff4",
      "name": "Encrypt Response",
      "type": "n8n-nodes-base.code",
      "position": [
        2688,
        1824
      ]
    },
    {
      "id": "dd67e257-f900-4f75-a0a3-61e8b04cbad2",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        2912,
        1824
      ]
    },
    {
      "id": "439fa7ab-c609-4d15-9fed-943e59c5e0d9",
      "name": "Switch on Action",
      "type": "n8n-nodes-base.switch",
      "position": [
        80,
        1328
      ]
    },
    {
      "id": "3e908ab3-eb23-4134-936e-85d4b14cae94",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        144,
        528
      ]
    },
    {
      "id": "95e15ae0-f4c2-489b-887d-3f2f41c73e11",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        352,
        832
      ]
    },
    {
      "id": "52f72a66-1e70-4545-87b4-03f230148e3b",
      "name": "whatsapp_consult_template",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        704,
        832
      ]
    },
    {
      "id": "38e2ebc5-be9c-4a8e-ae25-d922ae1660f2",
      "name": "whatsapp_message_tool",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        528,
        832
      ]
    },
    {
      "id": "9833334d-fd52-4f0e-ab53-cb16e20463f8",
      "name": "Search Existing Customer",
      "type": "n8n-nodes-base.airtable",
      "position": [
        416,
        2224
      ]
    },
    {
      "id": "dc192778-333b-42ec-8726-55a05427efa8",
      "name": "Lookup Service",
      "type": "n8n-nodes-base.airtable",
      "position": [
        1088,
        2224
      ]
    },
    {
      "id": "0b9e6c1e-0106-41dc-b1c8-d0a53492b81b",
      "name": "Prepare Booking Data1",
      "type": "n8n-nodes-base.code",
      "position": [
        208,
        2224
      ]
    },
    {
      "id": "b4b78f14-467e-4c8f-9a04-a24066931bd1",
      "name": "Create Booking in Airtable1",
      "type": "n8n-nodes-base.airtable",
      "position": [
        1312,
        2224
      ]
    },
    {
      "id": "f199a9f1-f6ea-477b-bdd9-61a83a979837",
      "name": "Update Booking with Calendar ID1",
      "type": "n8n-nodes-base.airtable",
      "position": [
        1808,
        2224
      ]
    },
    {
      "id": "62c6c4dd-ab5e-4da9-986b-9625d1d9f4af",
      "name": "Upsert Customer in Airtable",
      "type": "n8n-nodes-base.airtable",
      "position": [
        880,
        2224
      ]
    },
    {
      "id": "70235408-3e69-4bc3-b3c2-3e5c6a492dce",
      "name": "Google Calendar Events (Date)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        544,
        1840
      ]
    },
    {
      "id": "32cff87f-af74-4cae-97e9-acc2830f3cad",
      "name": "Calculate Slots for Date",
      "type": "n8n-nodes-base.code",
      "position": [
        768,
        1840
      ]
    },
    {
      "id": "2ea36a0e-ea3d-4e30-afdf-0ba322f985ea",
      "name": "Prepare Date Refresh Request1",
      "type": "n8n-nodes-base.code",
      "position": [
        336,
        1840
      ]
    },
    {
      "id": "c821c29b-7144-49ae-8a40-528c6ac9d561",
      "name": "Check Customer Exists1",
      "type": "n8n-nodes-base.code",
      "position": [
        640,
        2224
      ]
    },
    {
      "id": "955a58cf-8d98-4eda-83e2-f8d94c88a872",
      "name": "Prepare Success Response1",
      "type": "n8n-nodes-base.code",
      "position": [
        2496,
        2208
      ]
    },
    {
      "id": "2df0aba0-0fb1-42ce-b71b-e3df3c7496f6",
      "name": "Whatsapp Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        352,
        640
      ]
    },
    {
      "id": "8cbbb696-c1fa-4ae7-af16-725b43f6591e",
      "name": "Prepare Calendar Request",
      "type": "n8n-nodes-base.code",
      "position": [
        336,
        1680
      ]
    },
    {
      "id": "04b1b51e-26d8-4c3f-b61b-2af8301dcce2",
      "name": "Google Calendar Events",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        544,
        1680
      ]
    },
    {
      "id": "3711b099-f69e-4fd6-956a-cd62436a68e5",
      "name": "Calculate Available Slots",
      "type": "n8n-nodes-base.code",
      "position": [
        768,
        1680
      ]
    },
    {
      "id": "6fe22c3d-822f-48bc-8dec-59e052db19da",
      "name": "Create an event",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        1520,
        2224
      ]
    },
    {
      "id": "ad24e842-7f34-49c2-b87a-71b8640c9aee",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1200,
        944
      ],
      "parameters": {
        "width": 848,
        "height": 4992,
        "content": "## WhatsApp Flow JSON\nCopy and paste this flow into WhatsApp Flow builder for a simple 30 / 60 min services\n```json\n{\n  \"version\": \"6.0\",\n  \"data_api_version\": \"3.0\",\n  \"routing_model\": {\n    \"SERVICE"
      }
    },
    {
      "id": "5925f871-5a5e-4218-8e82-28ee84f168dc",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1200,
        304
      ],
      "parameters": {
        "width": 528,
        "height": 624,
        "content": "## Book meetings with Whatsapp and sync to Airtable and Google Calendar\n\n#### How it works\n\nThis workflows has an AI Agent that aims to classify a user's intent via WhatsApp Messages, and if they wish"
      }
    }
  ],
  "connections": {
    "Switch": {
      "main": [
        [
          {
            "node": "Return 200 OK (Regular Message)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Return 200 OK (Regular Message)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Whatsapp Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Paths": {
      "main": [
        [
          {
            "node": "Encrypt Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Verify Token": {
      "main": [
        [
          {
            "node": "Return Challenge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Lookup Service": {
      "main": [
        [
          {
            "node": "Create Booking in Airtable1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Whatsapp Agent": {
      "main": [
        [
          {
            "node": "Return 200 OK (Regular Message)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create an event": {
      "main": [
        [
          {
            "node": "Update Booking with Calendar ID1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Encrypt Response": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch on Action": {
      "main": [
        [
          {
            "node": "Return Ping Response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Handle INIT - Return Consultation Types",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare Calendar Request",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare Date Refresh Request1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Handle Confirm Booking",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare Booking Data1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Whatsapp Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "GET: Verify Webhook": {
      "main": [
        [
          {
            "node": "Verify Token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Regular Message?": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Switch on Action",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Booking Data1": {
      "main": [
        [
          {
            "node": "Search Existing Customer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "whatsapp_message_tool": {
      "ai_tool": [
        [
          {
            "node": "Whatsapp Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Check Customer Exists1": {
      "main": [
        [
          {
            "node": "Upsert Customer in Airtable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Calendar Events": {
      "main": [
        [
          {
            "node": "Calculate Available Slots",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Handle Confirm Booking": {
      "main": [
        [
          {
            "node": "Merge Paths",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "POST: Receive Messages1": {
      "main": [
        [
          {
            "node": "Decrypt WhatsApp Request1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate Slots for Date": {
      "main": [
        [
          {
            "node": "Merge Paths",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Calendar Request": {
      "main": [
        [
          {
            "node": "Google Calendar Events",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Existing Customer": {
      "main": [
        [
          {
            "node": "Check Customer Exists1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate Available Slots": {
      "main": [
        [
          {
            "node": "Merge Paths",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Decrypt WhatsApp Request1": {
      "main": [
        [
          {
            "node": "Is Regular Message?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Success Response1": {
      "main": [
        [
          {
            "node": "Merge Paths",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "whatsapp_consult_template": {
      "ai_tool": [
        [
          {
            "node": "Whatsapp Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Send WhatsApp Confirmation": {
      "main": [
        [
          {
            "node": "Prepare Success Response1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Booking in Airtable1": {
      "main": [
        [
          {
            "node": "Create an event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upsert Customer in Airtable": {
      "main": [
        [
          {
            "node": "Lookup Service",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Calendar Events (Date)": {
      "main": [
        [
          {
            "node": "Calculate Slots for Date",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Date Refresh Request1": {
      "main": [
        [
          {
            "node": "Google Calendar Events (Date)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Booking with Calendar ID1": {
      "main": [
        [
          {
            "node": "Send WhatsApp Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Handle INIT - Return Consultation Types": {
      "main": [
        [
          {
            "node": "Merge Paths",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}