See llms.txt for all machine-readable content.

Back to Templates

Triage inbound email with IMAP, custom AI HTTP APIs and SMTP

Created by

Created by: Ck Lu || cklu
Ck Lu

Last update

Last update 14 hours ago

Categories

Share


Quick overview

This workflow triages inbound email by fetching messages via IMAP (or receiving them via webhook), sending the content to external AI HTTP endpoints to classify and draft a reply, then either routes the draft for human approval or replies via SMTP and logs the outcome.

How it works

  1. Runs on a schedule to poll an IMAP inbox for unseen messages, or receives inbound messages as JSON via a webhook.
  2. Normalizes each message into a consistent structure (message ID, sender, subject, body, and received time).
  3. Sends the normalized content to a classification API endpoint that returns strict JSON labels (for example category and confidence).
  4. Sends the message and classification results to a drafting API endpoint to generate a reply draft in your chosen tone.
  5. Applies routing rules to decide whether the draft can be auto-sent or must go to a human review queue.
  6. If auto-sending is enabled, replies to the original sender via SMTP in the same email thread and logs the sent message to a database endpoint.
  7. If human review is required, creates a queue item, notifies an approver via a webhook (for example Slack or email), and logs the pending-review status to a database endpoint.

Setup

  1. Create and select an IMAP credential for reading mail and an SMTP credential for sending replies, and set the from address used for SMTP.
  2. Choose a single entry point (scheduled IMAP polling or the inbound webhook) and disable the other to avoid processing the same message twice.
  3. Provide working URLs (and any required authentication headers) for the classification API, drafting API, logging database write API, and the approver notification webhook.
  4. Update the approval policy (for example keep auto-send off initially and define confidence/category rules) and, if using webhook push mode, copy the webhook URL into your source system that forwards inbound messages.