How to Use AI Email Triage
Complete guide to setting up and using the AI-powered email triage system
Video Tutorial
Watch this walkthrough to see how to configure AI Email Triage for your FreeScout mailbox.
Open video in new tab
๐ง Step 1: Connect to FreeScout
To enable automatic email triage, you need to install the AI Triage module in your FreeScout mailbox.
A. Upload the FreeScout Module
- Download the module: freescout_module.zip
- Extract the zip file on your computer
- Rename the extracted folder from
freescout_module to AiTriage
- Upload the AiTriage folder to your FreeScout server at:
mikesinbox.clearcafe.com/Modules/AiTriage/
- Make sure the folder structure on your FreeScout server looks like this:
Modules/
โโโ AiTriage/
โโโ Module.php
โโโ Listener.php
โโโ module.json
โโโ README.md
B. Configure Environment Variables
Add these to your FreeScout .env file:
REPLIT_WEBHOOK_URL=https://config.clearcafe.com/webhook
WEBHOOK_SECRET=your_secret_key_here
โ ๏ธ IMPORTANT:
The WEBHOOK_SECRET must match exactly between FreeScout and this Replit app.
Generate a secure random secret using:
openssl rand -hex 32
C. Activate the Module
- Log in to your FreeScout admin panel
- Go to Manage โ Modules
- Find AI Triage in the list
- Click Activate
D. Get FreeScout API Key
- In FreeScout, go to Manage โ API
- Generate a new API token
- Add it to your Replit environment variables as
FREESCOUT_API_KEY
๐ Step 2: Using the Dashboard
Once connected, the AI will automatically process incoming emails. Here's what happens:
How It Works
- Email Arrives: New conversation created in FreeScout
- Webhook Sent: FreeScout module sends email data to this system
- AI Analysis: Grok AI analyzes the email using your SOPs
- Decision Made: AI assigns email, adds notes, sets status
- Applied: Changes automatically applied in FreeScout
- Review: You can review AI decisions in the dashboard
Dashboard Statistics
- โ Total Decisions: Number of emails processed
- โ Auto-Closed (%): Percentage of emails closed automatically
- โ High Confidence (%): Percentage of decisions with >80% confidence
โ
Step 3: Reviewing AI Decisions
Click "Review" on any decision to provide feedback:
- Approve: AI made the right decision
- Reject: AI made a mistake (provide correction)
- Modify: Adjust the decision and provide guidance
- Learn as SOP: Turn this decision into a new rule for future emails
๐ก Pro Tip:
When AI asks questions in the notes (confidence < 80%), answer them and check "Learn this as a new SOP rule"
to automatically improve the system!
๐ Step 4: Managing SOPs (Standard Operating Procedures)
SOPs teach the AI how to handle specific types of emails.
Creating a New SOP
- Go to SOPs page
- Fill in the trigger pattern (e.g., "password reset", "billing question")
- Set the action: who to assign to, what status to set
- Add Q&A to explain the reasoning
- Click Add SOP
Example SOPs
Trigger: "refund"
Action: Assign to User ID 1 (Finance), Status: Open
Reasoning: All refund requests need billing team review
Trigger: "password reset"
Action: Unassigned, Status: Closed
Reasoning: Password resets are automated, no action needed
๐ฅ Step 5: User Management (Admins Only)
Control who can access the AI Email Triage system.
- When someone logs in via RegardingWork SSO for the first time, they're marked as "pending"
- Go to Users page to see all access requests
- Click Approve to grant access or Reject to deny
- Promote trusted users to Admin to let them manage other users
User Roles
- ๐ค User: Can view dashboard, review decisions, manage SOPs
- ๐ Admin: Everything above + approve/reject users, promote to admin
โ๏ธ Required Environment Variables
Set these in Replit's Secrets (environment variables):
| Variable |
Description |
Required |
XAI_API_KEY |
Your Grok AI API key |
โ Yes |
FREESCOUT_API_KEY |
FreeScout API token |
โ Yes |
WEBHOOK_SECRET |
Shared secret for webhook authentication (must match FreeScout) |
โ Yes |
SECRET_KEY |
Flask session encryption key |
โ Yes |
FREESCOUT_BASE_URL |
Your FreeScout URL (default: https://mikesinbox.clearcafe.com) |
Optional |
๐งช Step 6: Testing Your Setup
1. Test the Webhook
- Go to /test/webhook
- Click "Send Test Webhook"
- Check that it appears in the dashboard
2. Test with Real Email
- Create a test conversation in FreeScout
- Check FreeScout logs:
storage/logs/laravel.log
- Verify the decision appears in this dashboard
- Confirm the conversation in FreeScout was updated (assigned/notes/status)
๐ง Troubleshooting
Module Not Showing in FreeScout
- Verify folder name is exactly
AiTriage (case-sensitive)
- Check file permissions are readable by web server
- Clear FreeScout cache:
php artisan cache:clear
Webhook Not Firing
- Check
storage/logs/laravel.log in FreeScout for errors
- Verify
REPLIT_WEBHOOK_URL and WEBHOOK_SECRET in FreeScout .env
- Test webhook manually using
/test/webhook
AI Not Making Decisions
- Verify
XAI_API_KEY is set in environment variables
- Check workflow logs for errors
- Make sure you've seeded some SOPs (
/seed)
Need Help?
Check the health status
or review the workflow logs in your Replit dashboard.