"Prepare Data": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Merge Summary & Prepare Update",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }    "Prepare Data": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Merge Summary & Prepare Update",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }{
  "name": "Twitter_Bookmarks_Google_Sheets",
  "nodes": [
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "your-google-sheet-id-here",
          "mode": "list",
          "cachedResultName": "Your Tweet Data Sheet"
        },
        "sheetName": {
          "__rl": true,
          "value": "Sheet1",
          "mode": "list",
          "cachedResultName": "Sheet1"
        },
        "columnToMatchOn": "A",
        "valueInputMode": "defineBelow",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "summary",
              "fieldValue": "={{ $json.summary }}"
            },
            {
              "fieldId": "category",
              "fieldValue": "={{ $json.category }}"
            }
          ]
        },
        "options": {}
      },
      "id": "update-google-sheets",
      "name": "Update Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.4,
      "position": [
        576,
        50
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "your-google-sheets-credential-id",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "functionCode": "return items.map((item, index) => {\n  let parsed = {};\n\n  try {\n    parsed = JSON.parse(item.json.output);  // parse JSON string returned by AI\n  } catch (err) {\n    parsed.summary = '';\n    parsed.category = 'Uncategorized';\n  }\n\n  return {\n    json: {\n      ...item.json,  // keep all original Google Sheets data\n      summary: parsed.summary || '',\n      category: parsed.category || 'Uncategorized',\n      row_number: index + 2 // +2 because sheets are 1-indexed and we skip header\n    }\n  };\n});\n"
      },
      "id": "f5d40a36-3a47-414b-95db-bdabf0ce019f",
      "name": "Process AI Results",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        356,
        50
      ]
    },
    {
      "parameters": {
        "operation": "read",
        "documentId": {
          "__rl": true,
          "value": "your-google-sheet-id-here",
          "mode": "list",
          "cachedResultName": "Your Tweet Data Sheet"
        },
        "sheetName": {
          "__rl": true,
          "value": "Sheet1",
          "mode": "list",
          "cachedResultName": "Sheet1"
        },
        "options": {
          "range": "A:Z"
        }
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.4,
      "position": [
        -260,
        50
      ],
      "id": "read-google-sheets",
      "name": "Read Google Sheets",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "your-google-sheets-credential-id",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Your task is to summarize and categorize tweets.\n\nEach input includes a field \"full_text\" with the tweet's content. The tweets may contain links, hashtags, mentions, or other metadata.\n\nInstructions:\n1. Summarize the tweet in 1–2 clear, concise sentences.\n2. Identify a **category** (such as: AI, Crypto, Business, Marketing, Productivity, Politics, Sports, Other).\n3. Output your result in **JSON format** like this:\n\n{\n  \"summary\": \"your summary here\",\n  \"category\": \"your category here\"\n}\n\nTweet:\n{{ $json.full_text }}\n",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2,
      "position": [
        -40,
        200
      ],
      "id": "f4a05628-a1b8-44f2-bdc9-66556edd9508",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "typeVersion": 1,
      "position": [
        -80,
        380
      ],
      "id": "db6409fc-8508-4447-8479-96082aa94bcc",
      "name": "OpenRouter Chat Model",
      "credentials": {
        "openRouterApi": {
          "id": "2QH3YhKfaStUQJJp",
          "name": "OpenRouter account"
        }
      }
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "a157ce7d-9365-4498-b572-f22e7f16b1f1",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -480,
        50
      ],
      "id": "7a540c59-7a86-4b53-8bea-ff89d1ae3dae",
      "name": "Webhook",
      "webhookId": "a157ce7d-9365-4498-b572-f22e7f16b1f1"
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "your-google-sheet-id-here",
          "mode": "list",
          "cachedResultName": "Your Tweet Data Sheet"
        },
        "sheetName": {
          "__rl": true,
          "value": "Sheet1",
          "mode": "list",
          "cachedResultName": "Sheet1"
        },
        "options": {
          "range": "A1:Z1"
        },
        "dataMode": "defineBelow",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "summary",
              "fieldValue": "Summary"
            },
            {
              "fieldId": "category", 
              "fieldValue": "Category"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.4,
      "position": [
        576,
        50
      ],
      "id": "add-headers",
      "name": "Add Column Headers",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "your-google-sheets-credential-id",
          "name": "Google Sheets account"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Read Google Sheets": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Update Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Google Sheets": {
      "main": [
        [
          {
            "node": "Add Column Headers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Read Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Data": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Merge Summary & Prepare Update",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "cd781917-3db6-4170-a650-3f5bafcc0d7f",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "0d8c11556f0fd09bf0db8f8b70d04f6ade041dfca163282907a361954d6eb19c"
  },
  "id": "xyVQXfVEO5y0Es9d",
  "tags": [
    {
      "createdAt": "2025-06-09T06:55:09.981Z",
      "updatedAt": "2025-06-09T06:55:09.981Z",
      "id": "aUXiZhoi65uZFwMw",
      "name": "summary"
    }
  ]
}
fix the issues in this code