{
  "id": "oHDzsXTId3JdBT70",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Find address photo",
  "tags": [],
  "nodes": [
    {
      "id": "4365a575-70a6-4e81-8ab1-10711bc9fc39",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -96,
        -48
      ],
      "parameters": {
        "options": {
          "appendAttribution": false
        },
        "formTitle": "Street View Locator",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Search Address",
              "placeholder": "e.g. 1600 Amphitheatre Pkwy, Mountain View, CA",
              "requiredField": true
            }
          ]
        },
        "formDescription": "Enter a physical address to retrieve its corresponding street view or location photo."
      },
      "typeVersion": 2.3
    },
    {
      "id": "9c29baa3-90b2-4cd7-9155-5b7e8a8c3c67",
      "name": "Prepare API request data",
      "type": "n8n-nodes-base.set",
      "position": [
        112,
        -48
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "8a6cac17-a468-4d0f-bc8d-c14c6094a983",
              "name": "address",
              "type": "string",
              "value": "={{ $json[\"Search Address\"] }}"
            },
            {
              "id": "09df1334-704f-41de-89e0-257e115903b8",
              "name": "api_key",
              "type": "string",
              "value": "YOU_API_KEY_HERE"
            }
          ]
        }
      },
      "typeVersion": 3.4,
      "alwaysOutputData": true
    },
    {
      "id": "04f016ee-f895-4b01-94e4-12bfce6db96f",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -544,
        -240
      ],
      "parameters": {
        "width": 384,
        "height": 864,
        "content": "## Validate Address + Generate Street View\n\nThis workflow allows users to generate a Street View image from any address using Google Maps APIs.\n\nA form collects the address input, which is then validated using the Geocoding API. If valid, the workflow extracts coordinates, retrieves the Street View image, stores it in Google Drive, and returns a visual response page.\n\nError handling is included to manage invalid addresses or unavailable Street View images, ensuring a reliable and user-friendly experience.\n\n\n## How it works\n\n1. User submits an address through the form  \n2. The address is validated using Google Geocoding API  \n3. Latitude and longitude are extracted  \n4. The Street View image is requested using coordinates  \n5. The image is validated and uploaded to Google Drive  \n6. A response page is generated (success or error)  \n\n\n## Setup steps\n\n1. Create a Google Maps API key (Geocoding + Street View enabled)  \n2. Add your API key in the workflow (or use environment variables)  \n3. Connect your Google Drive credentials  \n4. Adjust image size if needed (default: 600x400)  \n5. Activate the workflow and test using the form  \n"
      },
      "typeVersion": 1
    },
    {
      "id": "f8d574b8-57cc-47d6-94f7-d055d02eab41",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -144,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 384,
        "height": 240,
        "content": "## User input"
      },
      "typeVersion": 1
    },
    {
      "id": "c0cdddd4-8bd0-4e7a-9236-fe932789f9da",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 368,
        "height": 240,
        "content": "## Address validation"
      },
      "typeVersion": 1
    },
    {
      "id": "12675083-0a24-4c6c-9670-b8f6e02efad7",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        720,
        144
      ],
      "parameters": {
        "color": 7,
        "width": 576,
        "height": 224,
        "content": "## Error handling"
      },
      "typeVersion": 1
    },
    {
      "id": "1b936887-7b5d-4350-b57c-7c8ba7d4449d",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        640,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 416,
        "height": 240,
        "content": "## Process location data"
      },
      "typeVersion": 1
    },
    {
      "id": "1835a113-0b23-43be-8fa1-ba7c53df82bc",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1488,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 192,
        "height": 240,
        "content": "## Store image"
      },
      "typeVersion": 1
    },
    {
      "id": "82b95f26-8532-4917-8d7c-3725a857eea2",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1696,
        -112
      ],
      "parameters": {
        "color": 7,
        "height": 240,
        "content": "## Generate response page"
      },
      "typeVersion": 1
    },
    {
      "id": "c012ac1f-96ba-4556-b76b-2fa6d7ee5d2d",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1072,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 240,
        "content": "## Retrieve street view"
      },
      "typeVersion": 1
    },
    {
      "id": "f469884d-4007-4963-866f-7748969536f2",
      "name": "Erro address",
      "type": "n8n-nodes-base.set",
      "position": [
        752,
        192
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={\n  \"error\": \"Address not found\",\n  \"input\": \"{{ $json.address }}\"\n}\n"
      },
      "typeVersion": 3.4
    },
    {
      "id": "efeacd8b-950c-43f4-b1a6-0b8104d435a7",
      "name": "Erro image",
      "type": "n8n-nodes-base.set",
      "position": [
        912,
        192
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={\n  \"error\": \"Street View not available for this location\"\n}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "a567d867-2ae9-42f8-87e9-10714bb2c96e",
      "name": "Geocode address",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        304,
        -48
      ],
      "parameters": {
        "url": "https://maps.googleapis.com/maps/api/geocode/json",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "address",
              "value": "={{ $json.address }}"
            },
            {
              "name": "key",
              "value": "={{ $json.api_key }}"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "ccab8d9a-a683-42fe-b264-00b11524bb7d",
      "name": "Validate address",
      "type": "n8n-nodes-base.if",
      "position": [
        496,
        -48
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "49b7008e-47a0-4622-a8e8-0cb860bf32f6",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.results }}",
              "rightValue": ""
            },
            {
              "id": "7d664f05-9dcc-4c4d-a741-114ab48a31a4",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "OK"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "e5f0a37d-df92-424e-b972-fed0c56e9e5e",
      "name": "Format coordinates",
      "type": "n8n-nodes-base.set",
      "position": [
        912,
        -48
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={\n  \"location\": \"{{ $json.lat + ',' + $json.lng }}\"\n}\n"
      },
      "typeVersion": 3.4
    },
    {
      "id": "1b1d02ba-7914-47e5-a703-25c5be317c80",
      "name": "Extract location data",
      "type": "n8n-nodes-base.set",
      "position": [
        704,
        -48
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={\n  \"address\": \"{{ $json.results[0].formatted_address }}\",\n  \"lat\": {{ $json.results[0].geometry.location.lat }},\n  \"lng\": {{ $json.results[0].geometry.location.lng }},\n  \"place_id\": \"{{ $json.results[0].place_id }}\"\n}\n"
      },
      "typeVersion": 3.4
    },
    {
      "id": "e43196a8-1c8a-42d0-bc3e-a080b29b2fd4",
      "name": "Get street view image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1120,
        -48
      ],
      "parameters": {
        "url": "https://maps.googleapis.com/maps/api/streetview",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        },
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "size",
              "value": "600x400"
            },
            {
              "name": "location",
              "value": "={{ $('Prepare API request data').item.json.address }}"
            },
            {
              "name": "key",
              "value": "={{ $('Prepare API request data').item.json.api_key }}"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "6951cd0e-9c65-4c0a-b038-919a1bbd2430",
      "name": "Check street view availability",
      "type": "n8n-nodes-base.if",
      "position": [
        1312,
        -48
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "b7301ef6-f4fe-4444-aea4-91d56b9425ef",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "=={{ $binary.data !== undefined }}",
              "rightValue": ""
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "9ad5974c-f723-415a-a80a-fecfce3256ba",
      "name": "Upload image",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1520,
        -48
      ],
      "parameters": {
        "name": "data",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1OG29vKXBWkc69W3fph5aB4Sp_1Jhn7Ej",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1OG29vKXBWkc69W3fph5aB4Sp_1Jhn7Ej",
          "cachedResultName": "StreetViewImages"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "292b9891-9b60-4e3f-b0b4-e5d849afd5b0",
      "name": "Display page",
      "type": "n8n-nodes-base.html",
      "position": [
        1728,
        -32
      ],
      "parameters": {
        "html": "<!DOCTYPE html>\n<html>\n<head>\n  <title>Redirecting...</title>\n</head>\n<body style=\"font-family: Arial; text-align:center; padding:50px;\">\n\n  <h2>\ud83d\udd04 Processing your request...</h2>\n  <p>You will be redirected shortly.</p>\n\n  <script>\n    window.location.href = \"{{ $json.webViewLink }}\";\n  </script>\n\n  <p>\n    If nothing happens, \n    <a href=\"{{ $json.webViewLink }}\" target=\"_blank\">click here</a>.\n  </p>\n\n</body>\n</html>"
      },
      "typeVersion": 1.2
    },
    {
      "id": "b14ee326-71ff-4a7e-a800-67316404a5cc",
      "name": "Display error page",
      "type": "n8n-nodes-base.html",
      "position": [
        1104,
        192
      ],
      "parameters": {
        "html": "<!DOCTYPE html>\n<html>\n<head>\n  <title>Error</title>\n  <style>\n    body {\n      font-family: Arial;\n      text-align: center;\n      padding: 40px;\n      background-color: #f5f5f5;\n    }\n\n    .container {\n      background: white;\n      padding: 30px;\n      border-radius: 12px;\n      max-width: 600px;\n      margin: auto;\n      box-shadow: 0 4px 12px rgba(0,0,0,0.1);\n    }\n\n    .error {\n      color: #d9534f;\n      font-size: 22px;\n      margin-bottom: 20px;\n    }\n\n    .details {\n      color: #555;\n      margin-top: 10px;\n    }\n\n    a button {\n      padding: 10px 20px;\n      margin-top: 20px;\n      cursor: pointer;\n      border: none;\n      border-radius: 6px;\n      background-color: #007BFF;\n      color: white;\n      font-weight: bold;\n    }\n  </style>\n</head>\n\n<body>\n  <div class=\"container\">\n\n    <div class=\"error\">\u274c Something went wrong</div>\n\n    <p>{{ $json.error }}</p>\n\n    <div class=\"details\">\n      {{ $json.input ? \"Input: \" + $json.input : \"\" }}\n    </div>\n\n    <br>\n\n    <a href=\"javascript:history.back()\">\n      <button>\ud83d\udd19 Try Again</button>\n    </a>\n\n  </div>\n</body>\n</html>"
      },
      "typeVersion": 1.2
    }
  ],
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "02b2f558-3a1c-48b2-ac3f-c6334fa6844c",
  "connections": {
    "Erro image": {
      "main": [
        [
          {
            "node": "Display error page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Display page": {
      "main": [
        []
      ]
    },
    "Erro address": {
      "main": [
        [
          {
            "node": "Display error page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload image": {
      "main": [
        [
          {
            "node": "Display page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Geocode address": {
      "main": [
        [
          {
            "node": "Validate address",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate address": {
      "main": [
        [
          {
            "node": "Extract location data",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Erro address",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format coordinates": {
      "main": [
        [
          {
            "node": "Get street view image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Prepare API request data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract location data": {
      "main": [
        [
          {
            "node": "Format coordinates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get street view image": {
      "main": [
        [
          {
            "node": "Check street view availability",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare API request data": {
      "main": [
        [
          {
            "node": "Geocode address",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check street view availability": {
      "main": [
        [
          {
            "node": "Upload image",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Erro image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}