{ "kind": "open-flow-workflow", "version": 1, "name": "Parse a Labeled Email Body", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_3157858c78e9f8b3": { "name": "Enter body and labels", "kind": "start", "inputDefs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "labels" } ] }, "n_8b3af575e37e6c0c": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_3157858c78e9f8b3", "output": "body" } ] }, "labels": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_3157858c78e9f8b3", "output": "labels" } ] } }, "name": "Extract labeled values", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "labels" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "fields" } ], "name": "Extract labeled values", "moduleId": "n_3be66a1898296dfe", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_31ed440cd419c6e9": { "name": "Parsed fields", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "fields" } ], "outputMappings": { "fields": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_8b3af575e37e6c0c", "output": "fields" } ] } } } }, "edges": [ { "source": "n_3157858c78e9f8b3", "target": "n_8b3af575e37e6c0c" }, { "source": "n_8b3af575e37e6c0c", "target": "n_31ed440cd419c6e9" } ] } }, "modules": { "n_3be66a1898296dfe": { "name": "Extract labeled values", "imports": [], "source": "export default function parse({body,labels}){const obj={},names=labels.split(',');names.forEach(function(label){const re=names.indexOf(label)===names.length-1?'\\\\b'+label+'\\\\b[: ]+([^$]+)':'\\\\b'+label+'\\\\b[: ]+([^\\\\n$]+)';const found=body.match(new RegExp(re,'i'));if(found&&found.length>1)obj[label]=found[1].trim()});return{fields:obj}}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }