اپنا پہلا ایجنٹ بنانا
یہ گائیڈ آپ کو ایک کارٹ ریکوری ایجنٹ بنانے کے مراحل سے گزارتی ہے، یعنی ایک ایسا AI ایجنٹ جو چھوڑے گئے کارٹس کی نگرانی کرتا ہے اور Brevo کے MCP ٹولز کی مدد سے ای میل، SMS اور WhatsApp پر ذاتی نوعیت کی ریکوری سیکوینس چلاتا ہے۔
پیشگی شرائط
- API کلید والا Brevo اکاؤنٹ (یہاں سے حاصل کریں)
- کنفیگر شدہ Brevo MCP سرور (سیٹ اپ گائیڈ)
- Claude Desktop، Claude Code، یا کوئی بھی MCP کے ساتھ ہم آہنگ کلائنٹ
- کارٹ ریکوری کے لیے Brevo میں بنائے گئے ای میل ٹیمپلیٹس
ایجنٹس کیسے کام کرتے ہیں
ایجنٹ ایک markdown فائل ہے جو یہ متعین کرتی ہے:
- شناخت، ایجنٹ کیا کرتا ہے اور اس کی پابندیاں کیا ہیں
- ٹولز، وہ کن MCP ٹولز تک رسائی رکھتا ہے
- ہدایات، اسے کیسے سوچنا اور عمل کرنا چاہیے
- حفاظتی حدود، اسے کبھی کیا نہیں کرنا چاہیے
جب ایجنٹ چلایا جاتا ہے تو وہ ہدف پر غور کرنے، مناسب ٹولز منتخب کرنے اور Brevo کے API پر کارروائیاں انجام دینے کے لیے ایک LLM استعمال کرتا ہے۔
Marketer: "Set up cart recovery for carts over $50" ↓Agent reads its specification (tools, constraints) ↓Agent reasons: "I need to create a segment, design a sequence, set up tracking" ↓Agent calls: brevo/create-segment → brevo/send-email → brevo/send-sms → brevo/track-event ↓Result: 3-step recovery sequence active, tracking events flowingمرحلہ 1: ایجنٹ متعین کریں
cart-recovery-agent.md نام کی ایک فائل بنائیں:
---name: cart-recovery-agentdescription: Recover abandoned carts with personalized multi-channel sequencesversion: 1.0.0temperature: 0.2max_tokens: 4096tools: - brevo/list-contacts - brevo/get-contact - brevo/create-segment - brevo/send-email - brevo/send-sms - brevo/track-event - brevo/get-email-templates - brevo/get-email-statstriggers: - event: cart_abandoned conditions: - cart_value: "> 50" - time_since_activity: "> 30m" - schedule: "0 */4 * * *"permissions: - contacts:read - email:send - sms:send - events:write---
# Cart Recovery Agent
You are an e-commerce cart recovery specialist working with Brevo'sengagement platform. Your goal is to recover abandoned carts throughpersonalized, well-timed multi-channel outreach.
## Strategy
When a cart is abandoned:
1. **Wait 1 hour**, then send a reminder email with cart contents2. **Wait 24 hours**, if no open → send SMS with urgency message3. **Wait 48 hours**, if still no recovery → send final email with incentive (discount code if cart value > $100)
## Decision Framework
- Cart value < $50: Skip (not worth recovery cost)- Cart value $50-$100: Email only (2 touches)- Cart value $100-$250: Email + SMS (3 touches)- Cart value > $250: Email + SMS + personal outreach flag
## Rules
- NEVER send more than 3 messages per abandoned cart- NEVER contact customers who opted out of marketing- ALWAYS check if cart was recovered before sending next step- ALWAYS personalize with customer first name and cart items- ALWAYS track recovery events for attribution- Respect quiet hours: no SMS between 9pm-9am customer local time
## Email Templates
Use these Brevo template IDs:- Reminder (step 1): template_id 101- Urgency (step 2): template_id 102- Incentive (step 3): template_id 103
## Metrics to Track
- `cart_recovery_email_sent`, recovery email dispatched- `cart_recovery_sms_sent`, recovery SMS dispatched- `cart_recovered`, customer completed purchase- `cart_recovery_failed`, sequence completed without recoveryمرحلہ 2: ٹولز رجسٹر کریں
ایجنٹ کو مخصوص Brevo MCP ٹولز تک رسائی درکار ہوتی ہے۔ فرنٹ میٹر کا tools فیلڈ طے کرتا ہے کہ ایجنٹ کون سے ٹولز چلا سکتا ہے۔ ایجنٹ چلتے وقت صرف انہی ٹولز کو کال کر سکتا ہے، باقی سب کچھ بلاک رہتا ہے۔
اس ایجنٹ کے تناظر میں ہر ٹول کا کام یہ ہے:
tools: # Read customer data and cart state - brevo/list-contacts # Find customers with abandoned carts - brevo/get-contact # Get individual customer details
# Create targeted segments - brevo/create-segment # Segment by cart value, time, behavior
# Send recovery messages - brevo/send-email # Transactional recovery emails - brevo/send-sms # SMS nudges for high-value carts
# Track outcomes - brevo/track-event # Log recovery attempts and results - brevo/get-email-stats # Check if emails were opened - brevo/get-email-templates # Verify templates existمرحلہ 3: ایگزیکیوشن چین بنائیں
پیچیدہ ایجنٹس کے لیے آپ ایک کثیر مرحلہ ایگزیکیوشن چین متعین کر سکتے ہیں جس میں مخصوص ذیلی ایجنٹس مختلف مراحل سنبھالتے ہیں:
steps: - agent: analyzer input: | Analyze the abandoned cart data for the past 4 hours. Goal: {task}
Use brevo/list-contacts to find contacts with CART_ABANDONED event in the last 4 hours. Segment by cart value tier.
- agent: sequencer input: | Based on this analysis, design recovery sequences: {previous}
For each tier, create the appropriate message sequence using the decision framework.
- agent: executor input: | Execute these recovery sequences via Brevo: {previous}
Send emails and SMS according to the timing rules. Track every action with brevo/track-event.
- agent: reporter input: | Generate a recovery report from these execution results: {previous}
Include: carts targeted, messages sent, early recoveries, projected revenue impact.مرحلہ 4: ایجنٹ کو ٹیسٹ کریں
Claude Code کے ساتھ
# Point Claude Code at your agent specclaude --mcp brevo "Run the cart recovery agent for abandoned carts in the last 4 hours"Claude Desktop کے ساتھ
Brevo MCP سرور کنفیگر ہو جانے کے بعد Claude سے پوچھیں:
میرا کارٹ ریکوری ایجنٹ چلائیں۔ پچھلے 4 گھنٹوں میں 50 ڈالر سے زیادہ کے چھوڑے گئے کارٹس دیکھیں اور ریکوری سیکوینس چلائیں۔
Claude یہ کرے گا:
- ایجنٹ کی اسپیسیفیکیشن پڑھے گا
- چھوڑے گئے کارٹس تلاش کرنے کے لیے
brevo/list-contactsکال کرے گا - فیصلہ سازی کے فریم ورک کے مطابق کارٹ کی مالیت پر سیگمنٹ بنائے گا
brevo/send-emailکے ذریعے ریکوری ای میلز بھیجے گاbrevo/send-smsکے ذریعے SMS فالو اپ قطار میں لگائے گاbrevo/track-eventکے ذریعے تمام ایونٹس ٹریک کرے گا
پروگرام کے ذریعے چلانا
import { TajoAgent } from "@tajo/agent-sdk";import { BrevoMCPServer } from "@tajo/brevo-mcp-server";
const brevo = new BrevoMCPServer({ apiKey: process.env.BREVO_API_KEY,});
const agent = new TajoAgent({ specPath: "./cart-recovery-agent.md", mcpServers: [brevo], model: "claude-sonnet-4-6",});
// Run the agentconst result = await agent.run( "Recover abandoned carts over $50 from the last 4 hours");
console.log(result.summary);// → "Processed 23 abandoned carts. Sent 23 reminder emails,// 8 SMS messages. 3 carts already recovered during execution."مرحلہ 5: ایجنٹ کو شیڈول کریں
ایجنٹ کو بار بار چلنے والے شیڈول پر چلائیں:
Cron پر مبنی
# In your agent spec frontmattertriggers: - schedule: "0 */4 * * *" # Every 4 hours timezone: "America/New_York"ایونٹ سے چلنے والا
triggers: - event: cart_abandoned conditions: - cart_value: "> 50" - time_since_activity: "> 30m" debounce: 5mویب ہک
triggers: - webhook: /agents/cart-recovery/trigger method: POST authentication: api_keyمرحلہ 6: نگرانی اور بہتری
Brevo ایونٹس کے ذریعے ایجنٹ کی کارکردگی ٹریک کریں:
-- Recovery rate by cart value tierSELECT CASE WHEN cart_value < 100 THEN '$50-$100' WHEN cart_value < 250 THEN '$100-$250' ELSE '$250+' END as tier, COUNT(*) as carts_targeted, SUM(CASE WHEN recovered THEN 1 ELSE 0 END) as recovered, ROUND(SUM(CASE WHEN recovered THEN 1 ELSE 0 END)::numeric / COUNT(*) * 100, 1) as recovery_rate_pct, SUM(CASE WHEN recovered THEN cart_value ELSE 0 END) as revenue_recoveredFROM cart_recovery_eventsWHERE created_at > NOW() - INTERVAL '30 days'GROUP BY tierORDER BY tier;مثال: ایک مکمل ایجنٹ سیشن
یہاں ایک مارکیٹر اور کارٹ ریکوری ایجنٹ کے درمیان حقیقی تعامل دیا گیا ہے:
Marketer: "Check abandoned carts from today and start recovery"
Agent: Checking for abandoned carts in the last 24 hours...
[Calls brevo/list-contacts with filter CART_ABANDONED_AT > today]
Found 47 abandoned carts:- 12 carts under $50 (skipping per policy)- 23 carts $50-$100 (email-only tier)- 8 carts $100-$250 (email + SMS tier)- 4 carts over $250 (email + SMS + flag for personal outreach)
Starting recovery sequences...
[Calls brevo/send-email × 35 with template_id 101][Calls brevo/track-event × 35 with event "cart_recovery_email_sent"]
✅ Step 1 complete:- 35 reminder emails sent- 12 SMS queued for 24h follow-up (high-value carts)- 4 carts flagged for personal outreach
Next check scheduled in 4 hours.Recovery tracking events: cart_recovery_email_sent (35), cart_recovery_sms_queued (12), cart_recovery_escalated (4)اگلے اقدامات
- ایجنٹ اسپیسیفیکیشن فارمیٹ، ایجنٹ markdown کا مکمل ریفرنس
- پہلے سے تیار ایجنٹس، استعمال کے لیے تیار مارکیٹنگ ایجنٹس
- اسکلز ریفرنس، تمام دستیاب MCP ٹولز
- Brevo MCP سرور، ٹول اسکیمے اور اجازتیں