The Email Intelligence Plugin connects Hrida AI Studio to your IMAP/SMTP inbox. Once configured, AI reads your incoming mail, scores each message for urgency, tags it by topic, flags spam, suggests a draft reply, and links meeting invites to your CalDAV calendar — all without leaving Hrida AI Studio.
The Email workspace is only visible when the admin has enabled the Email Intelligence Plugin under Admin > Settings > Email > Install for All Users. See Admin Setup below.
What the Plugin Does
| Capability | Description |
|---|---|
| Urgency scoring | Each email is rated 1–5 for how urgently it needs attention |
| Auto-tagging | Topics like billing, legal, internal, urgent are detected and attached as tags |
| Spam detection | A spam_score (0.0–1.0) is assigned; emails at or above the admin-configured threshold are hidden from the inbox |
| Draft replies | AI generates a ready-to-send reply draft for each triaged message |
| CalDAV awareness | Meeting invites found in email are cross-referenced with your calendar to surface scheduling conflicts |
| Chat assistant | The Email Triage Assistant pipe lets you converse with your inbox in natural language |
Admin Setup
1. Install the plugins
Go to Admin > Settings > Email and click Install for All Users.
This single action registers two plugins server-side:
| Plugin | Type | ID |
|---|---|---|
| Email Manager | Tool | email_manager |
| Email Triage Assistant | Pipe (function) | email_triage_assistant |
The install is idempotent — clicking again after a server update reinstalls both plugins with the latest source.
2. Tool and pipe valves are set automatically
The Hrida API URL and API Key fields you fill in on the same Admin > Settings > Email screen before clicking Install for All Users are written straight into both plugins' HRIDA_API_URL / HRIDA_API_KEY valves server-side — there's no separate manual valve-configuration step. HRIDA_API_URL defaults to the container's own internal address (override via the EMAIL_PLUGIN_SELF_URL env var if yours differs; do not point it at the browser-facing port, e.g. not 3000). HRIDA_API_KEY is optional for the pipe — it falls back to the signed-in user's own session token, so leave it blank unless you need headless/API access.
If you want to double-check or hand-edit them afterward, they're visible under Admin > Workspace > Tools > Email Manager and Admin > Workspace > Functions > Email Triage Assistant (gear icon on each).
3. Email Triage Assistant pipe settings (optional)
The pipe also exposes a few tunables (gear icon on Email Triage Assistant under Admin > Workspace > Functions) — all have sane defaults, so this step is optional:
| Valve | Default | Notes |
|---|---|---|
MODEL_ID | (empty) | Model that writes the replies. Empty uses the Task Model, then the first default model, then the first available model |
TRIAGE_SYSTEM_PROMPT | Built-in email-assistant system prompt | Customize the assistant's persona/instructions |
AUTO_TRIAGE_ON_LOAD | true | Include the email digest in the context of every reply |
AUTO_TRIAGE_LIMIT | 50 | Max cached triage entries pulled into the digest |
Per-user, the pipe only has one setting — User Valves > account_id — covered in Linking your account below.
4. Set admin-level email settings
Go to Admin > Settings > Email:
| Setting | Default | Description |
|---|---|---|
| Max Emails per Triage Run | 50 | Prevents runaway IMAP polling. Max: 500 |
| Spam Threshold | 0.75 | Emails with spam_score ≥ this are hidden from the inbox and threads |
| Triage Model Override | (blank) | Model ID for the background sync triage. Leave blank to use the instance default. |
Docker Compose environment variables
# docker-compose.yaml → hrida-ai-studio service
# Background inbox auto-sync
- EMAIL_SYNC_INTERVAL=900 # seconds between automatic syncs (default: 15 min)
- EMAIL_RETENTION_DAYS=90 # how long triage results are kept
# Internal URL for the email pipe (only needed if your internal port differs from 8080)
# - EMAIL_PLUGIN_SELF_URL=http://localhost:8080SMTP_HOST / SMTP_USER / SMTP_PASSWORD (if set on your instance) configure the app's own outgoing system email — password resets, demo request notifications, etc. They have nothing to do with this feature. Each user's own inbox IMAP/SMTP credentials are entered per-account in Dashboard > Email (next section) and stored encrypted in the database, not as environment variables.
Setting Up Your Email Account
Navigate to Dashboard > Email and click + Add Account.
| Field | Description |
|---|---|
| Label | Friendly name for this account (e.g. "Work Gmail") |
| IMAP host | IMAP server address (e.g. imap.gmail.com) |
| IMAP port | Default: 993 (SSL) |
| SMTP host | SMTP server address (e.g. smtp.gmail.com) |
| SMTP port | Default: 587 (STARTTLS). Use 465 for SMTP over SSL |
| Username | Your email address |
| Password | App password or account password |
| Use SSL | Enable for IMAP port 993; leave off for STARTTLS configurations |
| CalDAV URL | (Optional) CalDAV server URL for calendar-aware scheduling |
| CalDAV username / password | (Optional) CalDAV credentials (stored separately from email credentials) |
Credentials are encrypted at rest using Fernet symmetric encryption keyed to the instance HRIDAAI_SECRET_KEY. Passwords are never returned in API responses or logs.
After saving, click Test Connection to verify IMAP and SMTP connectivity before running a triage.
Gmail requires an App Password (not your account password) when IMAP access is enabled. Generate one at Google Account > Security > 2-Step Verification > App passwords.
Linking Your Account to the Email Triage Assistant
The pipe needs to know which email account belongs to you. After adding your account:
- Go to Dashboard > Email, click your account, and copy the Account ID.
- Open a new chat and select Email Triage Assistant as the model.
- Open its Chat Controls panel (the sliders/adjustments icon) → Valves, and paste your Account ID into the
account_idfield under User Valves.
Using the Email Triage Assistant
With your account ID set, a digest of recently triaged emails (from the local triage cache) is injected into the assistant's context on every reply (controlled by the AUTO_TRIAGE_ON_LOAD / AUTO_TRIAGE_LIMIT valves above). From there you can ask things like:
- "Which emails are most urgent today?"
- "Is there anything from the finance team I should respond to?"
- "Triage my inbox" — explicitly re-runs triage mid-conversation
The injected digest looks like:
📬 **Email Digest** — 2026-08-14 09:30 UTC
Account: Work <you@example.com>
🔴 **CRITICAL** (1 email)
• **Budget approval needed** — finance@company.com [billing, urgent]
🟠 **URGENT** (2 emails)
• **Server outage — action required** — ops@company.com [infra]
• **Contract expires Friday** — legal@company.com [legal]
🚫 **Auto-filtered spam**: 3 emails
The model then answers based on this real-time inbox snapshot.
How Triage Works
Triage is triggered manually from the Email workspace, or automatically via the background scheduler:
- Fetch — the plugin connects via IMAP and fetches up to N recent messages (admin-configurable; default: 50).
- Analyse — each message is sent to the configured triage model. The model returns a structured triage result:
urgency(1–5)tags(list of topic strings)spam_score(0.0–1.0)summary(one-paragraph summary)draft_reply(ready-to-send response)
- Cache — results are stored in the triage cache (
email_triage_cachetable). Re-triaging the same message UID updates the cached result. - Spam filter — messages with
spam_score ≥ threshold(admin default:0.75) are hidden from the inbox and thread views. They stay in the triage cache and in your mailbox; nothing is moved or deleted on the mail server.
Browsing the Triage Results
The Email workspace shows your triaged messages in three views:
| View | What it lists |
|---|---|
| Needs reply | Messages still waiting for you: priority mail, or anything the AI rated Action needed (urgency 3) or higher, that nobody has replied to or marked handled. Soonest reply-by time first, so overdue mail is at the top. |
| Inbox | Everything that isn't blocked (spam stays hidden, as before). |
| Blocked | What your rules blocked, with the rule that matched. |
Use the filter controls to narrow a view by:
| Filter | Values |
|---|---|
| Urgency | Minimum urgency level (1–5) |
| Tag | Filter to messages with a specific tag |
Each message shows its subject, sender and urgency, a Priority badge (a priority sender or keyword matched) and, while it needs a reply, its deadline: Reply by …, or Overdue by … in red. Messages that need a reply have a highlighted left edge. Above the list, N overdue jumps to Needs reply.
Click a message to open the detail view. From there you can:
- Reply: opens the composer with the AI's draft reply filled in. Sending the reply marks the message handled.
- Mark as handled (or Reopen): takes it out of Needs reply without replying, or brings it back.
- Create task: turns the email into a Workcast task. You pick the board; the title, description (sender, AI summary, body) and priority are filled in, and the task is due when the reply is due. The email then shows a Task badge and Open task, which opens the board with the task.
- Priority sender / Block sender: adds the sender's address to your rules in one click.
- Unblock (in Blocked): removes the sender rule that blocked it.
Reply-by deadlines
A message that needs a reply is due a set number of hours after it arrives. If more than one applies, the shortest wins:
| Message | Default |
|---|---|
| Critical (urgency 5) | 4 hours |
| Urgent (urgency 4) | 8 hours |
| Action needed (urgency 3) | 24 hours |
| Priority mail | 24 hours |
Change them per account under Rules & settings → Reply within.
Rules: Blocked and Priority Mail
Click Rules & settings to set, per account, which mail is blocked and which is priority. Enter one item per line:
| Rule | Matches | Effect |
|---|---|---|
| Priority senders | An address (ceo@acme.com) or a domain (acme.com, which also covers mail.acme.com) | Highlighted and listed first under Needs reply |
| Priority keywords | A word or phrase in the subject or body (invoice overdue) | Same as a priority sender |
| Blocked senders | An address or a domain | Kept out of the inbox and never sent to the AI |
| Blocked subject keywords | A word or phrase in the subject only | Same as a blocked sender |
- Precedence: the first match wins, in this order: blocked sender, priority sender, blocked keyword, priority keyword. So a priority sender is never blocked by a keyword, and blocking a sender outright always wins.
- Applies everywhere: rules apply to new mail when it arrives (on sync and on results the plugin posts). When you save them, they also apply to every message already in the account, so blocking a sender hides the mail already there.
- Nothing is deleted: blocked mail is kept, not deleted; unblocking brings it back. A message blocked on arrival was never sent to the AI, so it has no summary or draft reply.
Suggested rules
The dialog suggests senders worth a rule, from how the account's mail was handled in the last 60 days:
- Block: three or more messages, none answered and none rated above Low; or two or more that are mostly spam.
- Priority: you replied to them at least twice from Studio.
Click Add to put a sender in the matching list, then Save. Senders already covered by a rule aren't suggested.
Moving blocked mail to a folder
Set Move blocked mail to folder (for example Blocked) and, at each sync, newly blocked messages are moved there on the mail server. The folder is created if it doesn't exist. Leave it empty to leave blocked mail where it is. Moving happens when mail arrives; changing the rules later doesn't move mail that was already synced.
Daily summary
Turn on Daily summary to get, once a day, an email listing the messages that still need a reply, overdue ones first. It is sent through the account's own SMTP server to the account's own address. Nothing is sent on a day when nothing needs a reply. Pick the hour (shown in your local time, stored in UTC). Preview shows today's summary and Send now sends it immediately. With several Studio replicas, the summary still goes out once a day.
Scheduled Triage (Background Sync)
You don't need to set anything up for this — every active email account is synced and re-triaged automatically in the background on a fixed interval, no Automation needed:
| Env var | Default | Description |
|---|---|---|
EMAIL_SYNC_INTERVAL | 900 (15 min) | Seconds between automatic background syncs |
EMAIL_RETENTION_DAYS | 90 | How long triage results are kept before being pruned |
These are plain environment variables (not admin-UI editable) — changing them requires a container restart. Use the manual ↻ Sync button in Dashboard > Email, or POST /api/v1/email/accounts/{id}/sync, to trigger a triage run immediately instead of waiting for the next scheduled interval.
Security
- Fernet encryption: All email and CalDAV credentials are encrypted using a key derived from
HRIDAAI_SECRET_KEY. If the secret key changes, existing credentials cannot be decrypted. - Owner-scoped access: Each user can only see and manage their own email accounts. Admins can access any account.
- Passwords never returned: The account API never includes plaintext passwords in responses. A separate internal endpoint decrypts on the fly for plugin use only and is only called server-side.
- Session token precedence: The Email Triage Pipe uses your signed-in session token by default. The
HRIDA_API_KEYvalve is only a fallback for headless API usage. - Spam is hidden, not deleted: Spam is only hidden in Hrida.ai; your mailbox is untouched. To see a message that was misclassified, request the triage list with
include_spam=true(GET /api/v1/email/accounts/{id}/triage?include_spam=true), or raise the threshold.
Troubleshooting
"Pipe load failed: unterminated string literal"
The pipe source was stored with a corrupt escape sequence. Re-run the install endpoint:
Admin > Settings > Email > Install for All Users
This re-installs the latest pipe source and clears the cached module.
"Configuration error: Could not auto-detect model"
The pipe's HRIDA_API_URL is pointing to the wrong address. Common causes:
| Symptom | Cause | Fix |
|---|---|---|
Max retries exceeded ... port=3000 | Valve set to browser-facing URL | Set HRIDA_API_URL to http://localhost:8080 |
Read timed out | Sync HTTP call deadlocking event loop | Upgrade to the latest server image — the fix is in functions.py (asyncio.to_thread) |
Connection refused | Container port mismatch | Check the PORT env var; default is 8080. Set EMAIL_PLUGIN_SELF_URL if needed |
The HRIDA_API_URL must be the container's own internal port, not the port your browser uses. If you publish port 3000:8080 in Docker, the internal URL is still http://localhost:8080.
Empty response (blank chat bubble)
This happens when the pipe returns raw JSON instead of text. Cause: the pipe was returning a dict (pass-through body). The fix is in the server — make sure you are running version 1.5.0+ of the pipe (visible in Admin > Workspace > Functions > Email Triage Assistant). Re-install if needed.
"LLM error 400: Bad Request"
The pipe was sending framework-internal fields (metadata, tool_ids, session_id) that your backend rejected. Fixed in pipe version 1.5.0 — the pipe now builds a clean OpenAI-compatible body before forwarding. Re-install the plugin.
No emails appearing after sync
- Confirm the email account credentials are correct (Dashboard > Email > Test Connection).
- Run a manual sync: click Sync on your account, or call
POST /api/v1/email/accounts/{id}/sync. - Check that the Email Triage Assistant has your
account_idset in User Valves. - Ensure the triage model is available: go to Workspace > Models and confirm at least one model is loaded.
Email account returns "Failed to decrypt credentials"
The HRIDAAI_SECRET_KEY environment variable changed between the time the account was saved and now. Credentials are encrypted with this key — changing it makes existing accounts unreadable. Re-add the account after restoring the original key, or keep the key stable across restarts (set it explicitly rather than letting it auto-generate).
API Reference
All email endpoints are under /api/v1/email.
# Account management
GET /api/v1/email/accounts
POST /api/v1/email/accounts
GET /api/v1/email/accounts/{id}
PATCH /api/v1/email/accounts/{id}
DELETE /api/v1/email/accounts/{id}
# Connection test
POST /api/v1/email/accounts/{id}/test
# Returns: {"imap": true, "smtp": true, "errors": {}}
# Manual IMAP sync + triage
POST /api/v1/email/accounts/{id}/sync
# Body: {"limit": 50, "folder": "INBOX", "only_unseen": true, "mark_as_read": true}
# Returns: {"synced": N, "fetched": N}
# Triage cache
GET /api/v1/email/accounts/{id}/triage ?view=inbox|needs_reply|blocked&urgency_min=1&tag=&skip=0&limit=50
GET /api/v1/email/accounts/{id}/triage/counts
# Returns: {"inbox": N, "needs_reply": N, "blocked": N, "overdue": N}
POST /api/v1/email/accounts/{id}/triage/{message_uid}/handled
# Body: {"handled": true} (false opens it again)
POST /api/v1/email/accounts/{id}/triage # upsert a triage result (plugin use; rules apply)
# Rules (blocked / priority senders and keywords)
GET /api/v1/email/accounts/{id}/rules
PUT /api/v1/email/accounts/{id}/rules
# Body: {"blocked_senders": [], "blocked_keywords": [], "priority_senders": [], "priority_keywords": []}
# Returns the saved rules and {"blocked": N, "priority": N, "total": N} after re-applying them
GET /api/v1/email/accounts/{id}/rules/suggestions
# Returns [{"kind": "block|priority", "sender", "messages", "replies", "reason"}]
# Settings: reply-by hours, blocked-mail folder, daily summary
GET /api/v1/email/accounts/{id}/settings
PUT /api/v1/email/accounts/{id}/settings
# Body: {"blocked_folder": "", "reply_within_hours": {"critical": 4, "urgent": 8, "action_needed": 24, "priority": 24},
# "digest_enabled": false, "digest_hour_utc": 8}
GET /api/v1/email/accounts/{id}/digest # preview: subject, text, html, count
POST /api/v1/email/accounts/{id}/digest/send # send now; {"sent", "count", "overdue"}
# Workcast task created from an email (the task itself: POST /api/v1/workcast/boards/{board_id}/tasks)
POST /api/v1/email/accounts/{id}/triage/{message_uid}/task
# Body: {"task_id": "...", "board_id": "..."}
DELETE /api/v1/email/accounts/{id}/triage/{message_uid}
DELETE /api/v1/email/accounts/{id}/triage # clear all cached results for account
# Thread grouping
GET /api/v1/email/accounts/{id}/threads ?limit=200
# Draft management
GET /api/v1/email/drafts
POST /api/v1/email/drafts
PATCH /api/v1/email/drafts/{draft_id}
DELETE /api/v1/email/drafts/{draft_id}
# Plugin install (admin only)
POST /api/v1/email/plugin/install
# Body: {"hrida_api_key": "<service-account-key>"}
# Returns: {"tool": "created|updated", "function": "created|updated"}