{ "name": "Extract Webpage Entities with Google Language", "tags": [ { "id": "hBkrfz3jN0GbUgJa", "name": "Google Page Entity Extraction Template", "createdAt": "2025-05-08T23:29:39.011Z", "updatedAt": "2025-05-08T23:29:39.011Z" } ], "nodes": [ { "id": "8719f1de-2a3e-4c34-9edc-e4b8f993b525", "name": "Respond to Webhook", "type": "n8n-nodes-base.respondToWebhook", "position": [ 1240, -420 ], "parameters": { "options": {} }, "typeVersion": 1.1 }, { "id": "01420fd5-3483-4e74-b9fc-971199898449", "name": "Google Entities", "type": "n8n-nodes-base.httpRequest", "position": [ 1020, -420 ], "parameters": { "url": "https://language.googleapis.com/v1/documents:analyzeEntities", "method": "POST", "options": {}, "jsonBody": "={{ $json.apiRequest }}", "sendBody": true, "specifyBody": "json", "authentication": "genericCredentialType", "genericAuthType": "httpHeaderAuth" }, "typeVersion": 4.2 }, { "id": "79add9a7-adca-4ce5-8a6a-5fcb75288846", "name": "Get Url", "type": "n8n-nodes-base.webhook", "position": [ 360, -420 ], "parameters": { "path": "extract-webpage-entities-with-google-language", "options": {}, "httpMethod": "POST", "responseMode": "responseNode" }, "typeVersion": 2 }, { "id": "081a52bc-2da7-44fb-bdc3-4cb73cbf8dd3", "name": "Get URL Page Contents", "type": "n8n-nodes-base.httpRequest", "position": [ 580, -420 ], "parameters": { "url": "={{ $json.url }}", "options": {} }, "typeVersion": 4.2 }, { "id": "dda5ef3d-f031-4dd6-b117-c1f69aa66b63", "name": "Respond with detected entities", "type": "n8n-nodes-base.code", "position": [ 800, -420 ], "parameters": { "jsCode": "// Clean and prepare HTML for API request\nconst html = $input.item.json.data;\n// Trim if too large (optional)\nconst trimmedHtml = html.length > 100000 ? html.substring(0, 100000) : html;\n\nreturn {\n json: {\n apiRequest: {\n document: {\n type: \"HTML\",\n content: trimmedHtml\n },\n encodingType: \"UTF8\"\n }\n }\n}" }, "typeVersion": 2 }, { "id": "extract-webpage-entities-with-google-language-validate", "name": "Validate the URL", "type": "n8n-nodes-base.code", "typeVersion": 2, "parameters": { "mode": "runOnceForEachItem", "jsCode": "function input({body}){const url=body?.url;if(typeof url!=='string'||!/^https?:\\/\\/[^\\/?#@\\s]+(?:[\\/?#][^\\s]*)?$/i.test(url))throw Error('Provide an HTTP or HTTPS URL without credentials');return {url}}\n\nreturn {json:input({body:$json.body})};" } }, { "id": "extract-webpage-entities-with-google-language-result", "name": "Check the entity response", "type": "n8n-nodes-base.code", "typeVersion": 2, "parameters": { "mode": "runOnceForEachItem", "jsCode": "if (!$json || typeof $json !== \"object\" || Array.isArray($json)) throw Error(\"Expected an entity response object\"); return {json:$json};" } } ], "active": false, "pinData": {}, "settings": { "executionOrder": "v1" }, "connections": { "Get Url": { "main": [ [ { "node": "Validate the URL", "type": "main", "index": 0 } ] ] }, "Google Entities": { "main": [ [ { "node": "Check the entity response", "type": "main", "index": 0 } ] ] }, "Get URL Page Contents": { "main": [ [ { "node": "Respond with detected entities", "type": "main", "index": 0 } ] ] }, "Respond with detected entities": { "main": [ [ { "node": "Google Entities", "type": "main", "index": 0 } ] ] }, "Check the entity response": { "main": [ [ { "node": "Respond to Webhook", "type": "main", "index": 0 } ] ] }, "Validate the URL": { "main": [ [ { "node": "Get URL Page Contents", "type": "main", "index": 0 } ] ] } } }