How to connect Email to an AI Agent
Connect your Flametree AI agent to email systems using IMAP/SMTP protocols to enable automated communication through email channels. This integration supports both traditional email providers and Microsoft Exchange environments.
Prerequisites
- Email Account with IMAP/SMTP access enabled
- SMTP server credentials for sending emails
- IMAP server credentials for receiving emails
- 2-Factor Authentication (2FA) enabled on your email account
- App password or OAuth credentials (strongly recommended)
- Admin access to your Flametree account
Setting Up Email Integration
Step 1: Prepare Email Account
-
Enable IMAP/SMTP Access
- For Gmail: Enable "Less secure app access" or use App Passwords
- For Outlook: Ensure IMAP is enabled in account settings
- For corporate emails: Contact IT admin for server details
-
Generate App-Specific Password
- Gmail: Google Account → Security → 2-Step Verification → App passwords
- Outlook: Account Security → Additional security options → App passwords
- Yahoo: Account Security → Generate and manage app passwords
Step 2: Collect Email Server Information
Save these values from your email provider:
Parameter | Description | Example |
---|---|---|
SMTP Server | Outgoing mail server | smtp.gmail.com |
SMTP Port | SMTP server port | 587 (TLS) or 465 (SSL) |
IMAP Server | Incoming mail server | imap.gmail.com |
IMAP Port | IMAP server port | 993 (SSL) |
Username | Full email address | user@example.com |
Password | Account or app password | your_app_password |
Configuring Flametree Integration
Step 1: Create Email Integration
- Navigate to Integrations
- Go to Channels section in Flametree
- Find IMAP/SMTP card and click Add +
💡 Note: IMAP/SMTP integration from Integrations section is outdated. Use Channels instead.
-
Fill Configuration
Field Description Required Example Value Source Name Custom integration name ✅ Yes Support Email Connector Your choice Description Integration purpose ✅ Yes Customer support email integration Your choice SMTP Server URL Outgoing mail server ✅ Yes smtp.gmail.com Email provider settings SMTP Server Port SMTP port number ✅ Yes 587 Email provider settings IMAP Server URL Incoming mail server ✅ Yes imap.gmail.com Email provider settings IMAP Server Port IMAP port number ✅ Yes 993 Email provider settings User name Full email address ✅ Yes support@company.com Your email account Password App-Specific Password ✅ Yes your_app_password Your email account Interval (in seconds) for checking updates in the INBOX provided Check interval for new messages ❌ No 15 Your choice Interval (in seconds) for checking receipts in the INBOX provided Check interval for delivery receipts ❌ No 15 Your choice Enable OAUTH (true/false) Enable OAuth authentication ❌ No true Your email account OAUTH Refresh Token Long-lived refresh token ⚠️ OAuth only refresh_token_here OAuth provider console OAUTH Token URI Token endpoint URL ⚠️ OAuth only https://oauth2.googleapis.com/token OAuth provider docs OAUTH Client ID Application client ID ⚠️ OAuth only client_id_here OAuth provider console OAUTH Client Secret Application secret ⚠️ OAuth only client_secret_here OAuth provider console Standard Ports:
- SMTP:
587
(TLS),465
(SSL),25
(unencrypted) - IMAP:
993
(SSL),143
(unencrypted)
Recommended intervals:
15
seconds — Critical support channels60
seconds — Standard business email300
seconds — Low-priority or bulk email
- SMTP:
-
Save Integration
- Click Save to create the integration
Step 2: Connect to AI Agent
-
Open Agent Configuration
- Navigate to your target AI agent's settings
- Go to Channels section
-
Assign Channel
- Select your email integration from the list
- Save the agent configuration
-
Restart Agent
- Restart the agent for changes to take effect
- This step is mandatory for the integration to work
❗️ Important: Always restart both the agent and channel after making changes.
Popular Email Provider Settings
Provider | SMTP Server | SMTP Port | IMAP Server | IMAP Port | Security |
---|---|---|---|---|---|
Gmail | smtp.gmail.com | 587 | imap.gmail.com | 993 | TLS/SSL |
Outlook/Office 365 | smtp.office365.com | 587 | outlook.office365.com | 993 | TLS/SSL |
Yahoo | smtp.mail.yahoo.com | 587 | imap.mail.yahoo.com | 993 | TLS/SSL |
Exchange | mail.company.com | 587 | mail.company.com | 993 | TLS/SSL |
Common Issues & Solutions
Authentication failures
Possible causes:
- Incorrect username/password
- 2FA enabled without app password
- IMAP/SMTP disabled on account
Solutions:
- Verify credentials: Double-check username and password
- Generate app password: Create app-specific password for 2FA accounts
- Enable IMAP/SMTP: Check provider settings to ensure protocols are enabled
- Check account status: Verify account is not locked or suspended
Connection timeouts
Possible causes:
- Incorrect server settings
- Firewall blocking connections
- Server overload
Solutions:
- Verify server details: Check SMTP/IMAP server URLs and ports
- Test connectivity: Use telnet to test server connectivity
- Check firewall: Ensure outbound connections are allowed
- Try different ports: Test alternative ports (587 vs 465 for SMTP)
Messages not being sent
Possible causes:
- SMTP configuration errors
- Rate limiting
- Email blocked by provider
Solutions:
- Check SMTP settings: Verify server, port, and authentication
- Review rate limits: Check provider's sending limits
- Test with different recipient: Rule out recipient-specific issues
- Check spam folders: Verify messages aren't being filtered
Messages not being received
Possible causes:
- IMAP configuration errors
- Folder permissions
- Agent not restarted
Solutions:
- Verify IMAP settings: Check server, port, and authentication
- Check folder access: Ensure IMAP has access to INBOX
- Restart agent: Restart your Flametree agent after configuration
- Review polling interval: Ensure reasonable update interval
FAQ
Do I need a dedicated email account for the AI agent?
Recommended: Yes, use a dedicated email account (e.g., support@company.com) to avoid conflicts with personal or other business emails. This provides better organization and security.
Can I use the same email account for multiple agents?
It depends on the channel mode:
- ✅ Yes — If you're using the channel for outbound communications only
- ❌ No — If any agent has inbound mode enabled for this channel
Why this limitation exists:
- Multiple agents listening for inbound emails would cause conflicts
- Messages might be processed by multiple agents simultaneously
- Response duplication and inconsistent behavior would occur
Best practice: Use dedicated email accounts for each agent to ensure reliable message handling and avoid conflicts.
What's the difference between IMAP and POP3?
- IMAP: Syncs with server, messages stay on server, supports multiple clients
- POP3: Downloads messages locally, removes from server, single client access
Flametree uses IMAP for better integration and message management.
How do I set up OAuth instead of password authentication?
OAuth provides enhanced security but requires additional setup:
- Create OAuth app in your email provider's developer console
- Configure redirect URIs and scopes
- Generate refresh token using authorization code flow
- Enter OAuth credentials in Flametree integration
See provider-specific documentation for detailed OAuth setup steps.
What email features are supported?
Flametree email integration supports:
- ✅ Text emails (HTML and plain text)
- ✅ File attachments
- ❌ Multiple recipients (To, CC, BCC)
How to configure a calendar?
Default behavior: If no custom calendar is connected, the agent automatically offers 3 fixed time slots for the next day using internal logic.
For real calendar integration:
- Create custom skill group with calendar API skills (
checkAvailableSlots
,createCalendarEvent
,cancelCalendarEvent
) - Add necessary tools defined in YAML plugin files
- Connect skill group to your AI agent via
workflow
ordefault_skill_group
This enables the agent to work with actual availability and manage bookings when responding to emails.
Security Considerations
Credential Security
- Use app passwords instead of main account passwords
- Enable 2FA on email accounts
- Rotate credentials regularly
- Use environment variables for sensitive configuration
- Monitor access logs for unusual activity
Email Security
- TLS/SSL encryption for all connections
- Validate sender identity before processing