첫 에이전트 만들기
이 가이드에서는 **장바구니 복구 에이전트(Cart Recovery Agent)**를 단계별로 만듭니다. 이 AI 에이전트는 이탈한 장바구니를 모니터링하고, Brevo의 MCP 도구를 사용하여 이메일·SMS·WhatsApp에 걸친 개인화된 복구 시퀀스를 오케스트레이션합니다.
사전 준비
- API 키가 있는 Brevo 계정 (여기에서 발급)
- 설정을 마친 Brevo MCP 서버 (설정 가이드)
- Claude Desktop, Claude Code 또는 MCP 호환 클라이언트
- Brevo에 생성해 둔 장바구니 복구용 이메일 템플릿
에이전트의 동작 방식
에이전트는 다음 항목을 정의하는 마크다운 파일입니다.
- 정체성: 에이전트가 하는 일과 제약 조건
- 도구: 접근할 수 있는 MCP 도구
- 지침: 추론하고 행동하는 방식
- 가드레일: 절대 해서는 안 되는 일
에이전트는 호출되면 LLM으로 목표를 추론하고, 알맞은 도구를 선택한 뒤, Brevo API에 대해 작업을 실행합니다.
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 flowing1단계: 에이전트 정의하기
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 recovery2단계: 도구 등록하기
에이전트는 특정 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 exist3단계: 실행 체인 구성하기
복잡한 에이전트라면 전문화된 하위 에이전트가 각 단계를 처리하는 다단계 실행 체인을 정의할 수 있습니다.
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_key6단계: 모니터링과 개선
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)다음 단계
- 에이전트 사양 형식: 에이전트 마크다운 전체 레퍼런스
- 사전 제작 에이전트: 바로 사용할 수 있는 마케팅 에이전트
- 스킬 레퍼런스: 사용 가능한 모든 MCP 도구
- Brevo MCP 서버: 도구 스키마와 권한