Skip to content

Email

Connect your Triggerfish agent to email so it can receive messages via IMAP and send replies via an SMTP relay service. The adapter supports services like SendGrid, Mailgun, and Amazon SES for outbound email, and polls any IMAP server for inbound messages.

Default Classification

Email defaults to PUBLIC classification. Email is inherently open -- anyone with your address can send you a message -- so PUBLIC is the safe default.

Setup

Step 1: Choose an SMTP Relay

Triggerfish sends outbound email through an HTTP-based SMTP relay API. Supported services include:

ServiceAPI Endpoint
SendGridhttps://api.sendgrid.com/v3/mail/send
Mailgunhttps://api.mailgun.net/v3/YOUR_DOMAIN/messages
Amazon SEShttps://email.us-east-1.amazonaws.com/v2/email/outbound-emails

Sign up for one of these services and obtain an API key.

Step 2: Configure IMAP for Receiving

You need IMAP credentials for receiving email. Most email providers support IMAP:

ProviderIMAP HostPort
Gmailimap.gmail.com993
Outlookoutlook.office365.com993
Fastmailimap.fastmail.com993
CustomYour mail server993

Gmail App Passwords

If you use Gmail with 2-factor authentication, you will need to generate an App Password for IMAP access. Your regular Gmail password will not work.

Step 3: Configure Triggerfish

Add the Email channel to your triggerfish.yaml:

yaml
channels:
  email:
    smtpApiUrl: "https://api.sendgrid.com/v3/mail/send"
    smtpApiKey: "your-sendgrid-api-key"
    imapHost: "imap.gmail.com"
    imapPort: 993
    imapUser: "you@gmail.com"
    imapPassword: "your-app-password"
    fromAddress: "triggerfish@yourdomain.com"
    ownerEmail: "you@gmail.com"
OptionTypeRequiredDescription
smtpApiUrlstringYesSMTP relay API endpoint URL
smtpApiKeystringYesAPI key for the SMTP relay service
imapHoststringYesIMAP server hostname
imapPortnumberNoIMAP server port (default: 993)
imapUserstringYesIMAP username (usually your email address)
imapPasswordstringYesIMAP password or app-specific password
fromAddressstringYesFrom address for outgoing emails
pollIntervalnumberNoHow often to check for new emails, in ms (default: 30000)
classificationstringNoClassification level (default: PUBLIC)
ownerEmailstringRecommendedYour email address for owner verification

Store Credentials Securely

Email credentials include passwords and API keys. Never commit them to source control. Use environment variables or your OS keychain.

Step 4: Start Triggerfish

bash
triggerfish stop && triggerfish start

Send an email to the configured address to confirm the connection.

Owner Identity

Triggerfish determines owner status by comparing the sender's email address against the configured ownerEmail:

  • Match -- The message is an owner command
  • No match -- The message is external input with PUBLIC taint

If no ownerEmail is configured, all messages are treated as coming from the owner.

Domain-Based Classification

For more granular control, email supports domain-based recipient classification. This is especially useful in enterprise environments:

  • Emails from @yourcompany.com can be classified as INTERNAL
  • Emails from unknown domains default to EXTERNAL
  • Admin can configure a list of internal domains
yaml
channels:
  email:
    # ... other config
    internalDomains:
      - "yourcompany.com"
      - "subsidiary.com"

This means the policy engine applies different rules based on where an email comes from:

Sender DomainClassification
Configured internal domainINTERNAL
Unknown domainEXTERNAL

How It Works

Inbound Messages

The adapter polls the IMAP server at the configured interval (default: every 30 seconds) for new, unread messages. When a new email arrives:

  1. The sender address is extracted
  2. Owner status is checked against ownerEmail
  3. The email body is forwarded to the message handler
  4. Each email thread is mapped to a session ID based on the sender address (email-sender@example.com)

Outbound Messages

When the agent responds, the adapter sends the reply via the configured SMTP relay HTTP API. The reply includes:

  • From -- The configured fromAddress
  • To -- The original sender's email address
  • Subject -- "Triggerfish" (default)
  • Body -- The agent's response as plain text

Poll Interval

The default poll interval is 30 seconds. You can adjust this based on your needs:

yaml
channels:
  email:
    # ... other config
    pollInterval: 10000   # Check every 10 seconds

Balance Responsiveness and Resources

A shorter poll interval means faster response to incoming email, but more frequent IMAP connections. For most personal use cases, 30 seconds is a good balance.

Changing Classification

yaml
channels:
  email:
    # ... other config
    classification: CONFIDENTIAL

Valid levels: PUBLIC, INTERNAL, CONFIDENTIAL, RESTRICTED.

Released under the MIT License.