Skip to main content

Overview

Email integration allows your agent to automatically respond to emails. There are two modes:
  • Generated inbox - Lua creates a dedicated email address for your agent (e.g. [email protected])
  • Existing email - Use your own email address (e.g. [email protected]) with forwarding

Professional

Business-appropriate channel

Universal

Everyone has email

B2B Friendly

Preferred for business

Threaded

Conversation threading

How It Works

1

Lua Creates Inbox

A dedicated email address is generated for your agent
2

User Sends Email

Customer emails the generated address directly
3

Agent Processes

Agent reads and understands email
4

Agent Responds

Agent sends reply via email
5

User Receives Reply

Reply appears in their inbox

Connection Method 1: CLI

$ lua channels
 Using agent: myAgent

? What would you like to do? 🔗 Link new channel
? Select channel type: 📧 Email

? Select email channel mode: 📬 Generate new inbox
? Enter display name (shown in email header): Support Team

📡 Creating Email channel...

 Email channel created successfully!

📧 Display Name:    Support Team
📬 Email Address:   [email protected]

────────────────────────────────────────────────────
Your agent's email inbox has been created.
────────────────────────────────────────────────────

Share this address with your customers or use it
in your workflows:
   [email protected]

Emails sent to this address will be handled by
your agent.
────────────────────────────────────────────────────
No additional setup required — your agent is ready to receive emails immediately.

Connection Method 2: Admin Dashboard

1

Open the dashboard

lua admin
Or visit https://admin.heylua.ai.
2

Open your agent and add a channel

Click Agents in the main side navigation, select your agent’s card, click the + (plus) icon to add a channel, then choose Email.
3

Choose a connection type

In the Connect to Email dialog, enter a Display name (shown in the email header, e.g. “Support Team”) and pick how to connect, then click Connect.
Lua creates a new email address your customers can email directly.
Generate new email
4

Finish setup

  • Generated — Lua shows “Your email address is ready!” with the new address. Copy it and share it with your customers.
  • Existing — Lua shows a forwarding address. Copy it and set up forwarding from your email provider (see Email Provider Setup below). Your agent only receives email once forwarding is active.

Email Provider Setup

Gmail Forwarding:
  1. Open Gmail Settings
  2. “Forwarding and POP/IMAP” tab
  3. “Add a forwarding address”
  4. Paste Lua forwarding address
  5. Check verification email
  6. Click verification link
  7. Return to Gmail settings
  8. Enable “Forward a copy”

Testing

1

Send a test email

Email your connected address — the generated address, or your business address once forwarding is set up:
To: [email protected]
Subject: Test
Body: Is this working?
2

Check Activity → Logs

In the admin dashboard, open Activity → Logs. You’ll see the inbound email and your agent’s response there as it’s processed.
3

Agent responds

Your agent replies automatically — the response lands in the sender’s inbox.

Accessing Email Metadata in Tools

For inbound emails, Lua.request.webhook.payload is populated with a JMAP-aligned object containing parsed message metadata. Use this to build threaded replies, deduplicate by Message-ID, read custom headers, or implement conversation threading.
import { Lua, LuaTool } from 'lua-cli';
import { z } from 'zod';

export default class ThreadedReplyTool implements LuaTool {
  name = 'send_threaded_reply';
  description = 'Send a reply to an email, preserving thread';

  inputSchema = z.object({
    message: z.string(),
  });

  async execute(input: z.infer<typeof this.inputSchema>) {
    const webhook = Lua.request.webhook;

    if (Lua.request.channel === 'email' && webhook) {
      const { messageId, inReplyTo, subject } = webhook.payload;
      
      // Build reply subject
      const replySubject = subject?.startsWith('Re:') ? subject : `Re: ${subject}`;
      
      // Use messageId to thread the reply
      return {
        message: input.message,
        threadId: inReplyTo ?? messageId,
        subject: replySubject,
      };
    }

    return { error: 'Not an email channel' };
  }
}
For full details on the shape, headers, and AgentMail divergence, see Webhook Payload → Email.

Attachments and Embedded Images

Inbound emails can carry files two ways, and both reach your agent as file parts alongside the message text:
  • Regular attachments (the paperclip) — always forwarded, no size restrictions.
  • Embedded images (pasted or dragged into the compose window, e.g. in Gmail) — forwarded when they are genuinely part of the message: the image must be referenced from the email’s HTML body, be an image type, and be at least 1 KB (filters out 1×1 spacer pixels). Up to 10 embedded images per email are forwarded.
Email clients insert a plain-text placeholder like [image: photo.png] where an embedded image sits in the body. That placeholder still appears in the message text your agent sees — but the actual image now arrives as a separate image part. Don’t try to parse the placeholder; use the image part.
A few behaviors worth knowing:
  • Remote-hosted images are not fetched. Images referenced by URL — for example Gmail signature images, which are hosted rather than embedded — are not downloaded. Only data actually transmitted in the email is processed.
  • Embedded signature logos may come through. Some email clients (commonly corporate Outlook setups) embed signature logos directly in the message. An embedded logo over 1 KB is indistinguishable from a content image and will reach your agent as an image part. If your users’ emails are signature-heavy, consider instructing your agent to disregard branding imagery.
  • Mislabeled attachments are recovered. Some clients mark real attachments as embedded content; these are detected and forwarded as normal attachments rather than dropped.

Best Practices

Email is a more formal channel than chat. If your agent’s core persona is casual or emoji-heavy, that style will carry into its emails unless you account for it. Prompt-engineer any skills or tools that generate email content to enforce a more formal tone — for example, instruct them to avoid emojis, use proper greetings and sign-offs, and write in complete paragraphs. This keeps email responses professional even when the underlying persona is playful elsewhere.
  • Aim for < 1 hour response
  • Set auto-reply for delays
  • Mention expected response time
  • Use proper paragraphs
  • Include signature
  • Format lists clearly
  • Proofread responses

Next Steps

Website Widget

Add chat to website

All Channels

View all options