{ "kind": "open-flow-workflow", "version": 1, "name": "Extract Webpage Entities with Google Language", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_6af224abb9dd9bf8": { "name": "Receive a webpage URL", "kind": "webhook", "bodyFields": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" } ], "method": "POST", "options": { "responseBody": { "kind": "workflow-outputs", "output": "response", "timeoutMs": 60000 }, "responseHeaders": { "Content-Type": "application/json" }, "responseStatusCode": 200 } }, "n_2c35f59997158097": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_6af224abb9dd9bf8", "output": "body" } ] } }, "name": "Validate the URL", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "body" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" } ], "name": "Validate the URL", "moduleId": "n_1eb024caced64d87", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_e9ce41ddb090ccf5": { "inputs": { "initialUrl": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_2c35f59997158097", "output": "url" } ] }, "index": { "kind": "value", "value": 0 }, "previousState": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_72cabe29e8143e97", "output": "state" } ] } }, "name": "Prepare the webpage request", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "initialUrl" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "index" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": true, "handle": "previousState" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" } ], "name": "Prepare the webpage request", "moduleId": "n_738209b722f95700", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_a5bdb7870516719b": { "inputs": { "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_e9ce41ddb090ccf5", "output": "url" } ] } }, "name": "Fetch the webpage", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" } ], "name": "Fetch the webpage", "executor": { "method": "GET", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "none", "authentication": { "type": "none" }, "responseFormat": "text", "statusPolicy": "all", "kind": "http-request" } } }, "n_72cabe29e8143e97": { "inputs": { "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_e9ce41ddb090ccf5", "output": "url" } ] }, "index": { "kind": "value", "value": 0 }, "status": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_a5bdb7870516719b", "output": "statusCode" } ] }, "headers": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_a5bdb7870516719b", "output": "headers" } ] }, "previousState": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_72cabe29e8143e97", "output": "state" } ] } }, "name": "Check the webpage response", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "index" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "status" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": true, "handle": "previousState" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "state" }, { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "redirect" }, { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "alive" } ], "name": "Check the webpage response", "moduleId": "n_4da02c3276a4ffa6", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_ab672f8d4197e883": { "inputs": {}, "name": "Follow a redirect?", "kind": "condition", "matchMode": "first", "cases": [ { "output": "follow", "groups": [ { "expressions": [ { "left": { "kind": "source", "source": { "kind": "node", "nodeId": "n_72cabe29e8143e97", "output": "redirect" } }, "operator": "isTrue" } ] } ] } ] }, "n_22b97f18d3d9b687": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_a5bdb7870516719b", "output": "body" } ] }, "alive": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_72cabe29e8143e97", "output": "alive" } ] } }, "name": "Prepare the HTML document", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "alive" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "request" } ], "name": "Prepare the HTML document", "moduleId": "n_d2e428cb139a27aa", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_c5b7e7c17ab703e8": { "inputs": { "url": { "kind": "value", "value": "https://language.googleapis.com/v1/documents:analyzeEntities" }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_22b97f18d3d9b687", "output": "request" } ] }, "auth.token": { "kind": "unset" } }, "name": "Analyze entities", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "auth.token" } ], "outputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" } ], "name": "Analyze entities", "executor": { "method": "POST", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "json", "authentication": { "type": "apiKey", "name": "X-Goog-Api-Key", "in": "header" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_3cfb59d02ba82fc0": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c5b7e7c17ab703e8", "output": "body" } ] } }, "name": "Check the entity response", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "response" } ], "name": "Check the entity response", "moduleId": "n_9706043d6e5c7bbd", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_02d1e16050dfda9c": { "name": "Return entity analysis", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "response" } ], "outputMappings": { "response": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_3cfb59d02ba82fc0", "output": "response" } ] } } } }, "edges": [ { "source": "n_6af224abb9dd9bf8", "target": "n_2c35f59997158097" }, { "source": "n_2c35f59997158097", "target": "n_e9ce41ddb090ccf5" }, { "source": "n_e9ce41ddb090ccf5", "target": "n_a5bdb7870516719b" }, { "source": "n_a5bdb7870516719b", "target": "n_72cabe29e8143e97" }, { "source": "n_72cabe29e8143e97", "target": "n_ab672f8d4197e883" }, { "source": "n_ab672f8d4197e883", "target": "n_e9ce41ddb090ccf5", "sourceHandle": "follow" }, { "source": "n_ab672f8d4197e883", "target": "n_22b97f18d3d9b687", "sourceHandle": "otherwise" }, { "source": "n_22b97f18d3d9b687", "target": "n_c5b7e7c17ab703e8" }, { "source": "n_c5b7e7c17ab703e8", "target": "n_3cfb59d02ba82fc0" }, { "source": "n_3cfb59d02ba82fc0", "target": "n_02d1e16050dfda9c" } ] } }, "modules": { "n_1eb024caced64d87": { "name": "Validate the URL", "imports": [], "source": "export default 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" }, "n_738209b722f95700": { "name": "Prepare the webpage request", "imports": [], "source": "export default function serverHop({initialUrl,index,previousState}) {\n return {url:previousState?.index===index&&previousState?.nextUrl?previousState.nextUrl:initialUrl};\n}\n" }, "n_4da02c3276a4ffa6": { "name": "Check the webpage response", "imports": [], "source": "export default function assessServer({url,index,status,headers,previousState}) {\n const prior=previousState?.index===index?previousState.hops:0;if(!Number.isInteger(prior)||prior<0)throw Error('Invalid redirect state');\n if((status>=300&&status<400)&&typeof headers?.location==='string'&&headers.location){\n if(prior>=21)return {state:{index,hops:prior,nextUrl:''},redirect:false,alive:false};\n try{const target=new URL(headers.location,url);if(!['http:','https:'].includes(target.protocol)||target.username||target.password)throw Error();return{state:{index,hops:prior+1,nextUrl:target.toString()},redirect:true,alive:false};}catch{return {state:{index,hops:prior,nextUrl:''},redirect:false,alive:false};}\n }\n return {state:{index,hops:prior,nextUrl:''},redirect:false,alive:status>=200&&status<300};\n}\n" }, "n_d2e428cb139a27aa": { "name": "Prepare the HTML document", "imports": [], "source": "export default function html({body,alive}){if(!alive)throw Error('The webpage request did not succeed');if(typeof body!=='string')throw Error('Expected a text webpage');return {request:{document:{type:'HTML',content:body.substring(0,100000)},encodingType:'UTF8'}}}\n" }, "n_9706043d6e5c7bbd": { "name": "Check the entity response", "imports": [], "source": "export default function result({body}){if(!body||typeof body!=='object'||Array.isArray(body))throw Error('Expected an entity response object');return{response:body}}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }