Skip to main content

Build an Email Auto-Responder

Learning Path

Level 4, Step 4.3 β€” Learning Path. Prerequisites: Human in the Loop.

This project combines AI intelligence with human oversight. You'll build a system that automatically drafts professional email replies, but waits for a human to approve (or revise) before sending. It's the perfect example of Human-in-the-Loop AI.

What You'll Build​

An email response system that:

  • Receives incoming email details via a form
  • Researches the sender for context
  • Drafts a professional reply
  • Pauses for human review and approval
  • Revises the draft based on feedback
  • Sends the approved email via Gmail

The Architecture​

Start (Form) β†’ Agent (draft reply) β†’ Human Input β†’ Send Email (if approved)
↑ ↓
└──── Loop (if rejected, with feedback) β”€β”€β”€β”€β”˜

Step 1: Create the Flow​

  1. Create a new Agentflow named "Email Auto-Responder"
  2. Configure the Start node:
    • Input Type: Form Input
    • Form Title: "Email Inquiry"
    • Form Description: "Incoming email to respond to"
    • Form Inputs:
      • Label: "Subject", Variable: subject, Type: String
      • Label: "Body", Variable: body, Type: String
      • Label: "From", Variable: from, Type: String

Step 2: Add the Email Reply Agent​

Add an Agent node connected to Start.

Model: ChatOpenAI β†’ gpt-4o

System Message:

You are a professional email assistant for our company. Your job is to draft thoughtful, professional email replies.

Guidelines:
- Match the tone of the incoming email (formal for formal, friendly for friendly)
- Address the sender's questions or concerns directly
- Be concise but thorough
- Always sign off as "Best regards, [Your Company] Support Team"
- Use the web search tool to research the sender's company for personalized context
- Include today's date when relevant

Today's date is {{ current_date_time }}

Tools:

  • Google Custom Search: To research the sender
  • Current DateTime: For accurate timestamps

Input Message:

Please draft a reply to this email:

From: {{ $form.from }}
Subject: {{ $form.subject }}
Body: {{ $form.body }}

Step 3: Add Human Input Node​

Add a Human Input node connected to the Agent.

  • Description Type: Fixed
  • Description: "Please review the draft email reply below. Approve to send, or reject with feedback to revise."
  • Enable Feedback: Yes

This pauses the flow and shows the draft to a human reviewer.

Step 4: Handle Rejection (Loop Back)​

Connect the Reject output of Human Input to a Loop node:

  • Loop Back To: The Email Reply Agent
  • Max Loop Count: 5

When rejected, the agent receives the feedback and generates an improved draft.

Step 5: Format and Send Email​

Connect the Proceed output of Human Input to an LLM node:

JSON Structured Output:

  • subject (string): "Email subject line"
  • body (string): "Email body text"

Then connect to a Tool node:

  • Tool: Gmail
  • Action: Send Message
  • Input Arguments:
    • to: {{ $form.from }}
    • subject: {{ llmAgentflow_0.output.subject }}
    • body: {{ llmAgentflow_0.output.body }}

Testing​

  1. Fill in the form with a sample email
  2. Review the AI-generated draft
  3. Try rejecting with feedback like "Make it more casual" or "Add information about our return policy"
  4. Approve when satisfied and verify the email is sent

Tips​

  • Research adds personalization: The web search tool helps the agent understand who they're replying to
  • Feedback improves quality: Each rejection with feedback makes the next draft better
  • Share for external review: Use the Executions panel to share the approval link with team members who don't have CiniterFlow access