Automatisierte Bestellbestätigung mit Abacate Pay: Gutschein für Erstkauf per E-Mail und Slack
Dies ist ein CRM, Multimodal AI-Bereich Automatisierungsworkflow mit 13 Nodes. Hauptsächlich werden If, Set, Code, Slack, Webhook und andere Nodes verwendet. Automatisierte Bestellbestätigung mit Abacate Pay: Gutschein für Erstkäufer, versendet per E-Mail und Slack
- •Slack Bot Token oder Webhook URL
- •HTTP Webhook-Endpunkt (wird von n8n automatisch generiert)
- •Möglicherweise sind Ziel-API-Anmeldedaten erforderlich
Verwendete Nodes (13)
{
"meta": {
"instanceId": "e860732ed76ff1de8212e780b2d62bd140dee0b71e6ccf7172d54e965acae43d",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "e4a1ed73-6ae6-4358-81dd-3400180d08ab",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"position": [
-500,
20
],
"webhookId": "1b27997e-c86e-4f3d-ac12-61a79400bb1d",
"parameters": {
"path": "1b27997e-c86e-4f3d-ac12-61a79400bb1d",
"options": {},
"httpMethod": "POST"
},
"typeVersion": 2
},
{
"id": "d1717d9f-ba23-49ad-b06e-ecb14542aaec",
"name": "Konfigurationen",
"type": "n8n-nodes-base.set",
"position": [
-260,
20
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "fa8a4b24-2171-454d-b0c1-5e7716cd9af6",
"name": "token",
"type": "string",
"value": "teste123"
},
{
"id": "17eb20d8-cd9a-4da4-99dd-853dea0247ea",
"name": "companyName",
"type": "string",
"value": "N8N"
},
{
"id": "7270f9b3-0ca3-4f5a-b236-0f103cec440c",
"name": "companySite",
"type": "string",
"value": "www.n8n.io"
},
{
"id": "f4f8a62c-f214-4872-ac2b-32db8a210296",
"name": "companyEmail",
"type": "string",
"value": "your.email@n8n.com"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "981c713b-53f8-4fe4-b091-bcd7a7a6a341",
"name": "Token prüfen",
"type": "n8n-nodes-base.if",
"position": [
-40,
20
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "dbd4bf73-c04d-40b0-8ce1-c00bf578e516",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $('Webhook').item.json.query.webhookSecret }}",
"rightValue": "={{ $json.token }}"
},
{
"id": "c2319a7f-1317-4a48-ba19-4bc44c97a8c1",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "8c252d44-ce6f-4a23-9224-f51ecb0c3462",
"name": "Fehler antworten",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
200,
20
],
"parameters": {
"options": {
"responseCode": 400
},
"respondWith": "json",
"responseBody": "{\n \"error\": \"token invalid\"\n}"
},
"typeVersion": 1.1
},
{
"id": "c757835b-dc8d-484b-b321-c823e19a719c",
"name": "E-Mail-Body erstellen",
"type": "n8n-nodes-base.code",
"position": [
1220,
-280
],
"parameters": {
"jsCode": "// Get data from previous nodes\nconst webhookData = $('Webhook').item.json.body.data;\nconst configs = $('Configs').item.json;\n\n// Check if the 'CreateCustomCoupon' node ran and has data\n// The .exists property is a safe way to check this\n// const couponNodeExists = $('CreateCustomCoupon');\nlet couponData = null;\nif ($('CheckFirstOrder').item.json.first) {\n console.log(\"teste\")\n couponData = $('CreateCustomCoupon').last().json.data;\n}\n\n// ---- PART 1: BUILD THE HTML FOR THE EMAIL ----\n\nlet couponHtmlSection = '';\nif (couponData) {\n couponHtmlSection = `\n <div class=\"coupon-section\">\n <h2>A Welcome Gift For You!</h2>\n <p>As a thank you for your first purchase, we've created a special <strong>10% discount coupon</strong> for your next order. Use the code below:</p>\n <div class=\"coupon-code\">${couponData.id}</div>\n </div>\n `;\n}\n\nconst emailHtml = `\n<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<title>Your Order Confirmation</title>\n<style>\n body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; margin: 0; padding: 0; background-color: #f4f4f7; }\n .container { max-width: 600px; margin: 20px auto; background-color: #ffffff; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.05); }\n .header { background-color: #4a5568; color: #ffffff; padding: 40px; text-align: center; }\n .header h1 { margin: 0; font-size: 28px; }\n .content { padding: 30px 40px; color: #4a5568; line-height: 1.6; }\n .content h2 { color: #2d3748; }\n .order-summary { width: 100%; border-collapse: collapse; margin-top: 20px; }\n .order-summary th, .order-summary td { border-bottom: 1px solid #e2e8f0; padding: 12px; text-align: left; }\n .order-summary th { background-color: #f7fafc; }\n .total { font-size: 18px; font-weight: bold; color: #2d3748; text-align: right; margin-top: 20px; }\n .coupon-section { background-color: #f7fafc; border: 2px dashed #2a9d8f; border-radius: 8px; padding: 20px; margin-top: 30px; text-align: center; }\n .coupon-code { background-color: #ffffff; border: 1px solid #e2e8f0; padding: 10px 20px; font-size: 20px; font-weight: bold; color: #2a9d8f; letter-spacing: 2px; display: inline-block; margin-top: 10px; }\n .footer { background-color: #edf2f7; color: #718096; text-align: center; padding: 20px; font-size: 12px; }\n .footer a { color: #4a5568; text-decoration: none; }\n</style>\n</head>\n<body>\n <div class=\"container\">\n <div class=\"header\">\n <h1>Thank You For Your Order!</h1>\n </div>\n <div class=\"content\">\n <p>Hello <strong>${webhookData.billing.customer.metadata.name}</strong>,</p>\n <p>Your order has been successfully processed. We appreciate your business and are already preparing your items.</p>\n\n <h2>Order Summary #${webhookData.billing.id}</h2>\n <table class=\"order-summary\">\n <thead>\n <tr>\n <th>Product ID</th>\n <th>Quantity</th>\n <th>Price</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>${webhookData.billing.products[0].externalId}</td>\n <td>${webhookData.billing.products[0].quantity}</td>\n <td>R$ ${webhookData.billing.paidAmount / 100}</td>\n </tr>\n </tbody>\n </table>\n <p class=\"total\">\n TOTAL: $${webhookData.billing.paidAmount / 100}\n </p>\n\n ${couponHtmlSection}\n\n <p>If you have any questions, please reply to this email or visit our support center. We're here to help!</p>\n <p>Sincerely,<br>The ${configs.companyName} Team</p>\n </div>\n <div class=\"footer\">\n <p>© ${new Date().getFullYear()} ${configs.companyName}. All rights reserved.</p>\n <p><a href=\"https://${configs.companySite}\">Visit our website</a> | <a href=\"mailto:${configs.companyEmail}\">Contact Us</a></p>\n </div>\n </div>\n</body>\n</html>\n`;\n\nlet slackBlocks = [\n\t{\n\t\t\"type\": \"header\",\n\t\t\"text\": { \"type\": \"plain_text\", \"text\": \"🎉 New Sale Received!\", \"emoji\": true }\n\t},\n\t{\n\t\t\"type\": \"section\",\n\t\t\"fields\": [\n\t\t\t{ \"type\": \"mrkdwn\", \"text\": `*Customer:*\\n${webhookData.billing.customer.metadata.name}` },\n\t\t\t{ \"type\": \"mrkdwn\", \"text\": `*Email:*\\n${webhookData.billing.customer.metadata.email}` },\n\t\t\t{ \"type\": \"mrkdwn\", \"text\": `*Order ID:*\\n\\`${webhookData.billing.id}\\`` },\n\t\t\t{ \"type\": \"mrkdwn\", \"text\": `*Amount Paid:*\\n*$${webhookData.billing.paidAmount / 100}*` }\n\t\t]\n\t},\n\t{ \"type\": \"divider\" }\n];\n\nif (couponData) {\n slackBlocks.push({\n\t\t\"type\": \"section\",\n\t\t\"text\": {\n\t\t\t\"type\": \"mrkdwn\",\n\t\t\t\"text\": `🎁 *First-Time Buyer Bonus!*\\nA 10% discount coupon was generated for their next purchase: \\`${couponData.id}\\``\n\t\t}\n\t});\n}\n\nslackBlocks.push(\n {\n\t\t\"type\": \"context\",\n\t\t\"elements\": [\n\t\t\t{ \"type\": \"mrkdwn\", \"text\": `Payment via *${webhookData.payment.method}* | ✅ Confirmation email sent.` }\n\t\t]\n\t},\n\t{\n\t\t\"type\": \"actions\",\n\t\t\"elements\": [\n\t\t\t{\n\t\t\t\t\"type\": \"button\",\n\t\t\t\t\"text\": { \"type\": \"plain_text\", \"text\": \"View Execution\", \"emoji\": true },\n\t\t\t\t\"url\": `${$('Webhook').last().json.webhookUrl}`,\n\t\t\t\t\"action_id\": \"view_execution_button\"\n\t\t\t}\n\t\t]\n\t}\n);\n\nreturn {\n json: {\n emailHtml: emailHtml,\n slackBlocks:{blocks: slackBlocks}\n }\n};"
},
"typeVersion": 2
},
{
"id": "000c0f09-b6a3-4a0a-bc4e-3c91dd22c5c2",
"name": "E-Mail senden",
"type": "n8n-nodes-base.emailSend",
"position": [
1440,
-360
],
"webhookId": "8c1766d5-bb30-4f14-9078-3193e6aac6b5",
"parameters": {
"html": "={{ $json.emailHtml }}",
"options": {},
"subject": "Thank You For Your Order!",
"toEmail": "={{ $('Webhook').item.json.body.data.billing.customer.metadata.email }}",
"fromEmail": "={{$('Configs').item.json.companyEmail}}"
},
"credentials": {
"smtp": {
"id": "qncoQX3vHrJbtnK7",
"name": "SMTP account"
}
},
"retryOnFail": true,
"typeVersion": 2.1
},
{
"id": "8d647e46-7e42-4ea8-aa81-eb6a380b0f52",
"name": "Slack",
"type": "n8n-nodes-base.slack",
"position": [
1440,
-200
],
"webhookId": "3abc93d5-ae38-4a60-b51c-836f660f5d73",
"parameters": {
"user": {
"__rl": true,
"mode": "username",
"value": "@mth.pedrosa"
},
"select": "user",
"blocksUi": "={{ JSON.stringify($json.slackBlocks) }}",
"messageType": "block",
"otherOptions": {}
},
"credentials": {
"slackApi": {
"id": "BHr2MFFEhDsD4Uzv",
"name": "Slack account 3"
}
},
"typeVersion": 2.3
},
{
"id": "ea067f2a-b47e-4411-92d3-0986c101c3de",
"name": "Individuellen Gutschein erstellen",
"type": "n8n-nodes-base.httpRequest",
"position": [
1000,
-420
],
"parameters": {
"url": "https://api.abacatepay.com/v1/coupon/create",
"method": "POST",
"options": {},
"jsonBody": "={\n \"code\": \"{{ $('Webhook').item.json.body.data.billing.customer.metadata.name.replaceAll(\" \",\"\").toUpperCase() }}_10\",\n \"notes\": \"Coupon sale {{$('Webhook').item.json.body.data.billing.id}}\",\n \"maxRedeems\": 1,\n \"discountKind\": \"PERCENTAGE\",\n \"discount\": 10,\n \"metadata\": {}\n}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "Bearer {{your_token}}"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "f0faf198-1ed4-4284-bbb6-85dae800999d",
"name": "Bestellungen abrufen",
"type": "n8n-nodes-base.httpRequest",
"position": [
240,
-300
],
"parameters": {
"url": "https://api.abacatepay.com/v1/billing/list",
"options": {},
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "Bearer {{your_token}}"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "4741f8ed-8bef-4d73-9dd6-e60e6ec66aa9",
"name": "Erstbestellung prüfen",
"type": "n8n-nodes-base.code",
"position": [
520,
-300
],
"parameters": {
"jsCode": "const orders = $('GetOrders').last().json\nconst currentOrder = $('Webhook').last().json.body.data\nlet first = false\n\nif(!orders.error){\n let firstOrder = orders.data.filter(order => order.customer?.id === currentOrder.billing.customer.id && order.id !== currentOrder.billing.id)\n\n console.log('first',firstOrder)\n if (firstOrder.length === 0){\n console.log(\"oi\")\n first = true\n }\n}\n\nreturn {first}"
},
"typeVersion": 2
},
{
"id": "019e46e1-dc65-404d-806e-8d75593be29a",
"name": "Wenn",
"type": "n8n-nodes-base.if",
"position": [
800,
-300
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "04f28052-4896-4b98-985e-f11adfec2f86",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.first }}",
"rightValue": "true"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "a00461f1-8ece-4f9a-af49-c349d4478e37",
"name": "Notiz",
"type": "n8n-nodes-base.stickyNote",
"position": [
-480,
-660
],
"parameters": {
"width": 560,
"height": 640,
"content": "## Abacate Pay to Email & Slack: Automated Confirmation & First-Buyer Coupon\n\n**Author:** Matheus Pedrosa | https://www.linkedin.com/in/matheus-pedrosa-custodio/\n**Version:** 1.0\n**Date:** 2025-08-14\n\n## Summary\nThis workflow automates the post-purchase process following a successful payment on the **Abacate Pay** gateway. It sends a confirmation email to the customer and a detailed notification to a Slack channel.\n\n## Key Feature\nThe core logic of this flow is **new customer detection and reward**. It checks if it's the customer's first purchase and, if so, creates and sends a 10% discount coupon for their next order, dynamically including it in the messages.\n\n## Setup (Quick Checklist)\n1. **`Configs` Node**: Start here. Define your main variables (company name, site, webhook validation token).\n2. **HTTP Request Nodes**: Insert your Abacate Pay API keys in the `GetOrders` and `CreateCustomCoupon` nodes.\n3. **Credentials**: Connect your accounts in the `Send Email` and `Slack` nodes and select the correct recipients."
},
"typeVersion": 1
},
{
"id": "8d7c877d-60ef-43f1-a707-e4616cb5e3ec",
"name": "Notiz1",
"type": "n8n-nodes-base.stickyNote",
"position": [
100,
-660
],
"parameters": {
"color": 4,
"width": 160,
"height": 220,
"content": "## AbacatePay\n"
},
"typeVersion": 1
}
],
"pinData": {
"Webhook": [
{
"body": {
"data": {
"billing": {
"id": "bill_0HfT4RcsWHfpL45EsCFD5GhF",
"kind": [
"PIX"
],
"amount": 1000,
"status": "ACTIVE",
"customer": {
"id": "cust_LK4T2Es0G0Ru3jZ2pfpPw202",
"metadata": {
"name": "Matheus Pedrosa",
"email": "mth.pedrosa@outlook.com",
"taxId": "37448456806",
"cellphone": "(18) 98820-1588"
}
},
"products": [
{
"id": "prod_jt2nC36C3JxSXcNSYAwaRe2m",
"quantity": 1,
"externalId": "1"
}
],
"frequency": "MULTIPLE_PAYMENTS",
"paidAmount": 1000,
"couponsUsed": []
},
"payment": {
"fee": 80,
"amount": 1000,
"method": "PIX"
}
},
"event": "billing.paid",
"devMode": true
},
"query": {
"webhookSecret": "teste123"
},
"params": {},
"headers": {
"host": "0a4e2be16c08.ngrok-free.app",
"accept": "*/*",
"svix-id": "msg_31FY8V4CRAfe8VNCtVtFDvtaosp",
"user-agent": "Svix-Webhooks/1.70.0 (sender-9YMgn; +https://www.svix.com/http-sender/)",
"content-type": "application/json",
"content-length": "517",
"svix-signature": "v1,Vigvp7HcLdvRR3eC3TDZd+cFOUBsKLxDOn8Kq4wm0iY=",
"svix-timestamp": "1755121128",
"accept-encoding": "gzip",
"x-forwarded-for": "63.33.109.123",
"x-forwarded-host": "0a4e2be16c08.ngrok-free.app",
"x-forwarded-proto": "https"
},
"webhookUrl": "http://localhost:5678/webhook/1b27997e-c86e-4f3d-ac12-61a79400bb1d",
"executionMode": "production"
}
]
},
"connections": {
"019e46e1-dc65-404d-806e-8d75593be29a": {
"main": [
[
{
"node": "ea067f2a-b47e-4411-92d3-0986c101c3de",
"type": "main",
"index": 0
}
],
[
{
"node": "c757835b-dc8d-484b-b321-c823e19a719c",
"type": "main",
"index": 0
}
]
]
},
"d1717d9f-ba23-49ad-b06e-ecb14542aaec": {
"main": [
[
{
"node": "981c713b-53f8-4fe4-b091-bcd7a7a6a341",
"type": "main",
"index": 0
}
]
]
},
"e4a1ed73-6ae6-4358-81dd-3400180d08ab": {
"main": [
[
{
"node": "d1717d9f-ba23-49ad-b06e-ecb14542aaec",
"type": "main",
"index": 0
}
]
]
},
"f0faf198-1ed4-4284-bbb6-85dae800999d": {
"main": [
[
{
"node": "4741f8ed-8bef-4d73-9dd6-e60e6ec66aa9",
"type": "main",
"index": 0
}
]
]
},
"981c713b-53f8-4fe4-b091-bcd7a7a6a341": {
"main": [
[
{
"node": "f0faf198-1ed4-4284-bbb6-85dae800999d",
"type": "main",
"index": 0
}
],
[
{
"node": "8c252d44-ce6f-4a23-9224-f51ecb0c3462",
"type": "main",
"index": 0
}
]
]
},
"000c0f09-b6a3-4a0a-bc4e-3c91dd22c5c2": {
"main": [
[]
]
},
"c757835b-dc8d-484b-b321-c823e19a719c": {
"main": [
[
{
"node": "8d647e46-7e42-4ea8-aa81-eb6a380b0f52",
"type": "main",
"index": 0
},
{
"node": "000c0f09-b6a3-4a0a-bc4e-3c91dd22c5c2",
"type": "main",
"index": 0
}
]
]
},
"4741f8ed-8bef-4d73-9dd6-e60e6ec66aa9": {
"main": [
[
{
"node": "019e46e1-dc65-404d-806e-8d75593be29a",
"type": "main",
"index": 0
}
]
]
},
"ea067f2a-b47e-4411-92d3-0986c101c3de": {
"main": [
[
{
"node": "c757835b-dc8d-484b-b321-c823e19a719c",
"type": "main",
"index": 0
}
]
]
}
}
}Wie verwende ich diesen Workflow?
Kopieren Sie den obigen JSON-Code, erstellen Sie einen neuen Workflow in Ihrer n8n-Instanz und wählen Sie "Aus JSON importieren". Fügen Sie die Konfiguration ein und passen Sie die Anmeldedaten nach Bedarf an.
Für welche Szenarien ist dieser Workflow geeignet?
Fortgeschritten - Kundenbeziehungsmanagement, Multimodales KI
Ist es kostenpflichtig?
Dieser Workflow ist völlig kostenlos. Beachten Sie jedoch, dass Drittanbieterdienste (wie OpenAI API), die im Workflow verwendet werden, möglicherweise kostenpflichtig sind.
Verwandte Workflows
Matheus Pedrosa
@julinhoI am a software engineer specializing in automations, with extensive experience on the N8N platform. With solid skills in JavaScript, Go, .NET, and C#, I am equipped to develop efficient and scalable solutions.
Diesen Workflow teilen