Email Trigger¶
Overview¶
The Email Trigger (Inbound Email Trigger) automatically starts workflows when emails are received at specific email addresses. This enables powerful email-based automation like parsing customer inquiries, processing support tickets, handling order confirmations, and more.
When to use this trigger:
- Process support emails automatically
- Parse order confirmations from suppliers
- Handle lead inquiries from email
- Process email-to-ticket conversions
- Monitor specific email addresses for actions
- Parse and extract data from structured emails
Quick Start¶
- Connect your email account (Gmail, Microsoft 365, or IMAP)
- Create a new workflow
- Add an Email Trigger as the first task
- Configure email matching rules (from, subject, etc.)
- Save and enable the workflow
- When matching emails arrive, the workflow runs automatically
[SCREENSHOT NEEDED: Email Trigger task panel showing email matching configuration]
Connecting Email Accounts¶
Gmail Integration¶
- Click "Connect Gmail Account" in the Email Trigger settings
- Authorize BaseCloud to access your Gmail
- Select which Gmail account to monitor
- Configure matching rules
Permissions Required: - Read emails (readonly access) - BaseCloud cannot send emails or modify your mailbox
Microsoft 365 / Outlook Integration¶
- Click "Connect Microsoft Account"
- Sign in with your Microsoft credentials
- Authorize BaseCloud
- Select the mailbox to monitor
- Configure matching rules
Supported Accounts: - Outlook.com personal accounts - Microsoft 365 business accounts - Exchange Online mailboxes
IMAP Integration (Any Email Provider)¶
For email providers not directly supported, use IMAP:
- Select "Connect via IMAP"
- Enter your IMAP server settings:
- Host: e.g.,
imap.gmail.com - Port: Usually 993 (SSL) or 143 (non-SSL)
- Username: Your email address
- Password: Your email password or app-specific password
- Use SSL: Recommended (checked)
Common IMAP Settings:
| Provider | IMAP Host | Port | SSL |
|---|---|---|---|
| Gmail | imap.gmail.com | 993 | Yes |
| Outlook | outlook.office365.com | 993 | Yes |
| Yahoo | imap.mail.yahoo.com | 993 | Yes |
| iCloud | imap.mail.me.com | 993 | Yes |
Email Matching Rules¶
Configure rules to determine which emails trigger your workflow.
Match by Sender (From Address)¶
Trigger only when emails come from specific addresses:
Or use wildcards:
Match by Subject¶
Trigger when subject contains specific text:
Or use partial matching:
Match by Recipient (To Address)¶
Trigger when email is sent to specific addresses:
Match by CC or BCC¶
Combine Multiple Rules¶
Use AND logic to match multiple criteria:
This triggers only when BOTH conditions are met.
Match All Emails¶
Leave rules empty to trigger on every email received at the connected account.
Warning: This can trigger many workflows. Use specific rules to avoid unnecessary executions.
Output Fields¶
The Email Trigger outputs comprehensive email data:
Basic Email Information¶
| Field | Description | Example Value |
|---|---|---|
task_[ID]_from | Sender email address | john@example.com |
task_[ID]_from_name | Sender display name | John Smith |
task_[ID]_to | Recipient email(s) | support@yourdomain.com |
task_[ID]_cc | CC email(s) | manager@yourdomain.com |
task_[ID]_bcc | BCC email(s) | `` |
task_[ID]_subject | Email subject | Order #12345 Confirmation |
task_[ID]_date | Email received date | 2024-02-08 14:30:00 |
Email Content¶
| Field | Description |
|---|---|
task_[ID]_body_text | Plain text email body |
task_[ID]_body_html | HTML email body |
task_[ID]_body_clean | Cleaned text (no HTML tags) |
Metadata¶
| Field | Description | Example Value |
|---|---|---|
task_[ID]_message_id | Unique email message ID | <abc123@mail.gmail.com> |
task_[ID]_in_reply_to | ID of email being replied to | <xyz789@mail.example.com> |
task_[ID]_references | Thread references | Multiple message IDs |
task_[ID]_status | Always "success" | success |
Attachments¶
| Field | Description |
|---|---|
task_[ID]_attachments | JSON array of attachments |
task_[ID].JSON.attachments[0].filename | First attachment filename |
task_[ID].JSON.attachments[0].url | First attachment download URL |
task_[ID].JSON.attachments[0].size | First attachment size in bytes |
task_[ID].JSON.attachments[0].content_type | MIME type |
Accessing Attachments:
To process attachments, use JSON notation:
Or loop through attachments using a Loop task.
Real-World Examples¶
Example 1: Support Email to CRM Ticket¶
Trigger Rule: to:support@yourdomain.com
Workflow: 1. Email Trigger - Monitor support@yourdomain.com 2. Match to Client - Find existing contact by email 3. MySQL Query - Create support ticket 4. Email - Send auto-reply confirming ticket creation
Example 2: Order Confirmation Parser¶
Trigger Rule:
Workflow: 1. Email Trigger - Catch order confirmations 2. Code Task - Parse order details from email body using regex 3. MySQL Query - Create order record 4. Email - Notify warehouse team
Example 3: Invoice Processing with AI¶
Trigger Rule: subject:*invoice* with attachments
Workflow: 1. Email Trigger - Catch emails with "invoice" in subject 2. If Task - Check if attachments exist 3. AI Prompt - Extract invoice data using AI 4. MySQL Query - Create invoice record 5. Email - Forward to accounting
Example 4: Lead Inquiry Auto-Response¶
Trigger Rule: to:info@yourdomain.com
Workflow: 1. Email Trigger - Monitor info@yourdomain.com 2. Match to Client - Find existing lead record 3. If Task - Check if it's a new contact - New: Send welcome email - Existing: Send quick response 4. Webhook Out - Notify Slack channel
Example 5: Email Thread Tracking¶
Trigger Rule: Match emails in specific thread
Workflow: 1. Email Trigger - Catch all emails 2. If Task - Check if in_reply_to is set 3. MySQL Query - Find original conversation 4. MySQL Query - Add message to conversation thread 5. Edit Client - Update contact's last interaction date
Handling Attachments¶
Checking for Attachments¶
Use an If task to check if attachments exist:
Downloading Attachments¶
Attachment URLs are temporary and accessible for 24 hours:
To permanently store attachments: 1. Use Webhook Out to download the file 2. Use File task to upload to your storage
Processing Multiple Attachments¶
Use a Loop task to process each attachment:
- Loop - Loop through
task_54123.JSON.attachments - Inside loop: Process each attachment
Common Attachment Types¶
- PDF: Use PDF task to extract text
- Images: Use AI Prompt with vision models
- CSV/Excel: Download and parse with Code task
- Documents: Use Speech to Text if scanned
Parsing Email Content¶
Extract Data from Structured Emails¶
Many automated emails follow predictable formats. Use Code task or AI Prompt to extract data.
Example: Parse order confirmation
const body = results['task_54123_body_text'];
// Extract order number
const orderMatch = body.match(/Order #(\d+)/);
const orderNumber = orderMatch ? orderMatch[1] : '';
// Extract amount
const amountMatch = body.match(/Total: \$(\d+\.\d{2})/);
const amount = amountMatch ? amountMatch[1] : '';
return {
order_number: orderNumber,
amount: amount
};
Clean Email Replies¶
Email replies often include previous message history. To extract just the new content:
const body = results['task_54123_body_text'];
// Split at common reply markers
const cleanBody = body.split(/On .* wrote:/)[0]
.split(/From:/)[0]
.split(/-----Original Message-----/)[0]
.trim();
return { clean_message: cleanBody };
Extract Email Addresses from Body¶
const body = results['task_54123_body_text'];
const emailRegex = /[\w.-]+@[\w.-]+\.\w+/g;
const emails = body.match(emailRegex) || [];
return { extracted_emails: emails };
Auto-Reply Handling¶
Prevent Reply Loops¶
If your workflow sends an email in response, be careful not to create loops:
- Check
in_reply_tofield - Add a unique identifier to your auto-reply subject
- Use If task to skip processing if subject contains that identifier
Example:
Setting Reply-To Headers¶
When sending email responses, use the original sender:
Best Practices¶
✅ Do's¶
- Use specific matching rules: Avoid triggering on every email unnecessarily
- Handle missing data gracefully: Use If tasks to check required fields exist
- Clean email content: Strip HTML and reply history before processing
- Add error notifications: Alert yourself if critical email workflows fail
- Test with sample emails: Send test emails to verify matching rules work
- Document your rules: Add workflow description explaining matching logic
- Monitor execution history: Regularly check that emails are being processed
❌ Don'ts¶
- Don't create reply loops: Always check for auto-reply markers
- Don't store attachments indefinitely: Download and process quickly
- Don't trigger on all emails: Use specific rules to avoid wasted executions
- Don't expose sensitive data: Be careful when forwarding or logging email content
- Don't ignore spam: Add validation to detect and skip spam emails
Troubleshooting¶
Emails Not Triggering Workflow¶
Possible Causes: - Email account not connected properly - Matching rules too restrictive - Workflow is disabled - Email going to spam/junk folder
Solutions: 1. Verify email account connection is active 2. Test with broader matching rules temporarily 3. Check workflow toggle is ON 4. Ensure emails are arriving in inbox (not spam) 5. Check execution history for error messages
Wrong Emails Being Processed¶
Cause: Matching rules too broad
Solution: Add more specific matching criteria:
Attachments Not Available¶
Possible Causes: - Attachment URLs expired (after 24 hours) - Attachment too large - Attachment type blocked
Solutions: 1. Process attachments immediately when email arrives 2. Check attachment size limits 3. Verify attachment content type is supported
Cannot Connect Email Account¶
Gmail: - Enable "Less secure app access" (or use App Passwords) - Check 2-factor authentication settings
Microsoft: - Verify mailbox permissions - Check admin hasn't blocked OAuth apps
IMAP: - Verify IMAP is enabled in your email settings - Use app-specific password if 2FA is enabled - Check firewall isn't blocking IMAP port (993)
Advanced Features¶
Email Thread Tracking¶
Track conversation threads using message_id, in_reply_to, and references fields:
Spam Detection¶
Implement basic spam detection:
const from = results['task_54123_from'];
const subject = results['task_54123_subject'];
const body = results['task_54123_body_text'];
// Basic spam indicators
const hasSpamWords = /viagra|casino|lottery|winner/i.test(subject + body);
const suspiciousSender = !from.includes('.com') && !from.includes('.net');
const tooManyLinks = (body.match(/http/g) || []).length > 5;
return {
is_spam: hasSpamWords || suspiciousSender || tooManyLinks
};
Email Categorization¶
Automatically categorize emails using AI:
- Email Trigger
- AI Prompt - "Categorize this email as: support, sales, billing, or other"
- If Task - Route based on category
Scheduled Email Checking¶
The system checks for new emails every 1-5 minutes automatically. You cannot customize this interval.
Frequently Asked Questions¶
Can I monitor multiple email addresses?¶
Yes, either: - Create multiple workflows, each with one Email Trigger - Or connect one account and use matching rules for different addresses
Does this work with shared mailboxes?¶
Yes for Microsoft 365 shared mailboxes. For Gmail, use group email addresses.
Can I delete emails after processing?¶
No, the Email Trigger only reads emails. To delete, you would need to use the email provider's API directly in a Code task.
What happens if I receive thousands of emails?¶
Each email triggers the workflow independently. For high-volume scenarios: - Use very specific matching rules - Consider batch processing with a Schedule trigger instead - Monitor execution costs
Can I access email headers?¶
Yes, all standard email headers are available in the output. Use JSON notation to access specific headers:
How quickly does the workflow trigger?¶
Usually within 1-5 minutes of email receipt. This varies based on system load.
Can I trigger on sent emails (not just received)?¶
No, only incoming emails trigger workflows. For sent emails, use your email provider's webhooks or API.
What's the attachment size limit?¶
Generally 25MB per attachment. Larger attachments may not be processed successfully.
Can I move processed emails to a folder?¶
Not directly. You would need to use the email provider's API in a Code task to move emails after processing.
Next Steps: - Form Submission Trigger - Trigger from website forms - Webhook In Trigger - Trigger from external systems - AI Prompt Task - Use AI to parse email content