Hướng dẫn tích hợp Tajo và Brevo
Hướng dẫn toàn diện này đưa bạn qua từng bước tích hợp nền tảng khách hàng thân thiết Tajo với Brevo để tạo ra các chiến dịch tương tác khách hàng tự động và mạnh mẽ.
Tổng quan
Tích hợp Tajo và Brevo cho phép bạn:
- Đồng bộ dữ liệu khách hàng theo thời gian thực giữa hai nền tảng
- Tự động hóa chiến dịch khách hàng thân thiết dựa trên hành vi khách hàng
- Theo dõi mức độ tương tác trên email, SMS và WhatsApp
- Phân khúc khách hàng theo hạng thân thiết và hành vi mua hàng
- Kích hoạt tin nhắn cá nhân hóa cho các sự kiện khách hàng thân thiết quan trọng
Điều kiện tiên quyết
Trước khi bắt đầu tích hợp, hãy đảm bảo bạn có:
- Tài khoản Tajo đã cấu hình chương trình khách hàng thân thiết
- Tài khoản Brevo có quyền truy cập API
- Khóa API hợp lệ cho cả hai nền tảng
- Endpoint webhook đã thiết lập để đồng bộ thời gian thực
- Chứng chỉ SSL để truyền dữ liệu an toàn
Bước 1: Thiết lập xác thực
Tạo khóa API Brevo
- Đăng nhập vào tài khoản Brevo của bạn
- Vào Account & Plan > API Keys
- Nhấp Generate a new API key
- Đặt tên là “Tajo Integration”
- Sao chép và lưu trữ khóa một cách an toàn
# Store in environment variablesexport BREVO_API_KEY="xkeysib-your-api-key-here"export TAJO_WEBHOOK_SECRET="your-webhook-secret"Cấu hình tích hợp Tajo
Trong bảng điều khiển Tajo của bạn:
- Vào Settings > Integrations
- Chọn Brevo từ danh sách
- Nhập khóa API Brevo của bạn
- Cấu hình các cài đặt đồng bộ
{ "brevo_api_key": "xkeysib-your-api-key-here", "sync_frequency": "real-time", "sync_contacts": true, "sync_orders": true, "sync_events": true, "loyalty_attributes": [ "LOYALTY_POINTS", "LOYALTY_TIER", "TOTAL_SPENT", "LAST_PURCHASE" ]}Bước 2: Đồng bộ dữ liệu khách hàng
Cấu hình đồng bộ liên hệ
Thiết lập đồng bộ liên hệ tự động để dữ liệu khách hàng luôn được cập nhật:
// Sync customer on registrationasync function syncCustomerToBrevo(customer) { const brevoData = { email: customer.email, attributes: { FIRSTNAME: customer.firstName, LASTNAME: customer.lastName, PHONE: customer.phone, LOYALTY_ID: customer.loyaltyId, LOYALTY_POINTS: customer.points, LOYALTY_TIER: customer.tier, SIGNUP_DATE: customer.createdAt, TOTAL_SPENT: customer.totalSpent, PREFERRED_CATEGORIES: customer.categories, BIRTHDAY: customer.birthday }, listIds: [getListForTier(customer.tier)] };
const response = await fetch('https://api.brevo.com/v3/contacts', { method: 'POST', headers: { 'Content-Type': 'application/json', 'api-key': process.env.BREVO_API_KEY }, body: JSON.stringify(brevoData) });
return response.json();}Đồng bộ sự kiện mua hàng
Tự động đồng bộ các giao dịch mua để kích hoạt chiến dịch khách hàng thân thiết:
// Sync order completionasync function syncOrderToBrevo(order, customer) { // Create order in Brevo const orderData = { id: order.id, email: customer.email, products: order.items.map(item => ({ id: item.productId, name: item.name, quantity: item.quantity, price: item.price, category: item.category })), revenue: order.total, date: order.createdAt };
await fetch('https://api.brevo.com/v3/ecommerce/orders', { method: 'POST', headers: { 'Content-Type': 'application/json', 'api-key': process.env.BREVO_API_KEY }, body: JSON.stringify(orderData) });
// Create loyalty event const eventData = { email: customer.email, event: 'Purchase Completed', properties: { order_id: order.id, amount: order.total, points_earned: order.pointsEarned, loyalty_tier: customer.tier, tier_upgraded: order.tierUpgraded, products: order.items.map(i => i.name).join(', ') } };
await fetch('https://api.brevo.com/v3/events', { method: 'POST', headers: { 'Content-Type': 'application/json', 'api-key': process.env.BREVO_API_KEY }, body: JSON.stringify(eventData) });}Bước 3: Thiết lập chiến dịch tự động
Chiến dịch chào mừng cho khách hàng mới
Tạo một chuỗi chào mừng tự động cho các thành viên thân thiết mới:
{ "campaign_name": "Tajo Loyalty Welcome Series", "trigger": { "event": "Contact Created", "conditions": { "LOYALTY_ID": "exists", "SIGNUP_DATE": "today" } }, "emails": [ { "delay": "immediate", "template_id": 101, "subject": "Welcome to Tajo Loyalty! Here's your {{params.welcome_bonus}} points bonus", "params": { "welcome_bonus": "500", "loyalty_tier": "Bronze", "next_tier_points": "1000" } }, { "delay": "3 days", "template_id": 102, "subject": "Don't forget to use your {{params.welcome_bonus}} bonus points!" }, { "delay": "1 week", "template_id": 103, "subject": "Here's how to earn points faster with Tajo" } ]}Chiến dịch thăng hạng
Tự động chúc mừng khi khách hàng thăng hạng:
// Webhook handler for tier upgradesapp.post('/webhook/tier-upgrade', (req, res) => { const { customer, previousTier, newTier } = req.body;
const campaignData = { email: customer.email, template_id: getTierUpgradeTemplate(newTier), params: { customer_name: customer.firstName, new_tier: newTier, previous_tier: previousTier, new_benefits: getTierBenefits(newTier), points_balance: customer.points } };
// Send congratulations email sendBrevoEmail(campaignData);
// Add to tier-specific list addToBrevoList(customer.email, getTierListId(newTier));
res.status(200).json({ success: true });});Bước 4: Theo dõi sự kiện khách hàng thân thiết
Các sự kiện chính cần theo dõi
Thiết lập theo dõi cho những sự kiện khách hàng thân thiết thiết yếu sau:
const loyaltyEvents = { // Account Events 'Account Created': { properties: ['signup_source', 'referral_code', 'welcome_bonus'] }, 'Profile Updated': { properties: ['updated_fields', 'marketing_consent'] },
// Purchase Events 'Purchase Completed': { properties: ['order_total', 'points_earned', 'loyalty_tier', 'products'] }, 'Product Returned': { properties: ['return_reason', 'points_deducted', 'refund_amount'] },
// Loyalty Events 'Points Earned': { properties: ['points_amount', 'earning_reason', 'total_balance'] }, 'Points Redeemed': { properties: ['points_used', 'reward_type', 'remaining_balance'] }, 'Tier Upgraded': { properties: ['previous_tier', 'new_tier', 'upgrade_benefits'] },
// Engagement Events 'Email Opened': { properties: ['campaign_type', 'subject_line', 'device'] }, 'Reward Browsed': { properties: ['reward_category', 'reward_name', 'points_required'] }, 'Referral Made': { properties: ['referral_method', 'referee_email', 'referral_bonus'] }};Triển khai theo dõi sự kiện
class TajoBrevoEventTracker { constructor(apiKey) { this.apiKey = apiKey; this.baseUrl = 'https://api.brevo.com/v3'; }
async trackEvent(customerEmail, eventName, properties = {}) { const eventData = { email: customerEmail, event: eventName, properties: { timestamp: new Date().toISOString(), source: 'tajo_platform', ...properties } };
try { const response = await fetch(`${this.baseUrl}/events`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'api-key': this.apiKey }, body: JSON.stringify(eventData) });
if (!response.ok) { throw new Error(`Event tracking failed: ${response.statusText}`); }
return await response.json(); } catch (error) { console.error('Brevo event tracking error:', error); throw error; } }
// Convenience methods for common events async trackPurchase(customer, order) { return this.trackEvent(customer.email, 'Purchase Completed', { order_id: order.id, order_total: order.total, currency: order.currency, points_earned: order.pointsEarned, loyalty_tier: customer.tier, items_count: order.items.length, first_purchase: customer.orderCount === 1 }); }
async trackTierUpgrade(customer, previousTier) { return this.trackEvent(customer.email, 'Tier Upgraded', { previous_tier: previousTier, new_tier: customer.tier, points_balance: customer.points, benefits_unlocked: getTierBenefits(customer.tier), upgrade_date: new Date().toISOString() }); }}Bước 5: Chiến lược phân khúc
Phân khúc khách hàng
Tạo các phân khúc có mục tiêu trong Brevo cho những chiến dịch cá nhân hóa:
const loyaltySegments = [ // Tier-based segments { name: "Bronze Members", conditions: { LOYALTY_TIER: "Bronze" }, campaigns: ["tier_upgrade_promotion", "engagement_boost"] }, { name: "Silver Members", conditions: { LOYALTY_TIER: "Silver" }, campaigns: ["premium_offers", "early_access"] }, { name: "Gold Members", conditions: { LOYALTY_TIER: "Gold" }, campaigns: ["vip_treatment", "exclusive_rewards"] }, { name: "Platinum Members", conditions: { LOYALTY_TIER: "Platinum" }, campaigns: ["luxury_experiences", "personal_offers"] },
// Behavior-based segments { name: "High Spenders", conditions: { TOTAL_SPENT: ">1000" }, campaigns: ["luxury_catalog", "big_spender_rewards"] }, { name: "Frequent Shoppers", conditions: { PURCHASE_FREQUENCY: "weekly" }, campaigns: ["convenience_offers", "bulk_discounts"] }, { name: "At-Risk Customers", conditions: { LAST_PURCHASE: ">90 days" }, campaigns: ["win_back", "special_incentives"] }, { name: "Birthday Month", conditions: { BIRTHDAY: "this_month" }, campaigns: ["birthday_specials", "bonus_points"] }];Bước 6: Kiểm thử và giám sát
Danh sách kiểm tra tích hợp
- Đồng bộ liên hệ: Khách hàng mới xuất hiện trong Brevo
- Đồng bộ đơn hàng: Các giao dịch mua kích hoạt sự kiện đúng cách
- Theo dõi sự kiện: Mọi sự kiện khách hàng thân thiết đều được ghi nhận
- Trigger chiến dịch: Email tự động được gửi đúng cách
- Phân khúc: Khách hàng chuyển giữa các danh sách chính xác
- Gửi webhook: Đồng bộ thời gian thực hoạt động ổn định
Thiết lập giám sát
// Health check endpointapp.get('/integration/health', async (req, res) => { const checks = { brevo_api: await checkBrevoConnection(), webhook_delivery: await checkWebhookDelivery(), event_tracking: await checkEventTracking(), campaign_triggers: await checkCampaignTriggers() };
const allHealthy = Object.values(checks).every(check => check.status === 'ok');
res.status(allHealthy ? 200 : 503).json({ status: allHealthy ? 'healthy' : 'degraded', checks, timestamp: new Date().toISOString() });});Khắc phục các sự cố thường gặp
Giới hạn tần suất API
Brevo có giới hạn tần suất, hãy triển khai logic thử lại:
async function makeBrevoRequest(url, options, retries = 3) { try { const response = await fetch(url, options);
if (response.status === 429) { const retryAfter = response.headers.get('Retry-After') || 60; await new Promise(resolve => setTimeout(resolve, retryAfter * 1000)); return makeBrevoRequest(url, options, retries - 1); }
return response; } catch (error) { if (retries > 0) { await new Promise(resolve => setTimeout(resolve, 5000)); return makeBrevoRequest(url, options, retries - 1); } throw error; }}Vấn đề đồng bộ dữ liệu
Giám sát và xử lý các xung đột đồng bộ:
// Sync conflict resolutionasync function resolveSyncConflict(tajoData, brevoData) { // Use most recent timestamp as source of truth const tajoUpdated = new Date(tajoData.updatedAt); const brevoUpdated = new Date(brevoData.modifiedAt);
if (tajoUpdated > brevoUpdated) { // Update Brevo with Tajo data await updateBrevoContact(brevoData.id, tajoData); } else { // Update Tajo with Brevo data await updateTajoCustomer(tajoData.id, brevoData); }}Bước tiếp theo
- Thiết lập webhook để đồng bộ thời gian thực
- Tạo mẫu email cho các chiến dịch khách hàng thân thiết
- Cấu hình tự động hóa SMS cho những thông báo khẩn
- Thiết lập phân tích để theo dõi hiệu quả
Hỗ trợ và tài nguyên
- Hỗ trợ tích hợp: [email protected]
- Tài liệu API Brevo: api.brevo.com
- Kho mã nguồn mẫu: github.com/tajo/brevo-integration
- Liên hệ hỗ trợ: /vi/contact