{ "kind": "open-flow-workflow", "version": 1, "name": "Form Testimonial Capture", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_4dca19fe35a13c31": { "name": "Submitted form feedback", "kind": "webhook", "bodyFields": [ { "jsonSchema": { "type": "object" }, "nullable": false, "handle": "data" } ], "method": "POST", "options": { "responseStatusCode": 200 } }, "n_960c4115d82667c5": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_4dca19fe35a13c31", "output": "body" } ] } }, "name": "Read author and feedback", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object" }, "nullable": false, "handle": "body" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "Author" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "Content" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "Created" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "URL" }, { "jsonSchema": { "type": "object" }, "nullable": false, "handle": "request" } ], "name": "Read author and feedback", "moduleId": "n_215965562a8370c3", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_8ca3f79a0e7c5bfa": { "inputs": { "url": { "kind": "value", "value": "https://language.googleapis.com/v1/documents:analyzeSentiment" }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_960c4115d82667c5", "output": "request" } ] }, "auth.token": { "kind": "unset" } }, "name": "Analyze form sentiment", "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 form sentiment", "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_a67f84773ab60791": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_8ca3f79a0e7c5bfa", "output": "body" } ] } }, "name": "Validate form score", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" } ], "outputs": [ { "jsonSchema": { "type": "number", "minimum": -1, "maximum": 1 }, "nullable": false, "handle": "score" } ], "name": "Validate form score", "moduleId": "n_3ea3fc33f6fa38ad", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_045ac73972c924f8": { "inputs": {}, "name": "Positive enough to capture", "kind": "condition", "matchMode": "first", "cases": [ { "output": "positive", "groups": [ { "expressions": [ { "left": { "kind": "source", "source": { "kind": "node", "nodeId": "n_a67f84773ab60791", "output": "score" } }, "operator": ">", "right": { "kind": "value", "value": 0.4 } } ] } ] } ] }, "n_cf1231bd1471e447": { "inputs": { "Content": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_960c4115d82667c5", "output": "Content" } ] }, "Author": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_960c4115d82667c5", "output": "Author" } ] }, "Created": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_960c4115d82667c5", "output": "Created" } ] }, "URL": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_960c4115d82667c5", "output": "URL" } ] } }, "name": "Select Strapi entry fields", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "Content" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "Author" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "Created" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "URL" } ], "outputs": [ { "jsonSchema": { "type": "object" }, "nullable": false, "handle": "record" }, { "jsonSchema": { "type": "object" }, "nullable": false, "handle": "body" } ], "name": "Select Strapi entry fields", "moduleId": "n_efd6bcb0b6e51600", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_f0b24c66a2961d89": { "inputs": { "url": { "kind": "value", "value": "https://YOUR_STRAPI_HOST/api/posts" }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_cf1231bd1471e447", "output": "body" } ] }, "auth.token": { "kind": "unset" } }, "name": "Create Strapi testimonial", "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": "Create Strapi testimonial", "executor": { "method": "POST", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "json", "authentication": { "type": "bearer" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_51384807b456b08e": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_f0b24c66a2961d89", "output": "body" } ] }, "score": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_a67f84773ab60791", "output": "score" } ] } }, "name": "Confirm captured entry", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "number", "minimum": -1, "maximum": 1 }, "nullable": false, "handle": "score" } ], "outputs": [ { "jsonSchema": { "type": "object", "properties": { "status": { "enum": [ "captured", "ignored" ] }, "score": { "type": "number", "minimum": -1, "maximum": 1 }, "entry": { "type": [ "object", "null" ] } }, "required": [ "status", "score", "entry" ], "additionalProperties": false }, "nullable": false, "handle": "result" } ], "name": "Confirm captured entry", "moduleId": "n_1510a0c28efc80cd", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_07fb13252c1e27a0": { "inputs": { "body": { "kind": "value", "value": null }, "score": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_a67f84773ab60791", "output": "score" } ] } }, "name": "Return ignored feedback", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "number", "minimum": -1, "maximum": 1 }, "nullable": false, "handle": "score" } ], "outputs": [ { "jsonSchema": { "type": "object", "properties": { "status": { "enum": [ "captured", "ignored" ] }, "score": { "type": "number", "minimum": -1, "maximum": 1 }, "entry": { "type": [ "object", "null" ] } }, "required": [ "status", "score", "entry" ], "additionalProperties": false }, "nullable": false, "handle": "result" } ], "name": "Return ignored feedback", "moduleId": "n_db6c2974a6e33b11", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_3ca3aaadc89beaba": { "name": "Capture result", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "object", "properties": { "status": { "enum": [ "captured", "ignored" ] }, "score": { "type": "number", "minimum": -1, "maximum": 1 }, "entry": { "type": [ "object", "null" ] } }, "required": [ "status", "score", "entry" ], "additionalProperties": false }, "nullable": false, "handle": "result" } ], "outputMappings": { "result": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_51384807b456b08e", "output": "result" }, { "kind": "node", "nodeId": "n_07fb13252c1e27a0", "output": "result" } ] } } } }, "edges": [ { "source": "n_4dca19fe35a13c31", "target": "n_960c4115d82667c5" }, { "source": "n_960c4115d82667c5", "target": "n_8ca3f79a0e7c5bfa" }, { "source": "n_8ca3f79a0e7c5bfa", "target": "n_a67f84773ab60791" }, { "source": "n_a67f84773ab60791", "target": "n_045ac73972c924f8" }, { "source": "n_045ac73972c924f8", "target": "n_cf1231bd1471e447", "sourceHandle": "positive" }, { "source": "n_cf1231bd1471e447", "target": "n_f0b24c66a2961d89" }, { "source": "n_f0b24c66a2961d89", "target": "n_51384807b456b08e" }, { "source": "n_045ac73972c924f8", "target": "n_07fb13252c1e27a0", "sourceHandle": "otherwise" }, { "source": "n_51384807b456b08e", "target": "n_3ca3aaadc89beaba" }, { "source": "n_07fb13252c1e27a0", "target": "n_3ca3aaadc89beaba" } ] } }, "modules": { "n_215965562a8370c3": { "name": "Read author and feedback", "imports": [], "source": "export default function prepareTestimonial(inputs) {\n const fields = inputs.body?.data?.fields;\n if (!Array.isArray(fields)) throw new Error('Expected data.fields with author first and feedback second.');\n const Author = fields[0]?.value;\n const Content = fields[1]?.value;\n if (typeof Author !== 'string' || !Author.trim() || typeof Content !== 'string' || !Content.trim()) throw new Error('Author and feedback must be nonempty text fields.');\n const Created = new Date().toISOString();\n return { Author, Content, Created, URL: '', request: { document: { type: 'PLAIN_TEXT', content: Content }, encodingType: 'UTF16' } };\n}\n" }, "n_3ea3fc33f6fa38ad": { "name": "Validate form score", "imports": [], "source": "export default function readSentiment(inputs) {\n const body = inputs.body;\n const score = body?.documentSentiment?.score;\n if (!body || typeof body !== 'object' || Array.isArray(body) || body.error || typeof score !== 'number' || !Number.isFinite(score) || score < -1 || score > 1) throw new Error('The sentiment service did not return a valid document score.');\n return { score };\n}\n" }, "n_efd6bcb0b6e51600": { "name": "Select Strapi entry fields", "imports": [], "source": "export default function prepareStrapiPayload(inputs) {\n const { Author, Content, Created, URL } = inputs;\n return { record: { Content, Author, Created, URL }, body: { data: { Content, Author, Created, URL } } };\n}\n" }, "n_1510a0c28efc80cd": { "name": "Confirm captured entry", "imports": [], "source": "export default function testimonialResult(inputs) {\n if (inputs.body === null) return { result: { status: 'ignored', score: inputs.score, entry: null } };\n const body = inputs.body;\n const entry = body?.data;\n if (!body || typeof body !== 'object' || body.error || !entry || typeof entry !== 'object' || Array.isArray(entry) || !(typeof entry.documentId === 'string' && entry.documentId || typeof entry.id === 'number' && Number.isFinite(entry.id) || typeof entry.id === 'string' && entry.id)) throw new Error('Strapi did not confirm a created entry.');\n return { result: { status: 'captured', score: inputs.score, entry } };\n}\n" }, "n_db6c2974a6e33b11": { "name": "Return ignored feedback", "imports": [], "source": "export default function testimonialResult(inputs) {\n if (inputs.body === null) return { result: { status: 'ignored', score: inputs.score, entry: null } };\n const body = inputs.body;\n const entry = body?.data;\n if (!body || typeof body !== 'object' || body.error || !entry || typeof entry !== 'object' || Array.isArray(entry) || !(typeof entry.documentId === 'string' && entry.documentId || typeof entry.id === 'number' && Number.isFinite(entry.id) || typeof entry.id === 'string' && entry.id)) throw new Error('Strapi did not confirm a created entry.');\n return { result: { status: 'captured', score: inputs.score, entry } };\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }