{
  "name": "Review Request After Service",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "documentId": {
          "__rl": true,
          "value": "YOUR_SPREADSHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "Jobs",
          "mode": "list",
          "cachedResultName": "Jobs"
        },
        "event": "rowUpdate",
        "options": {
          "dataLocationOnSheet": {
            "rangeDefinition": "detectAutomatically"
          }
        }
      },
      "id": "sheets-trigger",
      "name": "Watch for Job Status Changes",
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "typeVersion": 1,
      "position": [220, 300],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "YOUR_GOOGLE_SHEETS_CREDENTIAL_ID",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "status-check",
              "leftValue": "={{ $json.Status || $json.status }}",
              "rightValue": "Complete",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "check-status",
      "name": "Status is Complete?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [440, 300]
    },
    {
      "parameters": {
        "mode": "manual",
        "duplicateItem": false,
        "assignments": {
          "assignments": [
            {
              "id": "customerName",
              "name": "customerName",
              "value": "={{ $json['Customer Name'] || $json.customer_name || $json.name || $json.Name || 'Valued Customer' }}",
              "type": "string"
            },
            {
              "id": "customerEmail",
              "name": "customerEmail",
              "value": "={{ $json['Customer Email'] || $json.email || $json.Email }}",
              "type": "string"
            },
            {
              "id": "serviceType",
              "name": "serviceType",
              "value": "={{ $json['Service Type'] || $json.service || $json.Service || $json.service_type || 'service' }}",
              "type": "string"
            },
            {
              "id": "completedDate",
              "name": "completedDate",
              "value": "={{ $json['Completed Date'] || $json.completed_date || $now.toISO() }}",
              "type": "string"
            },
            {
              "id": "jobId",
              "name": "jobId",
              "value": "={{ $json['Job ID'] || $json.job_id || $json.id || $json.row_number }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "normalize-data",
      "name": "Normalize Customer Data",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [660, 220]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "email-exists",
              "leftValue": "={{ $json.customerEmail }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "check-email",
      "name": "Has Email Address?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [880, 220]
    },
    {
      "parameters": {
        "amount": 2,
        "unit": "days"
      },
      "id": "wait-2-days",
      "name": "Wait 2 Days",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [1100, 140],
      "webhookId": "review-request-wait"
    },
    {
      "parameters": {
        "sendTo": "={{ $('Normalize Customer Data').item.json.customerEmail }}",
        "subject": "How did we do? Your feedback matters to us",
        "emailType": "html",
        "message": "=<div style=\"font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto; padding: 20px;\">\n  <h2 style=\"color: #333;\">Hi {{ $('Normalize Customer Data').item.json.customerName }},</h2>\n  \n  <p style=\"font-size: 16px; color: #555; line-height: 1.6;\">\n    Thank you for choosing us for your {{ $('Normalize Customer Data').item.json.serviceType }}. We hope everything went smoothly!\n  </p>\n  \n  <p style=\"font-size: 16px; color: #555; line-height: 1.6;\">\n    We'd really appreciate it if you could take a minute to share your experience on Google. Your review helps other customers find us and lets us know how we're doing.\n  </p>\n  \n  <p style=\"text-align: center; margin: 30px 0;\">\n    <a href=\"YOUR_GOOGLE_REVIEW_LINK\" style=\"background-color: #4285f4; color: white; padding: 14px 28px; text-decoration: none; border-radius: 5px; font-size: 16px; font-weight: bold;\">Leave a Review on Google</a>\n  </p>\n  \n  <p style=\"font-size: 14px; color: #777; line-height: 1.6;\">\n    Just click the button above—it takes less than a minute. We read every review and genuinely appreciate your feedback.\n  </p>\n  \n  <p style=\"font-size: 16px; color: #555; line-height: 1.6;\">\n    Thanks again for your business!\n  </p>\n  \n  <p style=\"font-size: 14px; color: #777; margin-top: 30px;\">\n    <em>P.S. If there was anything we could have done better, just reply to this email. We'd love to make it right.</em>\n  </p>\n</div>",
        "options": {
          "replyTo": "YOUR_REPLY_TO_EMAIL"
        }
      },
      "id": "send-review-email",
      "name": "Send Review Request Email",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [1320, 140],
      "credentials": {
        "gmailOAuth2": {
          "id": "YOUR_GMAIL_CREDENTIAL_ID",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "YOUR_SPREADSHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "Jobs",
          "mode": "list",
          "cachedResultName": "Jobs"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Review Requested": "={{ $now.format('yyyy-MM-dd') }}"
          },
          "matchingColumns": ["Job ID"],
          "schema": [
            {
              "id": "Job ID",
              "displayName": "Job ID",
              "required": false,
              "defaultMatch": true,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Review Requested",
              "displayName": "Review Requested",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": false
            }
          ]
        },
        "options": {}
      },
      "id": "update-sheet",
      "name": "Mark Review Requested in Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [1540, 140],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "YOUR_GOOGLE_SHEETS_CREDENTIAL_ID",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "status",
              "name": "status",
              "value": "success",
              "type": "string"
            },
            {
              "id": "customer_email",
              "name": "customer_email",
              "value": "={{ $('Normalize Customer Data').item.json.customerEmail }}",
              "type": "string"
            },
            {
              "id": "customer_name",
              "name": "customer_name",
              "value": "={{ $('Normalize Customer Data').item.json.customerName }}",
              "type": "string"
            },
            {
              "id": "review_requested_date",
              "name": "review_requested_date",
              "value": "={{ $now.format('yyyy-MM-dd') }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "set-output",
      "name": "Set Success Output",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [1760, 140]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "skipped_reason",
              "name": "skipped_reason",
              "value": "No email address provided",
              "type": "string"
            },
            {
              "id": "customer_name",
              "name": "customer_name",
              "value": "={{ $('Normalize Customer Data').item.json.customerName }}",
              "type": "string"
            },
            {
              "id": "job_id",
              "name": "job_id",
              "value": "={{ $('Normalize Customer Data').item.json.jobId }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "log-skipped",
      "name": "Log Skipped (No Email)",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [1100, 340]
    }
  ],
  "connections": {
    "Watch for Job Status Changes": {
      "main": [
        [
          {
            "node": "Status is Complete?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Status is Complete?": {
      "main": [
        [
          {
            "node": "Normalize Customer Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Customer Data": {
      "main": [
        [
          {
            "node": "Has Email Address?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Email Address?": {
      "main": [
        [
          {
            "node": "Wait 2 Days",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log Skipped (No Email)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 2 Days": {
      "main": [
        [
          {
            "node": "Send Review Request Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Review Request Email": {
      "main": [
        [
          {
            "node": "Mark Review Requested in Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mark Review Requested in Sheet": {
      "main": [
        [
          {
            "node": "Set Success Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "errorWorkflow": ""
  },
  "staticData": null,
  "meta": {
    "templateCredsSetupCompleted": false,
    "instanceId": "uzunu-automation-templates"
  },
  "pinData": {},
  "versionId": "1",
  "triggerCount": 1,
  "tags": [
    {
      "name": "customer-service",
      "id": "customer-service"
    },
    {
      "name": "email-automation",
      "id": "email-automation"
    },
    {
      "name": "reviews",
      "id": "reviews"
    },
    {
      "name": "google-sheets",
      "id": "google-sheets"
    }
  ]
}
