Poproś o wcześniejszy dostęp

Podaj imię oraz adres e-mail lub numer telefonu. Wyślemy Ci informacje o dostępie do Tajo.

Budowa pierwszego agenta

Ten przewodnik przeprowadzi Cię przez budowę agenta odzyskiwania koszyków (Cart Recovery Agent), agenta AI, który monitoruje porzucone koszyki i orkiestruje spersonalizowaną sekwencję odzyskiwania w kanałach email, SMS i WhatsApp przy użyciu narzędzi MCP Brevo.

Wymagania wstępne

  • Konto Brevo z kluczem API (załóż je tutaj)
  • Skonfigurowany serwer Brevo MCP (przewodnik konfiguracji)
  • Claude Desktop, Claude Code lub dowolny klient zgodny z MCP
  • Szablony emaili do odzyskiwania koszyków utworzone w Brevo

Jak działają agenci

Agent to plik markdown, który definiuje:

  1. Tożsamość, czym agent się zajmuje i jakie ma ograniczenia
  2. Narzędzia, do których narzędzi MCP ma dostęp
  3. Instrukcje, jak ma rozumować i działać
  4. Zabezpieczenia, czego nigdy nie może zrobić

Po wywołaniu agent używa LLM, aby przeanalizować cel, dobrać właściwe narzędzia i wykonać działania na API 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

Krok 1: zdefiniuj agenta

Utwórz plik o nazwie 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

Krok 2: zarejestruj narzędzia

Agent potrzebuje dostępu do konkretnych narzędzi MCP Brevo. Pole tools we frontmatterze określa, które narzędzia agent może wywoływać. Podczas działania agent może wywołać wyłącznie te narzędzia, wszystko inne jest zablokowane.

Oto do czego służy każde narzędzie w kontekście tego agenta:

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

Krok 3: utwórz łańcuch wykonania

W przypadku złożonych agentów możesz zdefiniować wieloetapowy łańcuch wykonania, w którym wyspecjalizowani subagenci obsługują różne fazy:

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.

Krok 4: przetestuj agenta

W 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"

W Claude Desktop

Gdy serwer Brevo MCP jest już skonfigurowany, poproś Claude:

Uruchom mojego agenta odzyskiwania koszyków. Sprawdź porzucone koszyki o wartości powyżej 50 $ z ostatnich 4 godzin i wykonaj sekwencję odzyskiwania.

Claude wykona następujące kroki:

  1. Odczyta specyfikację agenta
  2. Wywoła brevo/list-contacts, aby znaleźć porzucone koszyki
  3. Podzieli je na segmenty według wartości koszyka zgodnie z ramami decyzyjnymi
  4. Wyśle emaile odzyskujące przez brevo/send-email
  5. Zakolejkuje wiadomości SMS jako kontynuację przez brevo/send-sms
  6. Zarejestruje wszystkie zdarzenia przez brevo/track-event

Uruchomienie programistyczne

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

Krok 5: zaplanuj uruchamianie agenta

Uruchamiaj agenta według cyklicznego harmonogramu:

Na podstawie crona

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

Sterowane zdarzeniami

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

Krok 6: monitoruj i usprawniaj

Śledź skuteczność agenta na podstawie zdarzeń 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;

Przykład: pełna sesja agenta

Oto rzeczywista interakcja między marketerem a agentem odzyskiwania koszyków:

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)

Następne kroki

Poproś o wcześniejszy dostęp

Podaj imię oraz adres e-mail lub numer telefonu. Wyślemy Ci informacje o dostępie do Tajo.

rozpoznajemy automatycznie
Asystent AI

Cześć! Zapytaj mnie o dokumentację.