{ "kind": "open-flow-workflow", "version": 1, "name": "WooCommerce Product to Slack", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_b5eb6deb60fdf91b": { "name": "Product Created", "kind": "integration", "config": { "events": { "kind": "value", "value": [ "product.created" ] }, "webhookName": { "kind": "value", "value": "WooCommerce Product 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_4757f9e7bba8d05c": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_b5eb6deb60fdf91b", "output": "body" } ] } }, "name": "Format product 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 product notification", "moduleId": "n_a73444b64c4f9b72", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_4013eccb4aa3b4d6": { "inputs": { "channelId": { "kind": "value", "value": "YOUR_SLACK_CHANNEL_ID" }, "text": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_4757f9e7bba8d05c", "output": "text" } ] }, "attachments": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_4757f9e7bba8d05c", "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" } } } }, "edges": [ { "source": "n_4757f9e7bba8d05c", "target": "n_4013eccb4aa3b4d6" }, { "source": "n_b5eb6deb60fdf91b", "target": "n_4757f9e7bba8d05c" } ] } }, "modules": { "n_a73444b64c4f9b72": { "name": "Format product notification", "imports": [], "source": "export default function productMessage({ body }) {\n const isHttpLink = (value) => {\n const parts = typeof value === 'string' && /^https?:\\/\\/(\\[[0-9a-f:.]+\\]|[^\\s/\\\\?#@:%\\[\\]<>\"`]+)(?::(\\d{1,5}))?(?:[/?#][^\\s\\\\]*)?$/i.exec(value);\n return Boolean(parts && !/[\\u0000-\\u0020\\u007f]/.test(value) && (!parts[2] || Number(parts[2]) <= 65535));\n };\n const escape = (text) => text.replace(/&/g, '&').replace(//g, '>');\n for (const field of ['name', 'regular_price', 'sale_price', 'permalink', 'date_created']) if (typeof body[field] !== 'string') throw new Error('WooCommerce product is missing ' + field);\n if (!isHttpLink(body.permalink)) throw new Error('Product permalink must be an HTTP(S) URL without credentials');\n const footer = 'Added: ' + escape(body.date_created);\n if (footer.length > 300) throw new Error('Product timestamp exceeds Slack footer size');\n const text = ':new: A new product has been added! :new:';\n return { text, attachments: [{ color: '#66FF00', fallback: text, fields: [\n { title: 'Name', value: escape(body.name), short: false },\n { title: 'Price', value: escape(body.regular_price), short: true },\n { title: 'Sale Price', value: escape(body.sale_price), short: true },\n { title: 'Link', value: escape(body.permalink), short: false },\n ], footer }] };\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }