{
  "name": "FlowPantry - Ask for a Google review after a job is completed",
  "nodes": [
    {
      "id": "a870f7ab-2282-41d9-bbb9-c67e3eb12fb2",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        300
      ],
      "parameters": {
        "httpMethod": "POST",
        "path": "job-completed",
        "responseMode": "onReceived",
        "options": {}
      },
      "webhookId": "887e2109-ef55-472c-b72f-94d357d27d52"
    },
    {
      "id": "4495da7a-006e-4073-b9ec-e077c976f996",
      "name": "Normalize customer",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        240,
        300
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "return $input.all().map(i=>{const b=i.json.body||i.json;return {json:{name:(b.name||'there').split(' ')[0],phone:b.phone,email:b.email,source:b.source||'web form',message:b.message||''}}}).filter(i=>i.json.phone);"
      }
    },
    {
      "id": "b397d474-e41c-464a-9fb3-b0c12dd0e1c2",
      "name": "Wait 2 hours",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        480,
        300
      ],
      "parameters": {
        "amount": 2,
        "unit": "hours"
      }
    },
    {
      "id": "b838c701-f1b8-4c09-943b-d28d9a5bf673",
      "name": "Ask for review",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        720,
        300
      ],
      "parameters": {
        "method": "POST",
        "url": "=https://api.twilio.com/2010-04-01/Accounts/{{$env.TWILIO_ACCOUNT_SID}}/Messages.json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth",
        "sendBody": true,
        "contentType": "form-urlencoded",
        "bodyParameters": {
          "parameters": [
            {
              "name": "To",
              "value": "={{$('Normalize customer').item.json.phone}}"
            },
            {
              "name": "From",
              "value": "={{$env.TWILIO_FROM_NUMBER}}"
            },
            {
              "name": "Body",
              "value": "=Hi {{$('Normalize customer').item.json.name}}, thanks for choosing {{$env.BUSINESS_NAME}}! Would you share a quick review? It really helps us: {{$env.GOOGLE_REVIEW_URL}} Reply STOP to opt out."
            }
          ]
        },
        "options": {}
      }
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Normalize customer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize customer": {
      "main": [
        [
          {
            "node": "Wait 2 hours",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 2 hours": {
      "main": [
        [
          {
            "node": "Ask for review",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {}
}