{
  "name": "Missed-call text-back (Dental practices)",
  "nodes": [
    {
      "id": "815247e8-3fe3-5368-a3b9-259451c21ea7",
      "name": "Call ended (from Twilio)",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        0
      ],
      "parameters": {
        "httpMethod": "POST",
        "path": "missed-call",
        "responseMode": "responseNode",
        "options": {}
      },
      "webhookId": "fe6cf748-545a-56ce-ac34-2ab5558e7134"
    },
    {
      "id": "6b96d8d6-34e7-579e-b017-411fadd9c27b",
      "name": "Incoming text",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        300
      ],
      "parameters": {
        "httpMethod": "POST",
        "path": "incoming-sms",
        "responseMode": "responseNode",
        "options": {}
      },
      "webhookId": "3e08933a-fab7-5a9c-974d-c96139f15a31"
    },
    {
      "id": "df42a119-9327-57b6-acc8-ee2363f6f9cd",
      "name": "Config (edit me)",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        140
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "18296aca-104a-543e-8979-435f637459cb",
              "name": "business_name",
              "value": "YOUR BUSINESS NAME",
              "type": "string"
            },
            {
              "id": "f308fc95-00aa-53cf-ab92-c64fa4f9bf6d",
              "name": "booking_link",
              "value": "https://YOUR-BOOKING-LINK",
              "type": "string"
            },
            {
              "id": "61f895f6-fef1-53c3-9667-65ea89a91c15",
              "name": "hours",
              "value": "Mon-Fri 8am-6pm",
              "type": "string"
            },
            {
              "id": "e95f3610-36cd-5f81-95ec-64a64322888e",
              "name": "owner_email",
              "value": "you@example.com",
              "type": "string"
            },
            {
              "id": "eaa56915-a873-5f71-9284-ff6d8586ccbe",
              "name": "owner_cell",
              "value": "+15555550100",
              "type": "string"
            },
            {
              "id": "f4aafd3d-ad39-5504-b963-b1730a6fc5b8",
              "name": "twilio_number",
              "value": "+15555550199",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      }
    },
    {
      "id": "354dff82-5f20-5be2-b952-3a5e7daa913a",
      "name": "Call or text?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        440,
        140
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "e2e0b830-8ae9-5d28-8edb-28fdf1375b1c",
              "leftValue": "={{ $json.body.DialCallStatus }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "b40bcb48-ccd7-5488-9acc-0f08d6c3d4d5",
      "name": "Tell Twilio what to say",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        660,
        0
      ],
      "parameters": {
        "respondWith": "text",
        "responseBody": "={{ $json.body.DialCallStatus === 'completed' ? '<Response><Hangup/></Response>' : '<Response><Say>Sorry we missed you. We are texting you right now.</Say><Hangup/></Response>' }}",
        "options": {
          "responseHeaders": {
            "entries": [
              {
                "name": "Content-Type",
                "value": "text/xml"
              }
            ]
          }
        }
      }
    },
    {
      "id": "6a928055-7c88-5594-812a-14a9a1429988",
      "name": "Was the call missed?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        880,
        0
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "348caaf7-a15b-5e14-a59f-678fac1be2e6",
              "leftValue": "={{ $('Call ended (from Twilio)').item.json.body.DialCallStatus }}",
              "rightValue": "completed",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "2e6f4ff2-b2ed-5064-9e38-fb85f8f38cbf",
      "name": "Text the caller",
      "type": "n8n-nodes-base.twilio",
      "typeVersion": 1,
      "position": [
        1100,
        0
      ],
      "parameters": {
        "from": "={{ $('Config (edit me)').item.json.twilio_number }}",
        "to": "={{ $('Call ended (from Twilio)').item.json.body.From }}",
        "message": "=Hi, this is {{ $('Config (edit me)').item.json.business_name }}. Sorry we missed your call, we're with a patient. Are you a new or existing patient, and what can we help with? Reply here and we'll get you scheduled. Book anytime: {{ $('Config (edit me)').item.json.booking_link }}",
        "options": {}
      },
      "credentials": {
        "twilioApi": {
          "id": "REPLACE_TWILIO_CREDENTIAL",
          "name": "Twilio account (placeholder)"
        }
      }
    },
    {
      "id": "5783625c-b4b7-500c-aef9-a4bfd876567b",
      "name": "Email the owner",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1320,
        0
      ],
      "parameters": {
        "sendTo": "={{ $('Config (edit me)').item.json.owner_email }}",
        "subject": "=Missed call from {{ $('Call ended (from Twilio)').item.json.body.From }}",
        "emailType": "text",
        "message": "=We missed a call from {{ $('Call ended (from Twilio)').item.json.body.From }} and texted them automatically. Call them back when you can.",
        "options": {}
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "REPLACE_GMAIL_CREDENTIAL",
          "name": "Gmail account (placeholder)"
        }
      }
    },
    {
      "id": "15ab697e-c659-585d-8167-2b80e3276807",
      "name": "Acknowledge Twilio (text)",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        660,
        420
      ],
      "parameters": {
        "respondWith": "text",
        "responseBody": "<Response></Response>",
        "options": {
          "responseHeaders": {
            "entries": [
              {
                "name": "Content-Type",
                "value": "text/xml"
              }
            ]
          }
        }
      }
    },
    {
      "id": "da2ed96e-480f-5a50-ac02-ebc98be54dd3",
      "name": "AI writes reply",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        880,
        620
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-5-mini",
          "mode": "id"
        },
        "messages": {
          "values": [
            {
              "content": "You are the friendly front-desk coordinator at a dental practice. Write one short, warm SMS reply (under 300 characters) to someone asking about an appointment. Welcome new patients, offer the online booking link, and say the team will follow up during office hours. Do not give medical or dental advice, do not ask for health details, do not quote prices or insurance coverage. If they mention severe pain, swelling or trauma, tell them to call the office or, if after hours and severe, seek emergency care.",
              "role": "system"
            },
            {
              "content": "=Business: {{ $('Config (edit me)').item.json.business_name }}\nHours: {{ $('Config (edit me)').item.json.hours }}\nBooking link: {{ $('Config (edit me)').item.json.booking_link }}\nCustomer's text: {{ $('Incoming text').item.json.body.Body }}"
            }
          ]
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "REPLACE_OPENAI_CREDENTIAL",
          "name": "OpenAI account (placeholder)"
        }
      }
    },
    {
      "id": "326f316f-7338-5285-ad90-6d13a718f109",
      "name": "Text the AI reply",
      "type": "n8n-nodes-base.twilio",
      "typeVersion": 1,
      "position": [
        1100,
        620
      ],
      "parameters": {
        "from": "={{ $('Config (edit me)').item.json.twilio_number }}",
        "to": "={{ $('Incoming text').item.json.body.From }}",
        "message": "={{ $json.message.content }}",
        "options": {}
      },
      "credentials": {
        "twilioApi": {
          "id": "REPLACE_TWILIO_CREDENTIAL",
          "name": "Twilio account (placeholder)"
        }
      }
    },
    {
      "id": "9a7702cc-ff53-5047-83e1-af11f15f312a",
      "name": "Email owner about the text",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1320,
        620
      ],
      "parameters": {
        "sendTo": "={{ $('Config (edit me)').item.json.owner_email }}",
        "subject": "=New text from {{ $('Incoming text').item.json.body.From }}",
        "emailType": "text",
        "message": "=They wrote: {{ $('Incoming text').item.json.body.Body }}\n\nWe auto-replied: {{ $('AI writes reply').item.json.message.content }}",
        "options": {}
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "REPLACE_GMAIL_CREDENTIAL",
          "name": "Gmail account (placeholder)"
        }
      }
    },
    {
      "id": "fe1fd5e1-3ac7-58e2-81ee-3f60d751c7ed",
      "name": "Setup steps",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -520,
        -120
      ],
      "parameters": {
        "content": "## Setup (about 1 hour)\n1. Open **Config (edit me)** and fill in your business name, booking link, hours, email, cell and Twilio number.\n2. Click each node with a red warning and connect your own **Twilio**, **OpenAI**, **Gmail** credentials.\n3. In Twilio, on your number: Voice > 'A call comes in' > TwiML Bin with:\n`<Response><Dial timeout=\"20\" action=\"YOUR_N8N_URL/webhook/missed-call\">+1YOURCELL</Dial></Response>`\n4. Messaging > 'A message comes in' > Webhook `YOUR_N8N_URL/webhook/incoming-sms` (POST).\n5. Register your number for A2P 10DLC in Twilio before texting customers.\n6. Activate the workflow.",
        "height": 440,
        "width": 480
      }
    }
  ],
  "connections": {
    "Call ended (from Twilio)": {
      "main": [
        [
          {
            "node": "Config (edit me)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Incoming text": {
      "main": [
        [
          {
            "node": "Config (edit me)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Config (edit me)": {
      "main": [
        [
          {
            "node": "Call or text?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call or text?": {
      "main": [
        [
          {
            "node": "Tell Twilio what to say",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Acknowledge Twilio (text)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tell Twilio what to say": {
      "main": [
        [
          {
            "node": "Was the call missed?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Was the call missed?": {
      "main": [
        [
          {
            "node": "Text the caller",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Text the caller": {
      "main": [
        [
          {
            "node": "Email the owner",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Acknowledge Twilio (text)": {
      "main": [
        [
          {
            "node": "AI writes reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI writes reply": {
      "main": [
        [
          {
            "node": "Text the AI reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Text the AI reply": {
      "main": [
        [
          {
            "node": "Email owner about the text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false,
    "generatedBy": "Speed-to-Lead Playbooks"
  },
  "tags": []
}