{
  "name": "Handling appointment leads and follow-up with Twilio, Cal.com and AI",
  "nodes": [
    {
      "id": "f55b3110-f960-4d89-afba-d47bc58102eb",
      "name": "Twilio Trigger",
      "type": "n8n-nodes-base.twilioTrigger",
      "position": [
        100,
        180
      ]
    },
    {
      "id": "8472f5b0-329f-45ac-b35f-c42558daa7c7",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1140,
        1360
      ]
    },
    {
      "id": "4b3e8a26-c808-46e5-bbcf-2e1279989a0b",
      "name": "Find Follow-Up Candidates",
      "type": "n8n-nodes-base.airtable",
      "position": [
        720,
        1240
      ]
    },
    {
      "id": "04dc979c-ad36-4e57-93d4-905929fe1af0",
      "name": "Send Follow Up Message",
      "type": "n8n-nodes-base.twilio",
      "position": [
        1880,
        1240
      ]
    },
    {
      "id": "55e222af-fb59-4ffd-9661-350b1972e802",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        570,
        943
      ],
      "parameters": {
        "width": 408.6631332343324,
        "height": 515.2449997772154,
        "content": "## Step 6. Filter Open Enquiries from Airtable\n\n### 💡Criteria For Follow Up Candidates\n* No Scheduled Appointment\n* No Request to STOP\n* No Previous Follow-up in Past 3 days\n* Follow-up is less than 3"
      }
    },
    {
      "id": "50d0c632-233b-4b31-b396-3fa603aecd03",
      "name": "Update Follow-Up Count and Date",
      "type": "n8n-nodes-base.airtable",
      "position": [
        1700,
        1240
      ]
    },
    {
      "id": "e1331352-c3da-4586-9d64-4be4dab49748",
      "name": "Create/Update Session",
      "type": "n8n-nodes-base.airtable",
      "position": [
        2240,
        269
      ]
    },
    {
      "id": "de8eaa46-2fe8-4afd-a400-9c528f578d24",
      "name": "Get Existing Chat Session",
      "type": "n8n-nodes-base.airtable",
      "position": [
        740,
        240
      ]
    },
    {
      "id": "16aabbf0-fdf7-4940-a3a3-962e0b877299",
      "name": "Every 24hrs",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        220,
        1160
      ]
    },
    {
      "id": "9471b840-3a59-491d-a309-180d5a69fb7e",
      "name": "Send Reply",
      "type": "n8n-nodes-base.twilio",
      "position": [
        2420,
        269
      ]
    },
    {
      "id": "601aa9ea-f3f4-49bd-a391-84e32c47f7ba",
      "name": "Send Confirmation",
      "type": "n8n-nodes-base.twilio",
      "position": [
        900,
        -280
      ]
    },
    {
      "id": "a8b9fffe-f814-4cb4-9e1a-bf7eb57e7afd",
      "name": "User Request STOP",
      "type": "n8n-nodes-base.airtable",
      "position": [
        660,
        -280
      ]
    },
    {
      "id": "3e7797f0-5449-404c-bac9-e0019223cea8",
      "name": "Check For Command  Words",
      "type": "n8n-nodes-base.switch",
      "position": [
        295,
        180
      ]
    },
    {
      "id": "e636ebb5-16c6-43ef-9fee-fe2b9a8c95a9",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1960,
        560
      ]
    },
    {
      "id": "3469740d-bd2f-4d34-a86b-59b088917d74",
      "name": "Auto-fixing Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserAutofixing",
      "position": [
        1820,
        440
      ]
    },
    {
      "id": "fc0adfdf-724c-45d2-84f6-cb2b43254cc0",
      "name": "OpenAI Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1840,
        560
      ]
    },
    {
      "id": "0e0d8236-0f10-4f8f-88c1-bba2ef084e90",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1080,
        -50.317404874203476
      ],
      "parameters": {
        "width": 1011.8938194478603,
        "height": 917.533068142247,
        "content": "## Step 3. Appointment Scheduling With AI\n[Learn about using AI Agents](https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.agent)\n\nUsing an AI Agent is a powerful wa"
      }
    },
    {
      "id": "380b437e-fa29-4ebb-bebd-1984d371bc93",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        549.8696404310444,
        -49.46972087742148
      ],
      "parameters": {
        "width": 504.0066355303578,
        "height": 557.8466102697549,
        "content": "## Step 2. Check for Existing Chat History\n[Read more about using Airtable](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.airtable)\n\nWe're using Airtable for customer session manag"
      }
    },
    {
      "id": "f89762f5-8520-4af6-987d-a71381c603e3",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        -52.79744987055557
      ],
      "parameters": {
        "width": 523.6927529886705,
        "height": 479.4432905734608,
        "content": "## Step 1. Wait For Customer SMS\n[Read more about Twilio trigger](https://docs.n8n.io/integrations/builtin/trigger-nodes/n8n-nodes-base.twiliotrigger)\n\nFor this workflow, we'll use the twilio SMS trig"
      }
    },
    {
      "id": "de525648-ef11-4b48-85ea-c6e5463c87cf",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        540,
        -450.0217713292123
      ],
      "parameters": {
        "width": 563.7797724327219,
        "height": 358.6710117357418,
        "content": "## Step 9. Cancelling Follow-Up Messages \n\nIf the customer messages the bot with the word STOP, we'll update our customer record in Airtable which will prevent further follow-ups from being trigger. A"
      }
    },
    {
      "id": "028e4253-d1e6-4cf8-b181-ba27b03fa66e",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2120,
        -40
      ],
      "parameters": {
        "width": 521.5259177258192,
        "height": 558.7093446159199,
        "content": "## Step 4. Updating Airtable and Responding to the Customer \n[Read more about using Twilio](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.twilio)\n\nOnce the agent formulates a respo"
      }
    },
    {
      "id": "f321ded9-c5d3-418d-bf1c-e29bf9845098",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        20,
        940
      ],
      "parameters": {
        "width": 509.931737588259,
        "height": 433.74984757777247,
        "content": "## Step 5. Following Up With Open Enquiries\n[Read more about using scheduled trigger](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.scheduletrigger)\n\nThe second half of this workf"
      }
    },
    {
      "id": "4485e39a-3e84-49ee-9d3f-a271a98a330a",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1000,
        940
      ],
      "parameters": {
        "width": 567.1169284476533,
        "height": 601.5572296901626,
        "content": "## Step 7. Generating a Follow-Up Message\n[Read more about Basic LLM Chain](https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.chainllm)\n\nWith our session and chat h"
      }
    },
    {
      "id": "f2d66e44-cf18-4e8f-80d5-e8d03e10e5ff",
      "name": "Generate Follow Up Message",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1140,
        1200
      ]
    },
    {
      "id": "0b93a300-b9ab-4c28-8ac0-fddc49247b74",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1600,
        940
      ],
      "parameters": {
        "width": 496.0833287715134,
        "height": 526.084030034264,
        "content": "## Step 8. Update Follow-Up Properties and Send Message\n[Read more about using Twilio](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.twilio/)\n\nFinally, we'll update our follow-up a"
      }
    },
    {
      "id": "0e022485-9504-416a-8632-edd65df29bf4",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        -80
      ],
      "parameters": {
        "width": 437.0019498737189,
        "height": 511.67220311821393,
        "content": "## Try It Out!\n\n### This workflow implements an appointment scheduling chatbot which is powered by an AI tools agent.\n* Workflow is triggered by Customer enquires sent via SMS\n* Customer session manag"
      }
    },
    {
      "id": "04681629-0221-47fe-b992-0d5791995523",
      "name": "OpenAI Chat Model3",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1120,
        420
      ]
    },
    {
      "id": "7633e3b0-daf3-495d-bcd7-ce0db24a73b9",
      "name": "Get Availability",
      "type": "@n8n/n8n-nodes-langchain.toolHttpRequest",
      "position": [
        1260,
        440
      ]
    },
    {
      "id": "0f814d08-218e-492e-b1f8-63985d583e80",
      "name": "Get Existing Booking",
      "type": "@n8n/n8n-nodes-langchain.toolHttpRequest",
      "position": [
        1560,
        440
      ]
    },
    {
      "id": "36a5a2a7-bb78-4091-8b25-5e9f49628542",
      "name": "Find Existing Booking",
      "type": "@n8n/n8n-nodes-langchain.toolHttpRequest",
      "position": [
        1700,
        440
      ]
    },
    {
      "id": "88ee279d-ed85-4dc6-b42a-5e1e50f3d708",
      "name": "Reschedule Booking",
      "type": "@n8n/n8n-nodes-langchain.toolHttpRequest",
      "position": [
        1560,
        620
      ]
    },
    {
      "id": "ee30c793-d8f4-4e49-9bd1-70e5ac109b68",
      "name": "Cancel Booking",
      "type": "@n8n/n8n-nodes-langchain.toolHttpRequest",
      "position": [
        1700,
        620
      ]
    },
    {
      "id": "d90aa957-30d7-4b29-93b9-acdc86f1cb17",
      "name": "Create a Booking",
      "type": "@n8n/n8n-nodes-langchain.toolHttpRequest",
      "position": [
        1400,
        440
      ]
    },
    {
      "id": "dfcf00ca-8fe1-4517-b64f-fbb4606ab221",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        928.7527821891895,
        600
      ],
      "parameters": {
        "width": 261.1134437946252,
        "height": 168.99242033383513,
        "content": "![alt](https://upload.wikimedia.org/wikipedia/commons/a/a5/Cal.com%2C_Inc._Logo.svg#100x80)\nYou'll need to set a custom Header Auth Credential for Cal.com API v2. See the following doc for more info: "
      }
    },
    {
      "id": "e743b324-ead2-47f8-87c9-2eb969305d4e",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1220,
        420
      ],
      "parameters": {
        "width": 301.851426117099,
        "height": 360.9218237282627,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n### 🚨 Change EventTypeID Here!\n* EventTypeID must be a number.\n* Your event type dictates the allowed duration of the booking.\n* If Event Type set to 30mins and the agent attempts to book"
      }
    },
    {
      "id": "f087e1a4-fffb-44da-afd6-a6277aef84b5",
      "name": "Appointment Scheduling Agent1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1220,
        200
      ]
    }
  ],
  "connections": {
    "Every 24hrs": {
      "main": [
        [
          {
            "node": "Find Follow-Up Candidates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Cancel Booking": {
      "ai_tool": [
        [
          {
            "node": "Appointment Scheduling Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Twilio Trigger": {
      "main": [
        [
          {
            "node": "Check For Command  Words",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create a Booking": {
      "ai_tool": [
        [
          {
            "node": "Appointment Scheduling Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get Availability": {
      "ai_tool": [
        [
          {
            "node": "Appointment Scheduling Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "User Request STOP": {
      "main": [
        [
          {
            "node": "Send Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Follow Up Message",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Auto-fixing Output Parser",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model3": {
      "ai_languageModel": [
        [
          {
            "node": "Appointment Scheduling Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Reschedule Booking": {
      "ai_tool": [
        [
          {
            "node": "Appointment Scheduling Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get Existing Booking": {
      "ai_tool": [
        [
          {
            "node": "Appointment Scheduling Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Create/Update Session": {
      "main": [
        [
          {
            "node": "Send Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find Existing Booking": {
      "ai_tool": [
        [
          {
            "node": "Appointment Scheduling Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Check For Command  Words": {
      "main": [
        [
          {
            "node": "User Request STOP",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Existing Chat Session",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Auto-fixing Output Parser",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Auto-fixing Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Appointment Scheduling Agent1",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Find Follow-Up Candidates": {
      "main": [
        [
          {
            "node": "Generate Follow Up Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Existing Chat Session": {
      "main": [
        [
          {
            "node": "Appointment Scheduling Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Follow Up Message": {
      "main": [
        [
          {
            "node": "Update Follow-Up Count and Date",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Appointment Scheduling Agent1": {
      "main": [
        [
          {
            "node": "Create/Update Session",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Follow-Up Count and Date": {
      "main": [
        [
          {
            "node": "Send Follow Up Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}