Email Triggers

Monitor your inbox with IMAP IDLE and trigger the agent on new emails.

How It Works

  1. aidaemon connects to the configured IMAP server with TLS
  2. Selects the configured folder (default: INBOX)
  3. Enters IMAP IDLE mode — a persistent connection that waits for new messages
  4. When a new email arrives, fetches the envelope (subject, sender)
  5. Creates an Event and broadcasts it via the internal event bus
  6. The agent processes the event and sends a notification via Telegram

Configuration

config.toml
[triggers.email]
host = "imap.gmail.com"
port = 993
username = "you@gmail.com"
password = "your-app-password"
folder = "INBOX"
Gmail App Passwords
For Gmail with 2FA, generate an app-specific password at myaccount.google.com/apppasswords.

Event Format

rust
Event {
    source: "email",
    session_id: "email_trigger",
    content: "New email from sender@example.com: Subject line here"
}

Event Bus

Triggers use a Tokio broadcast channel to deliver events. The agent listens on the receiver end and processes each event as a new message in its own session.

Untrusted Sessions
Email trigger sessions are marked as untrusted. All terminal commands in these sessions require explicit approval, regardless of the allowed_prefixes whitelist.

Reconnection

If the IMAP connection drops, aidaemon waits 30 seconds and reconnects automatically.