Documentation Index
Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Encore Health OS supports email delivery for in-app notifications, allowing users to receive important updates directly in their inbox. Emails are sent via the org-configured provider: Microsoft Entra ID (Graph API) or Gmail (Google Workspace).Configuration
Prerequisites
- Entra: Configure in Settings → Integrations → Microsoft Entra ID; set
ENTRA_CLIENT_SECRETin Supabase secrets. - Gmail: Set
GMAIL_SERVICE_ACCOUNT_JSONin Supabase secrets; set sender email in Settings → Integrations → Google Workspace (Gmail). - Per-org provider choice in HR → Settings → Email (Entra or Gmail).
Email Provider
The platform uses the shared email-provider abstraction (Entra or Gmail):- Professional HTML templates
- Delivery tracking
- Bounce and failure handling
- Variable substitution
Email Template Types
Standard Notifications
Basic notifications with auto-generated template wrapper. Used for simple alerts and updates.Scheduled Report Emails
Professional branded templates for automated report delivery with:- Branded Encore Health OS header with gradient
- Report details card (name, description)
- Statistics row (generated date, row count, format, file size)
- Prominent download button with signed URL
- Next scheduled run indicator
- Responsive design for mobile
Report Failure Emails
Error notification template for when scheduled reports fail:- Red accent error header
- Error details card with message
- Troubleshooting suggestions
- Link to reports page
Localization Support
Email templates support localization via thelocale parameter:
Supported Locales
en- English (default)es- Spanish (coming soon)fr- French (coming soon)
Adding New Locales
- Create locale file:
supabase/functions/_shared/email-templates/locales/{locale}.ts - Export translations matching
ReportDeliveryStringsandReportFailedStringsinterfaces - Add locale to
Localetype intypes.ts - Import and add to locale maps in template files
Translation Keys
{{name}}, {{report_name}}, etc.) must be escaped using escapeHtml() from _shared/email-templates/utils.ts before interpolation to prevent XSS attacks in rendered emails.
Features
Automatic Email Delivery
Notifications withchannel='email' are automatically sent via the send-email-notification edge function.
Pre-Rendered HTML Support
For complex templates like scheduled reports, you can provide pre-rendered HTML:Template Variables
Emails support variable substitution using{{variable}} syntax:
{{user.name}}- Recipient’s name{{org.name}}- Organization name{{action.url}}- Action link- Custom variables per notification type
Delivery Tracking
All emails track:- Sent - Successfully delivered via org provider (Entra or Gmail)
- Delivered - Confirmed received by recipient
- Bounced - Email address invalid or rejected
- Failed - Delivery error occurred
Usage
Sending Standard Email Notifications
Using Report Email Templates
Checking Delivery Status
UI Component
Email Template Architecture
Template Features
Base Layout (base-layout.ts)
- Responsive design (max-width 600px)
- Branded header with Encore Health OS gradient
- Dark mode ready with
prefers-color-schememeta - Consistent footer with preferences link
- Utility functions:
interpolate(),formatBytes(),formatDate()
Report Delivery Template
- Personalized greeting
- Report details card
- Stats row with 4 columns
- Large download CTA button
- Column summary (optional)
- Next run indicator
- Auto-generated notice
Report Failed Template
- Error-state red header
- Error details card with message
- Suggestion box with troubleshooting tips
- View Reports button
Best Practices
- Use Clear Subjects: Keep subject lines under 50 characters
- Provide Context: Include relevant details in the body
- Add Action URLs: Always link to the relevant page
- Test Variables: Ensure all variables are defined before sending
- Monitor Bounces: Review bounced emails and update user profiles
- Use Pre-Rendered HTML: For complex templates, use
skipTemplate: true
Error Handling
Failed emails are automatically logged with:- Error message stored in
delivery_error - Status set to
'failed' - Notification remains viewable in-app
- Invalid email address → Update user profile
- Rate limit exceeded → Emails queued automatically
- Auth/API error → Check Entra or Gmail configuration (Settings → Integrations)
Rate Limits
Provider rate limits:- Free tier: 100 emails/day
- Paid tier: Custom limits
Testing
Development Testing
Test email delivery:- Configure Entra or Gmail per org (Settings → Integrations)
- In HR → Settings → Email, use “Send Test Email” to verify
Production Testing
- Verify sender identity (Entra mailbox or Gmail/Workspace user)
- Update
fromaddress in edge function - Test with real email addresses
- Monitor delivery in Supabase logs and provider dashboards
Troubleshooting
Emails Not Sending
- Check Entra or Gmail secrets and org config (Settings → Integrations)
- Verify edge function deployed successfully
- Check notification has
channel='email' - Review edge function logs
Emails Bouncing
- Verify email address format (must be valid)
- Check recipient’s email server isn’t blocking
- Confirm sender domain is verified (production)
- Review function logs and provider dashboards for bounce/failure reasons
Variables Not Replacing
- Ensure variables use
{{key}}format - Verify variable data is provided in notification
- Check for typos in variable names
- Test with simple variables first
Pre-Rendered HTML Not Working
- Ensure
skipTemplate: trueis set - Verify
htmlfield contains valid HTML - Check that
bodyfield is empty string (not undefined)