{
  "name": "Missed-call text-back (Real estate agents)",
  "nodes": [
    {
      "id": "fcdc5832-daaa-54bc-943a-16cff3b9273b",
      "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": "af9e317e-0bf8-5240-b1f0-fbf033b5bd49"
    },
    {
      "id": "61217d67-4b6e-55c8-92b3-e46b502c835a",
      "name": "Incoming text",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        300
      ],
      "parameters": {
        "httpMethod": "POST",
        "path": "incoming-sms",
        "responseMode": "responseNode",
        "options": {}
      },
      "webhookId": "71f61b27-a86f-5579-a6c5-1200967caf95"
    },
    {
      "id": "6aacc76e-fb72-5758-90fb-9dea4ac84e1e",
      "name": "Config (edit me)",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        140
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "6d2ca97f-d77a-5931-a4b1-793043c745e4",
              "name": "business_name",
              "value": "YOUR BUSINESS NAME",
              "type": "string"
            },
            {
              "id": "9f7a42d9-0400-5cf7-a037-d0aec7049556",
              "name": "booking_link",
              "value": "https://YOUR-BOOKING-LINK",
              "type": "string"
            },
            {
              "id": "d32b1df0-1578-5a7b-839d-9703153c2e97",
              "name": "hours",
              "value": "Mon-Fri 8am-6pm",
              "type": "string"
            },
            {
              "id": "7492d360-2af4-5b48-826f-a4778f6e2d72",
              "name": "owner_email",
              "value": "you@example.com",
              "type": "string"
            },
            {
              "id": "a5058b90-56ba-5445-b7fc-d44a4002eb2f",
              "name": "owner_cell",
              "value": "+15555550100",
              "type": "string"
            },
            {
              "id": "2751ae10-77d1-533a-89ad-7f5a8f53616d",
              "name": "twilio_number",
              "value": "+15555550199",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      }
    },
    {
      "id": "1ca04373-3a8e-598e-b3ec-cac541676ae3",
      "name": "Call or text?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        440,
        140
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "0fc010d2-9e58-5316-bcbc-9714c6d85302",
              "leftValue": "={{ $json.body.DialCallStatus }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "c39a02de-88d2-5e74-be5c-31674daf438a",
      "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": "0f1271ce-fbb3-5d74-8322-3db6410eb8ac",
      "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": "487c9af3-8e41-573a-b9b9-1f5a3032ecf1",
              "leftValue": "={{ $('Call ended (from Twilio)').item.json.body.DialCallStatus }}",
              "rightValue": "completed",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "d402089f-36f4-50d5-b391-d550ea59cae2",
      "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, it's {{ $('Config (edit me)').item.json.business_name }}. Sorry I missed you, I'm probably at a showing. Are you looking to buy, sell, or asking about a specific home? Reply here and I'll get right back to you.",
        "options": {}
      },
      "credentials": {
        "twilioApi": {
          "id": "REPLACE_TWILIO_CREDENTIAL",
          "name": "Twilio account (placeholder)"
        }
      }
    },
    {
      "id": "8cd542d7-85d5-56bb-8df0-82165c045905",
      "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": "c9567626-b9ea-563e-9bee-fb06cb16412e",
      "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": "06ca9394-8514-55c9-a3e3-f7ddd6b41fd6",
      "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 assistant to a local real estate agent. Write one short, friendly SMS reply (under 300 characters) to a new lead. If they asked about a specific property, acknowledge it and offer to set up a showing. Ask one simple question (timeline, or pre-approved yes/no). Do not give legal, financial or pricing advice, do not make claims about schools, neighborhoods or demographics. Sign with the agent's name.",
              "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": "620d95ec-d5a9-5918-8afe-8c181f677427",
      "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": "65b4687b-2d81-5fce-816f-329227c3ec34",
      "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": "d914e766-54d6-5340-a200-2e3412e4735a",
      "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": []
}