AnnexGroup

Documentation

Agent trigger on mail criteria

A trigger rule calls an agent when a delivered message matches — or a webhook, or both. “Matches” means: conditions like the inbox rules (sender, subject, text, attachment, size) plus folder, junk verdict and a time window in server time. The human stays the one who sends, as long as the rule does not explicitly allow the agent to reply. Content leaves the server only when the rule allows it — by default only envelope and subject.

1. How to create a rule

  1. Own rules: under Mailbox → Agent calls (/access/agent-triggers), scope “user”. Domain and shared mailboxes: in the administration (/admin/agent-triggers), as operator or tenant admin.
  2. Choose criteria: conditions and exceptions like the inbox rules, plus the folder (empty = any), the junk verdict (any / not junk only / junk only) and the time window — across midnight, in server time.
  3. Choose targets: an agent of this server, a webhook or both; optionally the message is also copied to the agent’s mailbox. Only the operator sets the webhook target — users and tenant admins cannot enter one.
  4. Set rights and limits: excerpt length (only together with “Allow content to leave the server”), call expiry (default 60 minutes, at most 24 hours) and the hourly maximum per rule (default 20, at most 1000).

2. What the agent sees

  • trigger_list returns the open calls with message id, rule, sender and subject. The call authorises the agent to read exactly this one message (mail_read) — even in the owner’s mailbox — and nothing else in the mailbox. trigger_ack closes the call.
  • The read link (/api/v1/agent-triggers/read/{token}) returns header and raw message (up to 256 KiB) of this message until the call expires; only the token’s checksum is stored in the database.
  • Excerpt and read link only enter the call when the rule has “Allow content to leave the server” set.

3. Replying and organising via MCP

MCP stays mail — no calendar, no contacts. The tools: mail_list, mail_search, mail_read, mail_send, mail_pending, trigger_list, trigger_ack, mail_draft, mail_reply, mail_label, mail_move.

  • mail_draft (default): places a draft in the owner’s drafts folder, with X-Annex-Drafted-By. Nothing is sent; a human reviews and sends.
  • mail_reply (only with the right “Agent may reply on its own” / allow_reply): sends a reply in the agent’s name to Reply-To/From — through the normal delivery path with rule set, blocks and time windows, marked X-Annex-Agent-Trigger and Auto-Submitted: auto-replied.
  • mail_label and mail_move (only with the right “Agent may label and move” / allow_organize): label as IMAP keyword, move only into existing folders; the call moves along.
  • mail_send is unchanged and stays under the usual leash for agent mail.

4. Protection and log

  • Loop: mail from an agent of this server and mail carrying the X-Annex-Agent-Trigger mark never trigger a call. Calls arise only on delivery to user and shared mailboxes.
  • Rate: at most the configured maximum per rule and hour, and 200 calls per agent and hour; beyond that an entry skipped is recorded, no call.
  • Duplication: only one call per rule and message.
  • Log: you find the call log on the same pages; the audit events (agent.trigger, agent.trigger.skipped, agent.trigger.failed, agent.trigger.read and mcp.tool per MCP call) are in the audit log.

5. What does not work

  • Calls arise only on delivery, not retroactively for existing mail.
  • A failing webhook never delays delivery. Webhook calls go through a queue with retries (30 s, 5 min, 30 min, 2 h, then failed). Whoever uses the read link from a late retry may hit an already expired call — the call is no longer readable then.
  • The webhook must have subscribed to the event agent.trigger; the event goes targeted to exactly the rule’s webhook, never to all subscribers. Verify the signature as with the other integrations.
  • Not shown against a real agent or n8n — the trigger path is tested against mocks.
  • Calls are not purged automatically; a cleanup run for the call log is still pending.

Something unclear or described wrong? Tell us — we will fix it. Your question shows us where the text falls short.