{
  "id": "NypEKbAcGEmuEpCP",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Google Events API",
  "tags": [],
  "nodes": [
    {
      "id": "28a26329-303d-4f96-803a-4e9f3204f81a",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        -260
      ],
      "parameters": {
        "width": 280,
        "height": 320,
        "content": "\ud83d\udd27 SEARCH CONFIGURATION\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\n\ud83d\udccd Query: \"Events in Texas\"\n\ud83d\udcca Total Events: 20\n\ud83d\ude80 Start Position: 0\n\n\ud83d\udca1 Modify these values:\n- Change location/topic\n- Adjust event count (10 per page)\n- Set pagination start point\n\n\u26a0\ufe0f Note: SerpApi rate limits apply"
      },
      "typeVersion": 1
    },
    {
      "id": "b30e38fa-b991-42cd-be31-3d2b8d427ede",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        180,
        260
      ],
      "parameters": {
        "color": 5,
        "width": 260,
        "height": 280,
        "content": "\ud83c\udf10 SERPAPI INTEGRATION\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\n\ud83d\udd11 Engine: google_events\n\ud83c\udf0d Language: en (English)\n\ud83d\udccd Country: us (United States)\n\n\ud83d\udcc4 Pagination:\n- 10 events per request\n- 2-second delay between calls\n- Auto-calculates max requests\n\n\ud83d\udd10 Requires SerpApi credentials"
      },
      "typeVersion": 1
    },
    {
      "id": "c266ccf6-c412-4d70-97d7-55ce07fda254",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        440,
        -260
      ],
      "parameters": {
        "color": 4,
        "height": 320,
        "content": "\u2699\ufe0f DATA TRANSFORMATION\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\n\ud83d\udcdd Flattens nested event data\n\ud83c\udff7\ufe0f Adds search query to each event\n\ud83d\udd04 Combines multiple API responses\n\n\ud83d\udcca Output Fields:\n- title, link, description\n- start_date, when, address\n- venue, ticket_info, image\n- event_location_map, query"
      },
      "typeVersion": 1
    },
    {
      "id": "a9423400-c246-49fa-8954-2ab6a23e561a",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        120,
        -540
      ],
      "parameters": {
        "color": 3,
        "width": 380,
        "height": 260,
        "content": "\ud83c\udfaf GOOGLE EVENTS SCRAPER\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\n\ud83d\udd0d Searches Google Events via SerpApi\n\ud83d\udcca Extracts event details automatically\n\ud83d\udcbe Saves to Google Sheets for analysis\n\n\u23f1\ufe0f Runtime: ~30-60 seconds\n\ud83d\udcc8 Scalable: Adjust event count as needed\n\ud83d\udd04 Manual trigger for on-demand runs"
      },
      "typeVersion": 1
    },
    {
      "id": "09315e90-1e0b-4dc2-8257-c9240591e514",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        640,
        240
      ],
      "parameters": {
        "width": 340,
        "height": 220,
        "content": "\ud83d\udccb GOOGLE SHEETS OUTPUT\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\n\ud83d\udcc4 Sheet: \"Google Events API\"\n\ud83d\udcca Tab: \"Sheet1\"\n\u2705 Mode: Append rows\n\n\ud83d\udd17 [Spreadsheet](https://docs.google.com/spreadsheets/d/1DQo3tI8yKzCbLn-DWN2hureHgwj1XxvM1ogES1_77ts/edit?usp=sharing): (**Make a Copy of the Sheet**)\n\n\ud83d\udd10 Requires Google Sheets OAuth"
      },
      "typeVersion": 1
    },
    {
      "id": "d6b61e68-aee6-415e-b68b-40bcba2cbc33",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -180,
        80
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "7ff33746-1a70-473a-918c-0973e8df9b56",
      "name": "Set Search Parameters",
      "type": "n8n-nodes-base.set",
      "position": [
        40,
        80
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "{\n  \"query\": \"Events in Texas\",\n  \"total_events\": 10,\n  \"start\": 0\n}\n"
      },
      "typeVersion": 3.4
    },
    {
      "id": "0aafd123-2beb-4dcc-b9a5-3180dda8e0ef",
      "name": "SerpApi Events Request",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        260,
        80
      ],
      "parameters": {
        "url": "https://serpapi.com/search",
        "options": {
          "pagination": {
            "pagination": {
              "parameters": {
                "parameters": [
                  {
                    "name": "start",
                    "value": "={{ $json.start }}"
                  }
                ]
              },
              "maxRequests": "={{ $json.total_events/10 }}",
              "requestInterval": 2000,
              "limitPagesFetched": true
            }
          }
        },
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "engine",
              "value": "google_events"
            },
            {
              "name": "q",
              "value": "={{ $json.query }}"
            },
            {
              "name": "hl",
              "value": "en"
            },
            {
              "name": "gl",
              "value": "us"
            }
          ]
        }
      },
      "credentials": {
        "httpQueryAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2,
      "alwaysOutputData": false
    },
    {
      "id": "56757e55-daf1-4791-a7de-43ee59b4fa10",
      "name": "Process & Flatten Events",
      "type": "n8n-nodes-base.code",
      "position": [
        480,
        80
      ],
      "parameters": {
        "jsCode": "const allItems = $input.all();\nlet flattenedEvents = [];\n\nfor (const item of allItems) {\n  const events = item.json.events_results || [];\n  const query = item.json.search_parameters?.q || \"\";\n\n  for (const event of events) {\n    // Add query to each event object\n    flattenedEvents.push({\n      json: {\n        ...event,\n        query: query\n      }\n    });\n  }\n}\n\nreturn flattenedEvents;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "63d157da-a93e-4fc6-88ae-133fb8d52915",
      "name": "Save to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        700,
        80
      ],
      "parameters": {
        "columns": {
          "value": {
            "link": "={{ $json.link }}",
            "when": "={{ $json.date.when }}",
            "image": "={{ $json.image }}",
            "query": "={{ $json.query }}",
            "title": "={{ $json.title }}",
            "venue": "={{ $json.venue }}",
            "address": "={{ $json.address }}",
            "start_date": "={{ $json.date.start_date }}",
            "description": "={{ $json.description }}",
            "ticket_info": "={{ $json.ticket_info }}",
            "event_location_map": "={{ $json.event_location_map.link }}"
          },
          "schema": [
            {
              "id": "title",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "start_date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "start_date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "when",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "when",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "address",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "link",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "link",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "event_location_map",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "event_location_map",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ticket_info",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "ticket_info",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "venue",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "venue",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "query",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "query",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "description",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "image",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "image",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1DQo3tI8yKzCbLn-DWN2hureHgwj1XxvM1ogES1_77ts/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1DQo3tI8yKzCbLn-DWN2hureHgwj1XxvM1ogES1_77ts",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1DQo3tI8yKzCbLn-DWN2hureHgwj1XxvM1ogES1_77ts/edit?usp=drivesdk",
          "cachedResultName": "Google Events API"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "ff103f52-d64b-4303-b4f0-9334ee7aac05",
  "connections": {
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Set Search Parameters",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Search Parameters": {
      "main": [
        [
          {
            "node": "SerpApi Events Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SerpApi Events Request": {
      "main": [
        [
          {
            "node": "Process & Flatten Events",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process & Flatten Events": {
      "main": [
        [
          {
            "node": "Save to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}