{ "kind": "open-flow-workflow", "version": 1, "name": "Shortcut Text Transformer", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_7b2833f43d1bfc27": { "name": "Text from Shortcut", "kind": "webhook", "bodyFields": [ { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "type" }, { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "content" } ], "method": "POST", "options": { "responseBody": { "kind": "workflow-outputs", "output": "text", "timeoutMs": 60000 }, "responseHeaders": { "Content-Type": "text/plain; charset=utf-8" }, "responseStatusCode": 200 } }, "n_86c5b0c4118366c5": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7b2833f43d1bfc27", "output": "body" } ] } }, "name": "Choose text operation", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object" }, "nullable": false, "handle": "body" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "type" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "content" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "prompt" } ], "name": "Choose text operation", "moduleId": "n_af01827f8ebc55d7", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_7cf7354b1cff4024": { "inputs": { "prompt": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_86c5b0c4118366c5", "output": "prompt" } ] }, "content": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_86c5b0c4118366c5", "output": "content" } ] } }, "name": "Transform text", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "items": { "type": "object" }, "type": "array" }, "nullable": true, "handle": "messages", "value": null }, { "jsonSchema": { "items": { "type": "object" }, "minItems": 1, "type": "array" }, "nullable": false, "handle": "template", "value": [ { "role": "system", "content": "You are a helpful assistant designed to output JSON." }, { "role": "system", "content": "{{prompt}}" }, { "role": "user", "content": "{{content}}" } ] }, { "jsonSchema": { "type": "object" }, "nullable": false, "handle": "model", "value": { "model": "gpt-4o-mini" } }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "prompt" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "content" } ], "outputs": [ { "description": "Generated response.", "jsonSchema": { "type": "object", "properties": { "output": { "type": "string" } }, "required": [ "output" ] }, "nullable": false, "handle": "output" } ], "name": "Transform text", "executor": { "kind": "llm", "mode": "json" } } }, "n_543b6157f69b3724": { "inputs": { "result": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7cf7354b1cff4024", "output": "output" } ] } }, "name": "Read transformed text", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "properties": { "output": { "type": "string" } }, "required": [ "output" ] }, "nullable": false, "handle": "result" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "text" } ], "name": "Read transformed text", "moduleId": "n_95958de966bb5fc5", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_f6945a8b4d01d4d8": { "name": "Text response", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "text" } ], "outputMappings": { "text": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_543b6157f69b3724", "output": "text" } ] } } } }, "edges": [ { "source": "n_7b2833f43d1bfc27", "target": "n_86c5b0c4118366c5" }, { "source": "n_86c5b0c4118366c5", "target": "n_7cf7354b1cff4024" }, { "source": "n_7cf7354b1cff4024", "target": "n_543b6157f69b3724" }, { "source": "n_543b6157f69b3724", "target": "n_f6945a8b4d01d4d8" } ] } }, "modules": { "n_af01827f8ebc55d7": { "name": "Choose text operation", "imports": [], "source": "export const prompts = {\n spanish: 'Translate this message to Spanish.\\nOutput a JSON with a single field: output',\n english: 'Translate this message to English.\\nOutput a JSON with a single field: output',\n grammar: \"Correct grammar only, don't change the actual contents.\\nOutput a JSON with a single field: output\",\n shorter: 'Summarize this content a little bit (5% shorter)\\nOutput a JSON with a single field: output',\n longer: 'Make this content a little longer (5% longer)\\nOutput a JSON with a single field: output',\n};\n\nexport default function prepareText({ body }) {\n const { type, content } = body;\n if (typeof type !== 'string' || !Object.hasOwn(prompts, type)) {\n throw new Error('Choose spanish, english, grammar, shorter, or longer.');\n }\n if (typeof content !== 'string' || !content.trim()) {\n throw new Error('content must be nonempty text.');\n }\n return { type, content, prompt: prompts[type] };\n}\n" }, "n_95958de966bb5fc5": { "name": "Read transformed text", "imports": [], "source": "export default function textResult({ result }) {\n if (!result || typeof result !== 'object' || Array.isArray(result) || typeof result.output !== 'string' || !result.output.trim()) {\n throw new Error('The model must return a nonempty output string.');\n }\n return { text: result.output };\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }