Đăng ký quyền truy cập sớm

Nhập tên của bạn cùng email hoặc số điện thoại. Chúng tôi sẽ liên hệ và gửi thông tin truy cập Tajo.

Xây dựng tác nhân đầu tiên

Hướng dẫn này đưa bạn qua từng bước xây dựng một tác nhân khôi phục giỏ hàng, một tác nhân AI theo dõi các giỏ hàng bị bỏ dở và điều phối chuỗi khôi phục được cá nhân hóa qua email, SMS và WhatsApp bằng công cụ MCP của Brevo.

Điều kiện tiên quyết

  • Tài khoản Brevo có khóa API (lấy tại đây)
  • Máy chủ Brevo MCP đã cấu hình (hướng dẫn thiết lập)
  • Claude Desktop, Claude Code, hoặc bất kỳ client nào tương thích MCP
  • Mẫu email khôi phục giỏ hàng đã tạo sẵn trong Brevo

Tác nhân hoạt động ra sao

Tác nhân là một file markdown định nghĩa:

  1. Danh tính, tác nhân làm gì và bị ràng buộc bởi những gì
  2. Công cụ, tác nhân được dùng công cụ MCP nào
  3. Hướng dẫn, tác nhân nên suy luận và hành động thế nào
  4. Rào chắn, những việc tác nhân không bao giờ được làm

Khi được gọi, tác nhân dùng một LLM để suy luận về mục tiêu, chọn công cụ phù hợp và thực thi hành động qua API của Brevo.

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

Bước 1: định nghĩa tác nhân

Tạo một file tên là cart-recovery-agent.md:

---
name: cart-recovery-agent
description: Recover abandoned carts with personalized multi-channel sequences
version: 1.0.0
temperature: 0.2
max_tokens: 4096
tools:
- 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-stats
triggers:
- 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's
engagement platform. Your goal is to recover abandoned carts through
personalized, well-timed multi-channel outreach.
## Strategy
When a cart is abandoned:
1. **Wait 1 hour**, then send a reminder email with cart contents
2. **Wait 24 hours**, if no open → send SMS with urgency message
3. **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

Bước 2: đăng ký công cụ

Tác nhân cần quyền truy cập vào một số công cụ Brevo MCP cụ thể. Trường tools trong frontmatter xác định tác nhân được gọi những công cụ nào. Khi chạy, tác nhân chỉ gọi được đúng các công cụ đó, mọi thứ khác đều bị chặn.

Đây là vai trò của từng công cụ trong ngữ cảnh của tác nhân này:

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

Bước 3: tạo chuỗi thực thi

Với các tác nhân phức tạp, bạn có thể định nghĩa một chuỗi thực thi nhiều bước, trong đó các tác nhân con chuyên biệt đảm nhận từng giai đoạn khác nhau:

chain.yaml
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.

Bước 4: kiểm thử tác nhân

Với Claude Code

Terminal window
# Point Claude Code at your agent spec
claude --mcp brevo "Run the cart recovery agent for abandoned carts in the last 4 hours"

Với Claude Desktop

Sau khi máy chủ Brevo MCP đã được cấu hình, hãy yêu cầu Claude:

Chạy tác nhân khôi phục giỏ hàng của tôi. Kiểm tra các giỏ hàng bỏ dở trên 50 USD trong 4 giờ qua và thực thi chuỗi khôi phục.

Claude sẽ:

  1. Đọc đặc tả tác nhân
  2. Gọi brevo/list-contacts để tìm các giỏ hàng bỏ dở
  3. Phân nhóm theo giá trị giỏ hàng dựa trên khung ra quyết định
  4. Gửi email khôi phục qua brevo/send-email
  5. Xếp hàng SMS nhắc lại qua brevo/send-sms
  6. Ghi nhận mọi sự kiện qua brevo/track-event

Thực thi bằng mã lệnh

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 agent
const 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."

Bước 5: lên lịch cho tác nhân

Chạy tác nhân theo một lịch lặp lại:

Dựa trên cron

# In your agent spec frontmatter
triggers:
- schedule: "0 */4 * * *" # Every 4 hours
timezone: "America/New_York"

Dựa trên sự kiện

triggers:
- event: cart_abandoned
conditions:
- cart_value: "> 50"
- time_since_activity: "> 30m"
debounce: 5m

Webhook

triggers:
- webhook: /agents/cart-recovery/trigger
method: POST
authentication: api_key

Bước 6: giám sát và cải tiến

Theo dõi hiệu quả của tác nhân qua các sự kiện trong Brevo:

-- Recovery rate by cart value tier
SELECT
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_recovered
FROM cart_recovery_events
WHERE created_at > NOW() - INTERVAL '30 days'
GROUP BY tier
ORDER BY tier;

Ví dụ: một phiên làm việc hoàn chỉnh của tác nhân

Đây là một tương tác thực tế giữa người làm marketing và tác nhân khôi phục giỏ hàng:

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)

Bước tiếp theo

Đăng ký quyền truy cập sớm

Nhập tên của bạn cùng email hoặc số điện thoại. Chúng tôi sẽ liên hệ và gửi thông tin truy cập Tajo.

tự động nhận diện
Trợ lý AI

Xin chào! Hãy hỏi tôi về tài liệu.