Appearance
AI Agents for Email
The email system uses AI agents to handle incoming emails intelligently. Each agent has its own personality, system prompt, and can be assigned to specific workflows or used as defaults.
Agent Concepts
What is an Email Agent?
An email agent is an AI assistant configured to handle email conversations. Each agent has:
- System Prompt: Defines the agent's personality, role, and behavior
- Name: Used in email signatures
- Email Signature: Optional custom signature text appended to emails
- Default Settings: Can be set as default for email channel or all channels
Agent Selection Priority
When an email arrives, the system selects an agent in this order:
- Workflow-Assigned Agent: If a workflow has an
assistant_id, that agent is used - Routing Rules: If routing rules match the email content/intent, the target agent is selected
- Default Email Agent: The agent marked as
is_default_email = truefor the tenant - General Default: The agent marked as
is_default = true(fallback)
Agent Assignment
Once an agent is selected:
- The agent is assigned to the conversation
- Assignment is recorded in
email_agent_assignmentstable - The conversation's
assistant_idis updated - All responses from that conversation use the assigned agent
Configuring Agents for Email
Setting Up an Email Agent
- Navigate to Assistants page
- Create or edit an assistant
- Configure the agent:
- Name: This will appear in email signatures
- System Prompt: Define how the agent should respond to emails
- Email Signature: Optional custom signature (company info, contact details, etc.)
- Default for Email: Check to make this the default email agent
Email Signature Format
Email signatures are automatically generated with:
- Random Signoff: One of: Thanks, Cheers, Best, Regards, Sincerely, Warm regards, Best regards, Kind regards, Thank you, Take care
- Agent Name: The name configured for the agent
- Custom Signature: Optional text from the agent's email signature field
Example signature:
Best regards,
Sarah Johnson
Customer Success Manager
Acme Corp
support@acme.comSystem Prompt Best Practices
When writing system prompts for email agents:
- Be Specific: Clearly define the agent's role and expertise
- Set Tone: Specify professional, friendly, technical, etc.
- Include Context: Reference business information, services, policies
- Define Boundaries: What the agent can and cannot do
- Provide Examples: Show desired response style
Example:
You are Sarah, a customer success manager for Acme Corp, a web hosting company.
You are friendly, professional, and solution-oriented. You help customers with:
- Account questions
- Billing inquiries
- Technical support escalations
- Service recommendations
Always be empathetic and aim to resolve issues quickly. If you cannot help,
politely escalate to the appropriate team.Workflows with Agents
Assigning Agents to Workflows
When creating or editing a workflow, you can assign a specific agent:
- In the workflow form, select an Agent from the dropdown
- This agent will handle all emails matching that workflow
- The agent uses the workflow context as guidance (not as a template)
How Agents Use Workflows
Workflows provide guidance to agents, not rigid templates:
- Workflow Context: Business information, services, pricing (used as reference)
- Response Template: Tone and structure guidance (agent adapts naturally)
- Workflow Steps: Instructions for what to do (extract info, create tickets, etc.)
The agent generates natural, conversational responses while following workflow guidance.
Example: Sales Workflow with Agent
Workflow Context:
We offer three hosting plans:
- Starter: $29/month (10GB storage, 100GB bandwidth)
- Professional: $79/month (100GB storage, 1TB bandwidth)
- Enterprise: $199/month (unlimited storage and bandwidth)Agent Response (not template):
Hi John,
Thanks for your interest in our hosting services! Based on your needs for a small business website, I'd recommend our Professional plan at $79/month. It includes 100GB storage and 1TB bandwidth, which should be perfect for your requirements.
Would you like me to set up a trial account so you can test it out?
Best regards,
Sarah Johnson
Customer Success ManagerAgent Handoffs
When Handoffs Happen
Agents can hand off emails to other agents when:
- Routing Rules Match: A routing rule detects specific keywords or intents
- Specialization Needed: The current agent determines another agent is better suited
- Escalation Required: Complex issues need specialized expertise
Routing Rules for Email
Create routing rules to automatically hand off emails:
- Navigate to Routing Rules page
- Create a rule with:
- Trigger Keywords: Words that indicate a handoff is needed
- Trigger Intent: Intent classification (sales, support, billing, technical)
- Target Agent: The agent to hand off to
- Channels: Include "email" in the channels list
Example rule:
- Trigger Keywords: ["refund", "cancel", "billing issue"]
- Trigger Intent: "billing"
- Target Agent: "Billing Specialist"
- Channels: ["email"]
Handoff Process
When a handoff occurs:
- Current agent generates a handoff message
- Conversation is transferred to the new agent
- Handoff message is queued and sent with delay
- Handoff history is recorded in conversation metadata
- Future emails in the conversation use the new agent
Handoff Guardrails
To prevent excessive handoffs and ensure a smooth customer experience, the system includes configurable guardrails:
Maximum Handoffs Per Conversation
- Limits the total number of times a conversation can be transferred between agents
- Default: 3 handoffs per conversation
- Range: 1-10
- Prevents conversations from being passed around indefinitely
Cooldown Period
- Prevents rapid successive handoffs
- Two settings:
- Minimum Messages: Number of messages required before next handoff (default: 2)
- Minimum Minutes: Time in minutes required before next handoff (default: 5)
- Both conditions must be met before another handoff is allowed
Loop Prevention
- Prevents handoff loops (e.g., Agent A → Agent B → Agent A → Agent B)
- Checks if target agent was used in the last 2 handoffs
- Default: Enabled
- Prevents frustrating back-and-forth transfers
Time-Based Limits (Optional)
- Maximum handoffs per hour per conversation
- Prevents excessive handoffs within a short time window
- Default: No limit (null)
- Can be set to any positive number (e.g., 2 handoffs per hour)
Configuring Guardrails
- Navigate to Handoff Settings page
- Scroll to Guardrail Settings section
- Configure each setting:
- Maximum Handoffs Per Conversation: Set limit (1-10)
- Cooldown Settings: Set minimum messages and minutes
- Prevent Handoff Loops: Toggle on/off
- Maximum Handoffs Per Hour: Set limit or leave empty for no limit
- Click Save Settings
Guardrail Behavior
When a handoff would violate a guardrail:
- The handoff is prevented
- An error message explains why (e.g., "Maximum handoffs per conversation reached (3)")
- The conversation remains with the current agent
- The customer continues with the same agent without interruption
This ensures customers aren't frustrated by excessive transfers while still allowing necessary handoffs for specialized assistance.
Conversational AI Without Workflows
When No Workflow Matches
If an email doesn't match any workflow:
- System selects default email agent or general assistant
- Agent uses conversational AI with:
- Agent's system prompt
- Email context library entries
- Cross-channel conversation history
- Business information from tenant config
- Agent generates natural, helpful response
- Response is still queued with delay
Best Practices
- Set Default Email Agent: Always have a default email agent configured
- Use Context Library: Add business information to context library for all agents
- Monitor Conversations: Review agent responses and adjust system prompts
- Test Handoffs: Verify routing rules work correctly
Response Timing
Natural Delays
All email responses are queued with a 5-15 minute random delay to:
- Appear more human-like
- Avoid immediate automated responses
- Give agents time to "think" about responses
Queue Processing
- Email queue worker processes queued emails every 2 minutes
- Emails are sent when their scheduled time arrives
- Failed sends are retried with exponential backoff (max 3 retries)
Monitoring Agent Performance
View Agent Assignments
In Email Conversations page:
- See which agent handled each conversation
- View handoff history if agents were transferred
- Review agent signatures in email previews
Agent Assignment History
The email_agent_assignments table tracks:
- Which agent was assigned
- When the assignment happened
- Why the agent was selected (workflow_match, intent_based, handoff, default, routing_rule)
Best Practices
- Create Specialized Agents: Different agents for sales, support, billing, etc.
- Use Descriptive Names: Agent names appear in signatures, make them professional
- Keep System Prompts Updated: Update prompts as business needs change
- Test Agent Responses: Send test emails to verify agent behavior
- Monitor Handoffs: Review handoff patterns to optimize routing rules
- Customize Signatures: Add company info, titles, contact details to signatures
Next Steps
- Workflows Guide - Learn about workflow configuration
- Routing Rules - Set up agent handoffs
- Troubleshooting - Resolve agent issues

