{ "kind": "open-flow-workflow", "version": 1, "name": "WooCommerce Refunded Order to Slack", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_83114004af49c0de": { "name": "Order Updated", "kind": "integration", "config": { "events": { "kind": "value", "value": [ "order.updated" ] }, "webhookName": { "kind": "value", "value": "WooCommerce Refunded Order to Slack" } }, "definition": { "configInputs": [ { "jsonSchema": { "type": "array", "items": { "type": "string", "enum": [ "coupon.created", "coupon.updated", "coupon.deleted", "coupon.restored", "customer.created", "customer.updated", "customer.deleted", "order.created", "order.updated", "order.deleted", "order.restored", "product.created", "product.updated", "product.deleted", "product.restored", "product.published" ] }, "minItems": 1, "maxItems": 16, "uniqueItems": true }, "nullable": false, "handle": "events" }, { "jsonSchema": { "type": "string", "minLength": 1, "maxLength": 120 }, "nullable": false, "handle": "webhookName", "value": "OOMOL Trigger" } ], "definitionVersion": 2, "description": "Triggers when selected WooCommerce store events occur.", "displayName": "Store Event", "key": "woocommerce.on_store_event", "name": "on_store_event", "outputs": [ { "jsonSchema": { "type": "object" }, "nullable": false, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "deliveryId" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "event" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "resource" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "source" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "topic" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "webhookId" } ], "provider": "woocommerce", "type": "integration", "endpoint": { "body": { "allowArray": false, "allowEmpty": false, "formats": [ "json" ] }, "methods": [ "POST" ], "successStatus": 202 } } }, "n_22c73e3a478d799c": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_83114004af49c0de", "output": "body" } ] } }, "name": "Format refund notification", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object" }, "nullable": false, "handle": "body" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "text" }, { "jsonSchema": { "type": "array", "items": { "type": "object", "properties": {}, "additionalProperties": true, "description": "A Slack legacy attachment object. Prefer blocks for new messages when possible." }, "minItems": 1, "description": "Slack legacy attachments to include in the message." }, "nullable": false, "handle": "attachments" } ], "name": "Format refund notification", "moduleId": "n_f9fe5bcdba365328", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_f9f2bb334d636505": { "inputs": { "channelId": { "kind": "value", "value": "YOUR_SLACK_CHANNEL_ID" }, "text": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_22c73e3a478d799c", "output": "text" } ] }, "attachments": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_22c73e3a478d799c", "output": "attachments" } ] } }, "name": "Post notification to Slack", "kind": "task", "task": { "inputs": [ { "description": "The Slack conversation or channel ID.", "jsonSchema": { "type": "string", "minLength": 1, "description": "The Slack conversation or channel ID." }, "nullable": false, "handle": "channelId" }, { "description": "Plain text message content. When blocks are provided, Slack uses this as notification and accessibility fallback text.", "jsonSchema": { "type": "string", "description": "Plain text message content. When blocks are provided, Slack uses this as notification and accessibility fallback text." }, "nullable": true, "handle": "text", "value": null }, { "description": "Slack Block Kit blocks to render in the message.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": {}, "additionalProperties": true, "description": "A Slack Block Kit block object. Pass the block exactly as Slack documents it." }, "minItems": 1, "description": "Slack Block Kit blocks to render in the message." }, "nullable": true, "handle": "blocks", "value": null }, { "description": "Slack legacy attachments to include in the message.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": {}, "additionalProperties": true, "description": "A Slack legacy attachment object. Prefer blocks for new messages when possible." }, "minItems": 1, "description": "Slack legacy attachments to include in the message." }, "nullable": true, "handle": "attachments", "value": null }, { "description": "Whether Slack should unfurl links in the message.", "jsonSchema": { "type": "boolean", "description": "Whether Slack should unfurl links in the message." }, "nullable": true, "handle": "unfurlLinks", "value": null }, { "description": "Whether Slack should unfurl media in the message.", "jsonSchema": { "type": "boolean", "description": "Whether Slack should unfurl media in the message." }, "nullable": true, "handle": "unfurlMedia", "value": null }, { "description": "Slack message metadata to attach to the message.", "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "Slack message metadata to attach to the message." }, "nullable": true, "handle": "metadata", "value": null } ], "outputs": [ { "description": "The timestamp identifier of the posted message.", "jsonSchema": { "type": "string", "description": "The timestamp identifier of the posted message." }, "nullable": false, "handle": "ts" }, { "description": "The channel ID where the message was posted.", "jsonSchema": { "type": "string", "description": "The channel ID where the message was posted." }, "nullable": false, "handle": "channelId" } ], "name": "Post notification to Slack", "executor": { "kind": "connector", "action": "slack.post_message" } } }, "n_02e9a68d52ab763e": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_83114004af49c0de", "output": "body" } ] } }, "name": "Read order total and status", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object" }, "nullable": false, "handle": "body" } ], "outputs": [ { "jsonSchema": { "type": "number", "minimum": 0 }, "nullable": false, "handle": "total" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "status" } ], "name": "Read order total and status", "moduleId": "n_b0aecb00b36ccae1", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_cdb396b66544f654": { "inputs": {}, "name": "Order total at least 100", "kind": "condition", "matchMode": "first", "cases": [ { "output": "large", "groups": [ { "expressions": [ { "left": { "kind": "source", "source": { "kind": "node", "nodeId": "n_02e9a68d52ab763e", "output": "total" } }, "operator": ">=", "right": { "kind": "value", "value": 100 } } ] } ] } ] }, "n_732249dcfa7a39b9": { "inputs": {}, "name": "Order status is refunded", "kind": "condition", "matchMode": "first", "cases": [ { "output": "refunded", "groups": [ { "expressions": [ { "left": { "kind": "source", "source": { "kind": "node", "nodeId": "n_02e9a68d52ab763e", "output": "status" } }, "operator": "==", "right": { "kind": "value", "value": "refunded" } } ] } ] } ] } }, "edges": [ { "source": "n_22c73e3a478d799c", "target": "n_f9f2bb334d636505" }, { "source": "n_83114004af49c0de", "target": "n_02e9a68d52ab763e" }, { "source": "n_02e9a68d52ab763e", "target": "n_cdb396b66544f654" }, { "source": "n_cdb396b66544f654", "target": "n_732249dcfa7a39b9", "sourceHandle": "large" }, { "source": "n_732249dcfa7a39b9", "target": "n_22c73e3a478d799c", "sourceHandle": "refunded" } ] } }, "modules": { "n_f9fe5bcdba365328": { "name": "Format refund notification", "imports": [], "source": "export default function refundMessage({ body }) {\n const escape = (text) => text.replace(/&/g, '&').replace(//g, '>');\n if (!Number.isSafeInteger(body.id) || body.id < 1) throw new Error('WooCommerce order ID is missing or invalid');\n for (const field of ['status', 'total', 'currency', 'date_modified']) if (typeof body[field] !== 'string') throw new Error('WooCommerce order is missing ' + field);\n const money = typeof body.currency_symbol === 'string' && body.currency_symbol ? body.currency_symbol + body.total : body.currency + ' ' + body.total;\n const footer = '*Order updated:* ' + escape(body.date_modified);\n if (footer.length > 300) throw new Error('Order timestamp exceeds Slack footer size');\n const text = ':x: A refund has been issued :x:';\n return { text, attachments: [{ color: '#FF0000', fallback: text, fields: [\n { title: 'Order ID', value: String(body.id), short: true },\n { title: 'Status', value: escape(body.status), short: true },\n { title: 'Total', value: escape(money), short: true },\n ], footer }] };\n}\n" }, "n_b0aecb00b36ccae1": { "name": "Read order total and status", "imports": [], "source": "export default function orderAmount({ body }) {\n if (typeof body.total !== 'string' || !/^\\d+(?:\\.\\d+)?$/.test(body.total) || !Number.isFinite(Number(body.total))) throw new Error('WooCommerce order total must be a nonnegative decimal string');\n if (typeof body.status !== 'string' || !body.status) throw new Error('WooCommerce order status is missing');\n return { total: Number(body.total), status: body.status };\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }