AI Draft Generation
AI draft generation analyzes email threads and creates contextual replies using Anthropic’s Claude.How Draft Generation Works
User Triggers Generation
A user with Send or Admin permission clicks Generate Draft on an email thread.
Thread Context Prepared
The system extracts all messages from the thread and formats them:HTML tags are stripped to provide clean text context to the AI.
Draft Generation Prompt
Fromdraft/generate/route.ts:26, the full prompt structure:
The AI automatically detects the customer’s language and replies in the same language. No additional configuration needed.
Service Documents
Service documents are the key to customizing AI behavior. They provide context about your product, policies, and common issues.What to Include in Service Documents
Product Information:- Feature descriptions
- Pricing details
- Technical specifications
- Known limitations
- Refund policies
- Shipping information
- Account management procedures
- Cancellation terms
- Frequently asked questions
- Troubleshooting steps
- Workarounds for known bugs
- Setup instructions
- Company voice
- Level of formality
- Preferred greetings
- Standard phrases
Example Service Document
Documents can be plain text or Markdown. The AI understands both formats equally well.
Updating Service Documents
Admins can edit service documents in Settings:- Open Settings
- Select the Services tab
- Click on a service to expand it
- Edit the Document field
- Click Save
Talk to Draft
Talk to Draft allows users to iteratively refine AI-generated drafts using natural language instructions.How Talk to Draft Works
User Provides Instruction
In the draft editor, user enters an instruction like:
- “Make it more casual”
- “Add information about our refund policy”
- “Shorten this to 2 paragraphs”
Effective Talk to Draft Instructions
Tone Adjustments
Tone Adjustments
- “Make it more formal”
- “Use a friendlier tone”
- “Sound more apologetic”
- “Be more direct and concise”
Content Changes
Content Changes
- “Add our refund policy details”
- “Include the tracking link: https://example.com/track”
- “Mention that we’ll follow up in 24 hours”
- “Remove the section about pricing”
Structural Changes
Structural Changes
- “Break this into bullet points”
- “Combine the first two paragraphs”
- “Add a numbered list of steps”
- “Make it shorter”
Language Adjustments
Language Adjustments
- “Use simpler language”
- “Avoid technical jargon”
- “Make it more conversational”
- “Sound more professional”
Talk to Draft preserves the signature automatically. Focus your instructions on the main content.
Translation Feature
DelightBridge can translate drafts to Korean for bilingual support teams.How Translation Works
Fromdraft/translate/route.ts:15:
Translations are for reference only. The draft content itself is not replaced. This allows bilingual teams to verify translations before sending.
Customizing Translation Behavior
To translate to a different language, modify the prompt indraft/translate/route.ts:15:
AI Model Configuration
DelightBridge uses Anthropic’s Claude Sonnet 4 for all AI operations.Model Selection
From the route handlers:Changing the AI Model
To use a different Claude model, update themodel parameter in:
/api/draft/generate/route.ts/api/draft/talk/route.ts/api/draft/translate/route.ts
claude-sonnet-4-6- Best balance of speed and quality (current)claude-opus-4- Highest quality, slower, more expensiveclaude-haiku-4- Fastest, most affordable, lower quality
Environment Variables
AI features require an Anthropic API key:Best Practices
Keep service documents focused
Keep service documents focused
Include only information relevant to customer support. Avoid internal details, code snippets, or excessive background.
Update documents regularly
Update documents regularly
When products change, policies update, or new issues emerge, update service documents immediately to maintain AI accuracy.
Use examples in documents
Use examples in documents
Show example responses for common scenarios. The AI learns from these patterns.
Test draft generation frequently
Test draft generation frequently
After updating service documents, generate drafts for typical threads to verify the AI is responding appropriately.
Combine generation with Talk to Draft
Combine generation with Talk to Draft
Don’t expect perfect drafts initially. Use Talk to Draft to refine and teach the AI your preferences over time.
Monitor AI costs
Monitor AI costs
Each draft generation, Talk to Draft request, and translation costs API credits. Set up billing alerts in Anthropic Console.
Troubleshooting
Draft generation fails
Draft generation fails
Check:
ANTHROPIC_API_KEYis set correctly- API key has available credits
- No API outage (check Anthropic status page)
- Service document isn’t too large (>10,000 tokens)
Generated drafts are off-topic
Generated drafts are off-topic
The service document may be missing key information. Add:
- More context about the product
- Examples of good responses
- Clear policy statements
AI ignores Talk to Draft instructions
AI ignores Talk to Draft instructions
Instructions may be ambiguous. Be more specific:
- ❌ “Make it better”
- ✅ “Add bullet points listing the 3 steps to reset password”
Translations lose meaning
Translations lose meaning
The AI preserves meaning well but may miss idioms. Review translations manually before relying on them.
Draft includes unwanted markdown
Draft includes unwanted markdown
The AI occasionally returns markdown code fences. The system strips these automatically:If markdown appears in the draft content itself, update the prompt to be more explicit about HTML-only formatting.
Advanced: Customizing AI Behavior
Adjusting Response Length
Modifymax_tokens to control draft length:
Adding Custom Instructions
Enhance the prompt with company-specific guidelines:Implementing Few-Shot Learning
Add example exchanges to improve consistency:Prompt engineering is iterative. Test changes with real threads before deploying.