اطلب الوصول المبكر

أدخل اسمك الأول وبريدك الإلكتروني أو رقم هاتفك. سنتواصل معك لتزويدك بتفاصيل الوصول إلى Tajo.

دليل التكامل بين Tajo وBrevo

يرشدك هذا الدليل الشامل خلال دمج منصّة الولاء Tajo مع Brevo لإنشاء حملات تفاعل مؤتمتة وقوية مع العملاء.

نظرة عامة

يتيح لك التكامل بين Tajo وBrevo ما يلي:

  • مزامنة بيانات العملاء فورياً بين المنصّتين
  • أتمتة حملات الولاء بناءً على سلوك العميل
  • تتبّع التفاعل عبر البريد الإلكتروني وSMS وواتساب
  • تقسيم العملاء حسب مستوى الولاء وسلوك الشراء
  • إطلاق رسائل مخصّصة لأحداث الولاء الرئيسية

المتطلّبات المسبقة

قبل بدء التكامل، تأكّد من توفّر ما يلي:

  • حساب Tajo مع برنامج ولاء مُهيّأ
  • حساب Brevo مع وصول إلى API
  • مفاتيح API صالحة للمنصّتين
  • نقاط نهاية Webhook مُعدّة للمزامنة الفورية
  • شهادة SSL لنقل البيانات بأمان

الخطوة 1: إعداد المصادقة

إنشاء مفتاح API لـ Brevo

  1. سجّل الدخول إلى حساب Brevo الخاص بك
  2. انتقل إلى Account & Plan > API Keys
  3. انقر على Generate a new API key
  4. سمِّه “Tajo Integration”
  5. انسخ المفتاح واحفظه بأمان
Terminal window
# Store in environment variables
export BREVO_API_KEY="xkeysib-your-api-key-here"
export TAJO_WEBHOOK_SECRET="your-webhook-secret"

تهيئة التكامل في Tajo

من لوحة تحكم Tajo:

  1. انتقل إلى الإعدادات > عمليات التكامل
  2. اختر Brevo من القائمة
  3. أدخل مفتاح API الخاص بـ Brevo
  4. اضبط إعدادات المزامنة
{
"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"
]
}

الخطوة 2: مزامنة بيانات العملاء

تهيئة مزامنة جهات الاتصال

اضبط المزامنة التلقائية لجهات الاتصال لإبقاء بيانات العملاء محدَّثة:

// Sync customer on registration
async 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();
}

مزامنة أحداث الشراء

زامِن المشتريات تلقائياً لإطلاق حملات الولاء:

// Sync order completion
async 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)
});
}

الخطوة 3: إعداد الحملات المؤتمتة

حملة ترحيب بالعملاء الجدد

أنشئ سلسلة ترحيب مؤتمتة لأعضاء الولاء الجدد:

{
"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"
}
]
}

حملة الترقية بين المستويات

احتفِ بالترقيات بين المستويات تلقائياً:

// Webhook handler for tier upgrades
app.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 });
});

الخطوة 4: تتبّع أحداث الولاء

الأحداث الرئيسية التي يجب تتبّعها

اضبط التتبّع لأحداث الولاء الأساسية التالية:

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']
}
};

تنفيذ تتبّع الأحداث

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()
});
}
}

الخطوة 5: استراتيجية التقسيم

شرائح العملاء

أنشئ شرائح موجَّهة في Brevo من أجل حملات مخصّصة:

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"]
}
];

الخطوة 6: الاختبار والمراقبة

قائمة تحقّق لاختبار التكامل

  • مزامنة جهات الاتصال: يظهر العملاء الجدد في Brevo
  • مزامنة الطلبات: تُطلِق المشتريات الأحداث بشكل صحيح
  • تتبّع الأحداث: تُسجَّل كل أحداث الولاء
  • مُشغِّلات الحملات: تُرسَل الرسائل المؤتمتة بشكل سليم
  • التقسيم: ينتقل العملاء بين القوائم بشكل صحيح
  • تسليم Webhook: تعمل المزامنة الفورية بموثوقية

إعداد المراقبة

// Health check endpoint
app.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()
});
});

استكشاف المشكلات الشائعة وإصلاحها

حدود معدّل API

لدى Brevo حدود للمعدّل، لذا نفِّذ منطق إعادة المحاولة:

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;
}
}

مشكلات مزامنة البيانات

راقب تعارضات المزامنة وعالجها:

// Sync conflict resolution
async 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);
}
}

الخطوات التالية

  1. إعداد Webhooks للمزامنة الفورية
  2. إنشاء قوالب البريد الإلكتروني لحملات الولاء
  3. تهيئة أتمتة SMS للإشعارات العاجلة
  4. إعداد التحليلات لتتبّع الأداء

الدعم والموارد

اطلب الوصول المبكر

أدخل اسمك الأول وبريدك الإلكتروني أو رقم هاتفك. سنتواصل معك لتزويدك بتفاصيل الوصول إلى Tajo.

اكتشاف تلقائي
مساعد AI

مرحباً! اسألني أي شيء عن الوثائق.