Skip to content
GitHub

Capstone Project: E-commerce Automation System

ဤ Capstone Project တွင် Myanmar Online Shop တစ်ခုအတွက် Complete Automation System တည်ဆောက်မည်။ ဒီ Course တွင် လေ့လာခဲ့သော Concepts အားလုံးကို အသုံးချမည်:

Moduleဘာ သုံးမလဲ
WebhookOrder ဝင်ရောက်မှုကို လက်ခံသည်
CredentialsStripe, Gmail, Slack API
Data TransformationOrder Data ကို Format ချသည်
IF / BranchVIP vs Standard Order ခွဲသည်
Parallel ActionsEmail + Slack + Database တပြိုင်တည်း
Error HandlingPayment Fail ဖြစ်ရင် Alert ပေးသည်
Sub-WorkflowsNotification ကို Reusable လုပ်သည်
DatabaseMySQL ထဲ Order သိမ်းသည်
Loop/BatchBulk Order Report ထုတ်သည်
AICustomer Message ကို Auto-reply ပေးသည်
ScheduleDaily Report Email ပို့သည်
WooCommerce / Shopify Order Events
n8n Webhook Central Hub
Process & Automate Workflows
Database + Notifications MySQL + Email + Slack

E-commerce → n8n Hub → All automated actions

New Order ဝင်လာသောအခါ အောက်ပါ Actions တွေကို Run ပေးသည်:

Webhook: New Order (from Store)
Order Total > 50,000 MMK?
VIP Order ⭐
Set: VIP Flag
Gmail: VIP Confirmation + Free Shipping
Slack: #vip-orders alert
Standard Order
Set: Standard Flag
Gmail: Standard Confirmation
Slack: #orders alert
// Code Node — Order ကို Validate + Enrich လုပ်ပါ
const order = $input.first().json;
// Validate Required Fields
const required = ['orderId', 'customer', 'total', 'items'];
const missing = required.filter(f => !order[f]);
if (missing.length > 0) {
throw new Error(`Missing fields: ${missing.join(', ')}`);
}
// Enrich Order Data
return [{
json: {
...order,
isVip: order.total > 50000,
formattedTotal: `${Number(order.total).toLocaleString()} ကျပ်`,
itemCount: order.items.length,
orderDate: new Date().toLocaleDateString('my-MM', {
year: 'numeric', month: 'long', day: 'numeric'
}),
estimatedDelivery: new Date(
Date.now() + (order.isVip ? 2 : 5) * 24 * 60 * 60 * 1000
).toLocaleDateString('my-MM')
}
}];

Stripe Payment Webhook ဝင်လာသောအခါ:

Webhook: Stripe Payment Event
Payment succeeded?
payment_intent.succeeded ✅
MySQL: Update order status='paid'
Gmail: Receipt Email
Sub-WF: Send Notification
payment_intent.payment_failed ❌
MySQL: Update status='failed'
Gmail: Payment Failed + Retry Link
Slack: #payments urgent alert
// Code Node — Stripe Event ကို Parse လုပ်ပါ
const event = $input.first().json;
const isSuccess = event.type === 'payment_intent.succeeded';
const amount = event.data.object.amount / 100; // cents to dollars
return [{
json: {
eventType: event.type,
orderId: event.data.object.metadata.orderId,
amount,
currency: event.data.object.currency.toUpperCase(),
status: isSuccess ? 'paid' : 'failed',
failureReason: isSuccess ? null : event.data.object.last_payment_error?.message
}
}];
Schedule Trigger Mon-Sat 8am
MySQL: Yesterday's Orders
Code: Calculate KPIs
Gmail: Report to Owner

နေ့တိုင်း မနက် ၈ နာရီ ကနေ့ Sales Summary ကို Owner ဆီ Email ပို့သည်

// Code Node — KPI Calculation
const orders = $input.all().map(i => i.json);
const stats = {
date: new Date(Date.now() - 86400000).toLocaleDateString('my-MM'),
totalOrders: orders.length,
totalRevenue: orders.reduce((s, o) => s + o.total, 0),
avgOrderValue: orders.length > 0
? Math.round(orders.reduce((s, o) => s + o.total, 0) / orders.length)
: 0,
vipOrders: orders.filter(o => o.is_vip).length,
cancelledOrders: orders.filter(o => o.status === 'cancelled').length,
topProducts: orders
.flatMap(o => JSON.parse(o.items || '[]'))
.reduce((acc, item) => {
acc[item.name] = (acc[item.name] || 0) + item.quantity;
return acc;
}, {})
};
// Top product ကို ရှာပါ
stats.bestSeller = Object.entries(stats.topProducts)
.sort(([,a], [,b]) => b - a)[0]?.[0] ?? 'N/A';
return [{ json: stats }];

Report Email HTML:

<div style="font-family: Arial, sans-serif; max-width: 640px; margin: 0 auto;">
<div style="background: #1a1a2e; color: white; padding: 24px; border-radius: 8px 8px 0 0;">
<h1 style="margin:0; font-size:24px;">📊 Daily Sales Report</h1>
<p style="margin:8px 0 0; opacity:0.8;">{{ $json.date }}</p>
</div>
<div style="background: #f8f9fa; padding: 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px;">
<div style="background: white; padding: 16px; border-radius: 8px; border-left: 4px solid #4CAF50;">
<div style="font-size: 28px; font-weight: bold; color: #4CAF50;">{{ $json.totalOrders }}</div>
<div style="color: #666; font-size: 14px;">Total Orders</div>
</div>
<div style="background: white; padding: 16px; border-radius: 8px; border-left: 4px solid #2196F3;">
<div style="font-size: 28px; font-weight: bold; color: #2196F3;">{{ $json.totalRevenue.toLocaleString() }} ကျပ်</div>
<div style="color: #666; font-size: 14px;">Total Revenue</div>
</div>
<div style="background: white; padding: 16px; border-radius: 8px; border-left: 4px solid #FF9800;">
<div style="font-size: 28px; font-weight: bold; color: #FF9800;">{{ $json.avgOrderValue.toLocaleString() }} ကျပ်</div>
<div style="color: #666; font-size: 14px;">Avg Order Value</div>
</div>
<div style="background: white; padding: 16px; border-radius: 8px; border-left: 4px solid #9C27B0;">
<div style="font-size: 28px; font-weight: bold; color: #9C27B0;">⭐ {{ $json.vipOrders }}</div>
<div style="color: #666; font-size: 14px;">VIP Orders</div>
</div>
</div>
<div style="background: white; padding: 16px 24px; border-top: 1px solid #eee;">
<p>🏆 Best Seller: <strong>{{ $json.bestSeller }}</strong></p>
</div>
</div>

Customer ၏ Message ကို AI ဖြင့် Auto-reply:

Webhook: Customer Message
AI: Sentiment Negative?
Angry Customer 😠
Flag as Urgent
Slack: #support-urgent
Human Agent Assignment
Normal Query 😊
AI: Generate Reply
Gmail: Auto-reply
Log to CRM
AI Prompt for Auto-Reply:
"""
You are a customer service representative for Myanmar Online Shop.
Reply in a friendly, professional manner in Myanmar language.
Customer message: {{ $json.message }}
Customer name: {{ $json.customerName }}
Order ID (if mentioned): {{ $json.orderId ?? 'N/A' }}
Guidelines:
- Keep replies under 150 words
- If asking about order status, say you'll check and follow up
- Be empathetic and solution-focused
- Sign off as "MOS Customer Support Team"
"""
Phase 1: Setup (ရက် ၁)
□ n8n Self-host on VPS (Docker Compose)
□ Domain + SSL Configure
□ Credentials: Gmail, Slack, MySQL, Stripe
Phase 2: Core Workflows (ရက် ၂-၃)
□ Order Processing Webhook
□ Payment Success/Fail Handling
□ Error Workflow (Global Alert)
Phase 3: Reporting (ရက် ၄)
□ Daily Sales Report (Schedule)
□ Weekly Summary
□ Monthly Revenue Report
Phase 4: AI Integration (ရက် ၅)
□ Customer Message Sentiment Analysis
□ Auto-reply for FAQ
□ Escalation to Human Agent
Phase 5: Polish (ရက် ၆-၇)
□ Test all Workflows in Staging
□ Set up Backup (Nightly)
□ Monitor first week of Production