{ "name": "WooCommerce Product to Slack", "nodes": [ { "name": "Product Created", "type": "n8n-nodes-base.wooCommerceTrigger", "position": [ 320, 500 ], "parameters": { "event": "product.created" }, "typeVersion": 1, "id": "woocommerce-product-slack-alert-0" }, { "name": "Send to Slack", "type": "n8n-nodes-base.slack", "position": [ 1230, 500 ], "parameters": { "authentication": "accessToken", "resource": "message", "operation": "post", "channel": "YOUR_SLACK_CHANNEL_ID", "text": "={{ $json.text }}", "jsonParameters": false, "attachments": "={{ $json.attachments.map(attachment => ({...attachment, fields: {item: attachment.fields}})) }}", "blocksUi": { "blocksValues": [] }, "otherOptions": { "sendAsUser": "" } }, "typeVersion": 1, "id": "woocommerce-product-slack-alert-1" }, { "id": "woocommerce-product-slack-alert-format", "name": "Format product notification", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1000, 500 ], "parameters": { "mode": "runOnceForEachItem", "jsCode": "const format = 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\nreturn {json:format({body:$json})};" } } ], "active": false, "settings": { "executionOrder": "v1" }, "connections": { "Product Created": { "main": [ [ { "node": "Format product notification", "type": "main", "index": 0 } ] ] }, "Format product notification": { "main": [ [ { "node": "Send to Slack", "type": "main", "index": 0 } ] ] } }, "pinData": {} }