{ "kind": "open-flow-workflow", "version": 1, "name": "Discord Feedback Router", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_17ce54c06cd8ca9f": { "name": "Test feedback routing", "kind": "start", "inputDefs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "feedback" } ] }, "n_fed54994d59525db": { "name": "Submitted feedback", "kind": "webhook", "bodyFields": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "feedback" } ], "method": "POST", "options": { "responseStatusCode": 200 } }, "n_400833304f325674": { "inputs": { "feedback": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_17ce54c06cd8ca9f", "output": "feedback" }, { "kind": "node", "nodeId": "n_fed54994d59525db", "output": "body", "field": "feedback" } ] } }, "name": "Check feedback text", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "feedback" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "feedback" } ], "name": "Check feedback text", "moduleId": "n_2ee816b06f2e6eee", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_6fff787c358ea4f6": { "inputs": { "feedback": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_400833304f325674", "output": "feedback" } ] } }, "name": "Classify service feedback", "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": "Act as a service desk agent and help to categorize user messages. Return back only JSON without quotations. Do not return anything else." }, { "role": "user", "content": "Here is a user feedback: \"{{feedback}}\". Please analyse it and put into one of the categories:\n1. \"success-story\" for user appraisal or success story. this will be processed by customer success department\n2. \"urgent-issue\" for extreme dissatisfaction or an urgent problem. this will be escalated to the IT team. Please assess if the request is really urgent and whether it has an immediate impact on the client. If the ticket doesn't look like an immediate problem or an extreme dissatisfaction then proceed as a normal ticket.\n3. \"ticket\" for everything else. This will be processed as normal by customer support team.\n\nPlease return back a JSON with the following structure: category (string), feedback (string), instruction (string).\nCategory must match the analysed category. feedback must match the original text. instruction should contain a text for a department according to the category with a one sentense summary of the feedback. Please be polite and friendly to the colleagues." } ] }, { "jsonSchema": { "type": "object" }, "nullable": false, "handle": "model", "value": { "model": "gpt-4o-mini-2024-07-18", "temperature": 0.5, "max_tokens": 500 } }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "feedback" } ], "outputs": [ { "description": "Generated response.", "jsonSchema": { "type": "string" }, "nullable": false, "handle": "output" } ], "name": "Classify service feedback", "executor": { "kind": "llm", "mode": "chat" } } }, "n_eb98358159c0a707": { "inputs": { "completion": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_6fff787c358ea4f6", "output": "output" } ] }, "feedback": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_400833304f325674", "output": "feedback" } ] } }, "name": "Read category and instruction", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "completion" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "feedback" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "category" }, { "jsonSchema": { "type": "string", "maxLength": 2000 }, "nullable": false, "handle": "instruction" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "feedback" }, { "jsonSchema": { "type": "string", "enum": [ "routed", "ignored" ] }, "nullable": false, "handle": "status" } ], "name": "Read category and instruction", "moduleId": "n_2a8167bd21e48960", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_94468dac4f59b741": { "inputs": {}, "name": "Choose feedback department", "kind": "condition", "matchMode": "first", "cases": [ { "output": "success", "groups": [ { "expressions": [ { "left": { "kind": "source", "source": { "kind": "node", "nodeId": "n_eb98358159c0a707", "output": "category" } }, "operator": "==", "right": { "kind": "value", "value": "success-story" } } ] } ] }, { "output": "urgent", "groups": [ { "expressions": [ { "left": { "kind": "source", "source": { "kind": "node", "nodeId": "n_eb98358159c0a707", "output": "category" } }, "operator": "==", "right": { "kind": "value", "value": "urgent-issue" } } ] } ] }, { "output": "support", "groups": [ { "expressions": [ { "left": { "kind": "source", "source": { "kind": "node", "nodeId": "n_eb98358159c0a707", "output": "category" } }, "operator": "==", "right": { "kind": "value", "value": "ticket" } } ] } ] } ] }, "n_2bda3debe2c5380b": { "inputs": { "channel_id": { "kind": "value", "value": "YOUR_SUCCESS_CHANNEL_ID" }, "content": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_eb98358159c0a707", "output": "instruction" } ] } }, "name": "Notify customer success", "kind": "task", "task": { "inputs": [ { "description": "The channel id.", "jsonSchema": { "type": "string", "description": "The channel id." }, "nullable": false, "handle": "channel_id" }, { "description": "The message content.", "jsonSchema": { "type": "string", "maxLength": 2000, "description": "The message content." }, "nullable": true, "handle": "content", "value": null }, { "description": "The embeds to include.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": {}, "additionalProperties": true, "description": "A JSON-like object with arbitrary Discord payload fields." }, "maxItems": 10, "description": "The embeds to include." }, "nullable": true, "handle": "embeds", "value": null }, { "description": "The components to include.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": {}, "additionalProperties": true, "description": "A JSON-like object with arbitrary Discord payload fields." }, "maxItems": 5, "description": "The components to include." }, "nullable": true, "handle": "components", "value": null }, { "description": "The sticker ids to attach.", "jsonSchema": { "type": "array", "items": { "type": "string", "description": "A non-empty string." }, "maxItems": 3, "description": "The sticker ids to attach." }, "nullable": true, "handle": "sticker_ids", "value": null }, { "description": "The attachment metadata to include.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": {}, "additionalProperties": true, "description": "A JSON-like object with arbitrary Discord payload fields." }, "description": "The attachment metadata to include." }, "nullable": true, "handle": "attachments", "value": null }, { "description": "The allowed mentions configuration for a Discord message.", "jsonSchema": { "type": "object", "properties": { "parse": { "type": "array", "items": { "type": "string", "enum": [ "roles", "users", "everyone" ], "description": "A supported mention target." }, "maxItems": 3, "description": "The mention targets to parse automatically." }, "roles": { "type": "array", "items": { "type": "string", "description": "A Discord snowflake identifier." }, "description": "The role ids allowed to be mentioned." }, "users": { "type": "array", "items": { "type": "string", "description": "A Discord snowflake identifier." }, "description": "The user ids allowed to be mentioned." }, "replied_user": { "type": "boolean", "description": "Whether the replied user should be mentioned." } }, "additionalProperties": true, "description": "The allowed mentions configuration for a Discord message." }, "nullable": true, "handle": "allowed_mentions", "value": null }, { "description": "A Discord message reference.", "jsonSchema": { "type": "object", "properties": { "message_id": { "type": "string", "description": "The referenced message id." }, "channel_id": { "type": "string", "description": "The referenced channel id." }, "guild_id": { "type": "string", "description": "The referenced guild id." }, "fail_if_not_exists": { "type": "boolean", "description": "Whether the request should fail if the reference does not exist." }, "type": { "type": "integer", "description": "The reference type." } }, "additionalProperties": true, "description": "A Discord message reference." }, "nullable": true, "handle": "message_reference", "value": null }, { "description": "Whether the message is a text-to-speech message.", "jsonSchema": { "type": "boolean", "description": "Whether the message is a text-to-speech message." }, "nullable": true, "handle": "tts", "value": null }, { "description": "The message flags.", "jsonSchema": { "type": "integer", "description": "The message flags." }, "nullable": true, "handle": "flags", "value": null }, { "description": "The message nonce.", "jsonSchema": { "anyOf": [ { "type": "integer", "description": "A numeric nonce." }, { "type": "string", "maxLength": 25, "minLength": 1, "description": "A string nonce." } ], "description": "The message nonce." }, "nullable": true, "handle": "nonce", "value": null }, { "description": "Whether nonce enforcement is enabled.", "jsonSchema": { "type": "boolean", "description": "Whether nonce enforcement is enabled." }, "nullable": true, "handle": "enforce_nonce", "value": null }, { "description": "The optional poll payload.", "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "The optional poll payload." }, "nullable": true, "handle": "poll", "value": null }, { "description": "The optional shared client theme payload.", "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "The optional shared client theme payload." }, "nullable": true, "handle": "shared_client_theme", "value": null } ], "outputs": [ { "description": "A Discord message object.", "jsonSchema": { "type": "object", "properties": { "id": { "type": "string", "description": "The message id." }, "channel_id": { "type": "string", "description": "The channel id." }, "content": { "type": "string", "description": "The message content." } }, "required": [ "id", "channel_id" ], "additionalProperties": true, "description": "A Discord message object." }, "nullable": false, "handle": "output" } ], "name": "Notify customer success", "executor": { "kind": "connector", "action": "discordbot.create_message", "outputMode": "value" } } }, "n_4b1ea72707a05cdb": { "inputs": { "channel_id": { "kind": "value", "value": "YOUR_IT_CHANNEL_ID" }, "content": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_eb98358159c0a707", "output": "instruction" } ] } }, "name": "Notify IT for urgent issue", "kind": "task", "task": { "inputs": [ { "description": "The channel id.", "jsonSchema": { "type": "string", "description": "The channel id." }, "nullable": false, "handle": "channel_id" }, { "description": "The message content.", "jsonSchema": { "type": "string", "maxLength": 2000, "description": "The message content." }, "nullable": true, "handle": "content", "value": null }, { "description": "The embeds to include.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": {}, "additionalProperties": true, "description": "A JSON-like object with arbitrary Discord payload fields." }, "maxItems": 10, "description": "The embeds to include." }, "nullable": true, "handle": "embeds", "value": null }, { "description": "The components to include.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": {}, "additionalProperties": true, "description": "A JSON-like object with arbitrary Discord payload fields." }, "maxItems": 5, "description": "The components to include." }, "nullable": true, "handle": "components", "value": null }, { "description": "The sticker ids to attach.", "jsonSchema": { "type": "array", "items": { "type": "string", "description": "A non-empty string." }, "maxItems": 3, "description": "The sticker ids to attach." }, "nullable": true, "handle": "sticker_ids", "value": null }, { "description": "The attachment metadata to include.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": {}, "additionalProperties": true, "description": "A JSON-like object with arbitrary Discord payload fields." }, "description": "The attachment metadata to include." }, "nullable": true, "handle": "attachments", "value": null }, { "description": "The allowed mentions configuration for a Discord message.", "jsonSchema": { "type": "object", "properties": { "parse": { "type": "array", "items": { "type": "string", "enum": [ "roles", "users", "everyone" ], "description": "A supported mention target." }, "maxItems": 3, "description": "The mention targets to parse automatically." }, "roles": { "type": "array", "items": { "type": "string", "description": "A Discord snowflake identifier." }, "description": "The role ids allowed to be mentioned." }, "users": { "type": "array", "items": { "type": "string", "description": "A Discord snowflake identifier." }, "description": "The user ids allowed to be mentioned." }, "replied_user": { "type": "boolean", "description": "Whether the replied user should be mentioned." } }, "additionalProperties": true, "description": "The allowed mentions configuration for a Discord message." }, "nullable": true, "handle": "allowed_mentions", "value": null }, { "description": "A Discord message reference.", "jsonSchema": { "type": "object", "properties": { "message_id": { "type": "string", "description": "The referenced message id." }, "channel_id": { "type": "string", "description": "The referenced channel id." }, "guild_id": { "type": "string", "description": "The referenced guild id." }, "fail_if_not_exists": { "type": "boolean", "description": "Whether the request should fail if the reference does not exist." }, "type": { "type": "integer", "description": "The reference type." } }, "additionalProperties": true, "description": "A Discord message reference." }, "nullable": true, "handle": "message_reference", "value": null }, { "description": "Whether the message is a text-to-speech message.", "jsonSchema": { "type": "boolean", "description": "Whether the message is a text-to-speech message." }, "nullable": true, "handle": "tts", "value": null }, { "description": "The message flags.", "jsonSchema": { "type": "integer", "description": "The message flags." }, "nullable": true, "handle": "flags", "value": null }, { "description": "The message nonce.", "jsonSchema": { "anyOf": [ { "type": "integer", "description": "A numeric nonce." }, { "type": "string", "maxLength": 25, "minLength": 1, "description": "A string nonce." } ], "description": "The message nonce." }, "nullable": true, "handle": "nonce", "value": null }, { "description": "Whether nonce enforcement is enabled.", "jsonSchema": { "type": "boolean", "description": "Whether nonce enforcement is enabled." }, "nullable": true, "handle": "enforce_nonce", "value": null }, { "description": "The optional poll payload.", "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "The optional poll payload." }, "nullable": true, "handle": "poll", "value": null }, { "description": "The optional shared client theme payload.", "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "The optional shared client theme payload." }, "nullable": true, "handle": "shared_client_theme", "value": null } ], "outputs": [ { "description": "A Discord message object.", "jsonSchema": { "type": "object", "properties": { "id": { "type": "string", "description": "The message id." }, "channel_id": { "type": "string", "description": "The channel id." }, "content": { "type": "string", "description": "The message content." } }, "required": [ "id", "channel_id" ], "additionalProperties": true, "description": "A Discord message object." }, "nullable": false, "handle": "output" } ], "name": "Notify IT for urgent issue", "executor": { "kind": "connector", "action": "discordbot.create_message", "outputMode": "value" } } }, "n_365b7fb4db501084": { "inputs": { "channel_id": { "kind": "value", "value": "YOUR_SUPPORT_CHANNEL_ID" }, "content": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_eb98358159c0a707", "output": "instruction" } ] } }, "name": "Notify customer support", "kind": "task", "task": { "inputs": [ { "description": "The channel id.", "jsonSchema": { "type": "string", "description": "The channel id." }, "nullable": false, "handle": "channel_id" }, { "description": "The message content.", "jsonSchema": { "type": "string", "maxLength": 2000, "description": "The message content." }, "nullable": true, "handle": "content", "value": null }, { "description": "The embeds to include.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": {}, "additionalProperties": true, "description": "A JSON-like object with arbitrary Discord payload fields." }, "maxItems": 10, "description": "The embeds to include." }, "nullable": true, "handle": "embeds", "value": null }, { "description": "The components to include.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": {}, "additionalProperties": true, "description": "A JSON-like object with arbitrary Discord payload fields." }, "maxItems": 5, "description": "The components to include." }, "nullable": true, "handle": "components", "value": null }, { "description": "The sticker ids to attach.", "jsonSchema": { "type": "array", "items": { "type": "string", "description": "A non-empty string." }, "maxItems": 3, "description": "The sticker ids to attach." }, "nullable": true, "handle": "sticker_ids", "value": null }, { "description": "The attachment metadata to include.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": {}, "additionalProperties": true, "description": "A JSON-like object with arbitrary Discord payload fields." }, "description": "The attachment metadata to include." }, "nullable": true, "handle": "attachments", "value": null }, { "description": "The allowed mentions configuration for a Discord message.", "jsonSchema": { "type": "object", "properties": { "parse": { "type": "array", "items": { "type": "string", "enum": [ "roles", "users", "everyone" ], "description": "A supported mention target." }, "maxItems": 3, "description": "The mention targets to parse automatically." }, "roles": { "type": "array", "items": { "type": "string", "description": "A Discord snowflake identifier." }, "description": "The role ids allowed to be mentioned." }, "users": { "type": "array", "items": { "type": "string", "description": "A Discord snowflake identifier." }, "description": "The user ids allowed to be mentioned." }, "replied_user": { "type": "boolean", "description": "Whether the replied user should be mentioned." } }, "additionalProperties": true, "description": "The allowed mentions configuration for a Discord message." }, "nullable": true, "handle": "allowed_mentions", "value": null }, { "description": "A Discord message reference.", "jsonSchema": { "type": "object", "properties": { "message_id": { "type": "string", "description": "The referenced message id." }, "channel_id": { "type": "string", "description": "The referenced channel id." }, "guild_id": { "type": "string", "description": "The referenced guild id." }, "fail_if_not_exists": { "type": "boolean", "description": "Whether the request should fail if the reference does not exist." }, "type": { "type": "integer", "description": "The reference type." } }, "additionalProperties": true, "description": "A Discord message reference." }, "nullable": true, "handle": "message_reference", "value": null }, { "description": "Whether the message is a text-to-speech message.", "jsonSchema": { "type": "boolean", "description": "Whether the message is a text-to-speech message." }, "nullable": true, "handle": "tts", "value": null }, { "description": "The message flags.", "jsonSchema": { "type": "integer", "description": "The message flags." }, "nullable": true, "handle": "flags", "value": null }, { "description": "The message nonce.", "jsonSchema": { "anyOf": [ { "type": "integer", "description": "A numeric nonce." }, { "type": "string", "maxLength": 25, "minLength": 1, "description": "A string nonce." } ], "description": "The message nonce." }, "nullable": true, "handle": "nonce", "value": null }, { "description": "Whether nonce enforcement is enabled.", "jsonSchema": { "type": "boolean", "description": "Whether nonce enforcement is enabled." }, "nullable": true, "handle": "enforce_nonce", "value": null }, { "description": "The optional poll payload.", "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "The optional poll payload." }, "nullable": true, "handle": "poll", "value": null }, { "description": "The optional shared client theme payload.", "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "The optional shared client theme payload." }, "nullable": true, "handle": "shared_client_theme", "value": null } ], "outputs": [ { "description": "A Discord message object.", "jsonSchema": { "type": "object", "properties": { "id": { "type": "string", "description": "The message id." }, "channel_id": { "type": "string", "description": "The channel id." }, "content": { "type": "string", "description": "The message content." } }, "required": [ "id", "channel_id" ], "additionalProperties": true, "description": "A Discord message object." }, "nullable": false, "handle": "output" } ], "name": "Notify customer support", "executor": { "kind": "connector", "action": "discordbot.create_message", "outputMode": "value" } } }, "n_2973a317d2c82d0c": { "name": "Feedback routing result", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "category" }, { "jsonSchema": { "type": "string", "maxLength": 2000 }, "nullable": false, "handle": "instruction" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "feedback" }, { "jsonSchema": { "type": "string", "enum": [ "routed", "ignored" ] }, "nullable": false, "handle": "status" } ], "outputMappings": { "category": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_eb98358159c0a707", "output": "category" } ] }, "instruction": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_eb98358159c0a707", "output": "instruction" } ] }, "feedback": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_eb98358159c0a707", "output": "feedback" } ] }, "status": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_eb98358159c0a707", "output": "status" } ] } } } }, "edges": [ { "source": "n_17ce54c06cd8ca9f", "target": "n_400833304f325674" }, { "source": "n_fed54994d59525db", "target": "n_400833304f325674" }, { "source": "n_400833304f325674", "target": "n_6fff787c358ea4f6" }, { "source": "n_6fff787c358ea4f6", "target": "n_eb98358159c0a707" }, { "source": "n_eb98358159c0a707", "target": "n_94468dac4f59b741" }, { "source": "n_94468dac4f59b741", "target": "n_2bda3debe2c5380b", "sourceHandle": "success" }, { "source": "n_2bda3debe2c5380b", "target": "n_2973a317d2c82d0c" }, { "source": "n_94468dac4f59b741", "target": "n_4b1ea72707a05cdb", "sourceHandle": "urgent" }, { "source": "n_4b1ea72707a05cdb", "target": "n_2973a317d2c82d0c" }, { "source": "n_94468dac4f59b741", "target": "n_365b7fb4db501084", "sourceHandle": "support" }, { "source": "n_365b7fb4db501084", "target": "n_2973a317d2c82d0c" }, { "source": "n_94468dac4f59b741", "target": "n_2973a317d2c82d0c", "sourceHandle": "otherwise" } ] } }, "modules": { "n_2ee816b06f2e6eee": { "name": "Check feedback text", "imports": [], "source": "export default function prepareFeedback(inputs) {\n if (typeof inputs.feedback !== 'string' || !inputs.feedback.trim()) throw new Error('Supply nonempty feedback text.');\n return { feedback: inputs.feedback };\n}\n" }, "n_2a8167bd21e48960": { "name": "Read category and instruction", "imports": [], "source": "export default function parseFeedback(inputs) {\n if (typeof inputs.completion !== 'string') throw new Error('The classifier did not return text.');\n const text = inputs.completion.trim().replace(/^```(?:json)?\\s*\\n?([\\s\\S]*?)\\n?```$/i, '$1');\n let reply;\n try { reply = JSON.parse(text); }\n catch {\n // Retain the source's repair for literal newlines inside JSON strings.\n reply = JSON.parse(text.replace(/\\n(?=[^\"]*\"(?:[^\"]*\"[^\"]*\")*[^\"]*$)/g, '\\\\n'));\n }\n if (!reply || typeof reply !== 'object' || Array.isArray(reply) || typeof reply.category !== 'string' || !reply.category.trim()) throw new Error('The classifier must return a category string.');\n const category = reply.category.trim().toLowerCase();\n const known = ['success-story', 'urgent-issue', 'ticket'].includes(category);\n const instruction = typeof reply.instruction === 'string' ? reply.instruction : '';\n if (instruction.length > 2000 || known && !instruction.trim()) throw new Error('A routed instruction must contain 1–2000 characters.');\n return { category, instruction, feedback: inputs.feedback, status: known ? 'routed' : 'ignored' };\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }