Email Channel
Let your AI agent receive and reply to customer emails automatically, with built-in escalation to human agents when needed.
How It Works
- A customer sends an email to your support address (e.g., support@yourbank.com)
- Resend receives the email and sends a webhook to your Tavio instance
- Tavio creates a conversation, runs the email through RAG, and generates an AI reply
- The AI reply is sent back to the customer from your configured From address
- If escalation triggers fire (keywords, unresolved after N replies), it hands off to your human team
Prerequisites
- A Resend account with a verified domain
- An inbound email address configured in Resend
- Environment variables:
RESEND_API_KEYandRESEND_WEBHOOK_SECRET
Setup Steps
- Sign up at resend.com and verify your domain (e.g., yourbank.com)
- In Resend dashboard, go to Webhooks and add your inbound webhook URL:
Inbound Webhook URL
text
${platformUrl}/api/v1/channels/email/inbound- Copy your Resend webhook secret and add it to your environment variables
- Go to Dashboard → Channels → Email → Configuration
- Enter your inbound address, from address, and agent settings
- Configure escalation rules (keywords, threshold, escalation email)
- Save and send a test email to your inbound address
Agent Reply Flow
Email Processing Pipeline
text
Inbound Email (Resend webhook)
-> Verify webhook signature (HMAC)
-> Parse email (from, subject, body, attachments)
-> Check allowed sender domains (if configured)
-> Check escalation keywords (immediate escalate if matched)
-> Create/resume conversation
-> Run through RAG pipeline (knowledge base search)
-> Generate AI response (max 1000 tokens)
-> Append email signature
-> Send reply via Resend
-> Check escalation threshold (auto-escalate if exceeded)Escalation Rules
Emails are escalated to your human team when:
- Keyword match — The customer email contains words like "fraud," "urgent," or "speak to human"
- Reply threshold — The conversation exceeds N back-and-forth replies without resolution
- AI signal — The AI response contains [ESCALATE] (automatic detection of complex issues)
- Low confidence — The AI is unsure about its answer
When escalated, the full conversation history is forwarded to your escalation email and an escalation ticket is created in the dashboard.
Security
- All inbound webhooks are verified using HMAC-SHA256 signatures
- PII (account numbers, SSNs, etc.) is automatically scrubbed from AI responses
- Allowed sender domains can restrict who can email your agent
- Email content is sanitized to prevent injection attacks
- All emails are logged and auditable in the dashboard
API Endpoint
Inbound Email Webhook
bash
# Resend sends this to your server when an email arrives
POST /api/v1/channels/email/inbound
Content-Type: application/json
svix-id: msg_xxx
svix-timestamp: 1234567890
svix-signature: v1,base64signature
{
"type": "email.received",
"data": {
"from": "customer@example.com",
"to": "support@yourbank.com",
"subject": "Balance inquiry",
"text": "What is my account balance?",
"html": "<p>What is my account balance?</p>"
}
}Limits
Max AI Response
1000 tokens (~750 words)
Attachments
Parsed but not processed by AI
Rate Limit
Per your Resend plan
Thread Matching
By subject + sender email