📧 Email Alias Quick Start
Generate email aliases to receive orders via email.
🚀 Quick Start (2 Steps)
Section titled “🚀 Quick Start (2 Steps)”1. List Your ERP Connections
Section titled “1. List Your ERP Connections”pnpm --filter webapp email:list-connectionsCopy the ID of the connection.
2. Generate Aliases
Section titled “2. Generate Aliases”# Generate with auto user selectionpnpm --filter webapp email:generate-aliases <CONNECTION_ID>
# Generate with specific userpnpm --filter webapp email:generate-aliases <CONNECTION_ID> user@example.comThe script automatically handles Clerk authentication using your backend credentials!
4. Verify Emails
Section titled “4. Verify Emails”Verification emails are automatically sent to each alias address. Users must click the verification link to activate.
📖 What This Creates
Section titled “📖 What This Creates”For an organization named “GenFit”:
- Organization alias:
orders+genfit@yourdomain.com- Receives emails for entire organization
- Member aliases:
orders+genfit_johnsmith@yourdomain.com- One for each organization member
- Format:
{org-slug}_{firstname}{lastname}
🔍 Check Alias Status
Section titled “🔍 Check Alias Status”# View aliases in databasepsql "$DATABASE_URL" -c \ "SELECT email, status, verified_at FROM email_aliases WHERE erp_connection_id = 'your-connection-id';"🧪 Test
Section titled “🧪 Test”- Send email to an alias (e.g.,
orders+genfit@yourdomain.com) - Watch logs: webapp / Temporal logs will show email processing
- Verify: Order should be created in your system
📚 Full Documentation
Section titled “📚 Full Documentation”- Email body extraction flow: ../architecture/email-body-order-extraction.md
🛠️ Scripts Available
Section titled “🛠️ Scripts Available”# List ERP connectionspnpm --filter webapp email:list-connections
# Generate email aliasespnpm --filter webapp email:generate-aliases <CONNECTION_ID>🆘 Common Issues
Section titled “🆘 Common Issues””Unauthorized” Error
Section titled “”Unauthorized” Error”- Get a fresh Clerk token from browser
- Make sure CLERK_SECRET_KEY is set in your local environment
Emails Not Sending
Section titled “Emails Not Sending”- Check RESEND_API_KEY in your local environment
- Verify
WEBAPP_URL/APP_URLis set if you need generated verification links to use a public URL
No Aliases Created
Section titled “No Aliases Created”- Check DATABASE_URL is correct
- Verify webapp is running:
curl http://localhost:4321/api/health
Database Auth Failed
Section titled “Database Auth Failed”Update DATABASE_URL in .env with correct Neon credentials from Neon Console
📋 How It Works
Section titled “📋 How It Works”The script:
- Connects to your database to list ERP connections
- Uses Clerk backend API to get a valid session token
- Calls the webapp alias-generation route with proper authentication
- Generates aliases for organization and all members
- Sends verification emails automatically
✅ Next Steps After Alias Generation
Section titled “✅ Next Steps After Alias Generation”- Send test email to an alias to verify the end-to-end flow
- Monitor processing in webapp / Temporal logs