Email Integration
Vertesia agents support bidirectional email communication, enabling users to interact with agents through their email client instead of the Studio UI. This guide covers the three main email interaction patterns.
Overview
Email integration enables three distinct interaction patterns:
| Pattern | Trigger | Description |
|---|---|---|
| Agent response email | Agent completes or waits for input | Agent sends results or questions via email; user can reply to continue |
| Ask user via email | Agent uses ask_user tool | Agent asks questions via email when the user channel is set to email |
| Email-started workflow | User sends email to agent | User initiates a new agent session by sending an email to a project address |
All three patterns use a reply-to address format that routes responses back to the correct workflow run.
Prerequisites
Email integration is configured in Project Settings > Integrations > Resend Email.
Required Settings
| Setting | Description |
|---|---|
API Key | Your Resend API key for sending emails |
Inbound Domain | Domain for sending/receiving email (e.g., mail.yourcompany.com) |
Webhook Secret | Resend webhook signing secret for verifying inbound emails |
Security Settings (Optional)
| Setting | Default | Description |
|---|---|---|
Require Project Access | Enabled | Only users with project access can start agents via email |
Require Email Authentication | Enabled | Inbound emails must pass DKIM/SPF authentication |
Allowed Sender Domains | Empty (all) | Whitelist of allowed sender email domains |
DNS Configuration
Your inbound domain requires:
- MX records pointing to Resend's inbound servers
- SPF and DKIM records for email authentication
- Webhook configuration in Resend pointing to
https://your-studio-url/webhooks/resend
Pattern 1: Agent Response Emails
When a workflow has an email channel configured in user_channels, the agent automatically sends emails to the user:
- Completion emails: When a non-interactive workflow finishes
- Response emails: When an interactive workflow produces output and waits for input
- Ask user emails: When the agent needs to ask questions
How It Works
- Workflow runs with email channel in
user_channels(automatic for email-started workflows) - Agent processes the request and produces output
- System sends email with results and a reply-to address:
r+{routeKey}@{inbound_domain} - When user replies, the email is received by the inbound domain
- Resend sends a webhook to Vertesia
- The webhook extracts the run ID and sends a
UserInputsignal to the workflow - The workflow continues with the user's reply as input
Email Threading
All emails in a conversation maintain proper threading:
- Subject line preserves
Re: Original Subject In-Reply-ToandReferencesheaders enable proper threading in email clients- Users see all messages in a single thread
Pattern 2: Ask User via Email
When the workflow has an email channel configured in user_channels, the ask_user tool sends questions via email in addition to displaying them in the UI.
Configuration
Configure user_channels with an email channel in your workflow variables:
{
"vars": {
"type": "conversation",
"interaction": "my-agent",
"user_channels": [
{
"type": "email",
"to_email": "user@example.com"
}
]
}
}
The email channel supports email threading with optional fields:
thread_subject: Subject for the email thread (without "Re:" prefix)in_reply_to: Message ID for the In-Reply-To headerreferences: Array of message IDs for the References header
How It Works
- Agent calls
ask_userwith questions - System detects email channel in
user_channelsand sends an email to the configured recipient - The email contains the questions with context from the conversation
- User replies to the email with their answers
- Reply is routed back to the workflow and the agent continues
Email Formulation
When sending ask_user questions via email, the system uses an LLM to formulate a well-contextualized email that includes:
- Recent conversation context
- The current task being worked on
- The questions being asked
- Instructions for replying
Pattern 3: Email-Started Workflows
Users can start new agent sessions by sending an email to a project-specific address. This enables email-first workflows where users never need to access the Studio UI.
Email Address Format
{namespace}+{interaction-name}@{inbound_domain}
For example:
acme+review-contract@mail.vertesia.io- Start thereview-contractagent in theacmeprojectmyproject+analyst@mail.vertesia.io- Start theanalystagent in themyprojectproject
Access Control
When a user sends an email to start a workflow, the following checks are performed:
- Email authentication (if enabled): DKIM and SPF are verified
- Sender domain whitelist: If
Allowed Sender Domainsis configured, the sender must match - Project access (if enabled): The sender's email must belong to a user with access to the project
- Interaction access: The interaction must exist and be configured as an agent
Interaction Data Fields
When a workflow starts via email, the interaction receives the following data fields that can be used in the prompt template:
| Field | Type | Description |
|---|---|---|
{{message}} | string | The email body (plain text preferred, falls back to HTML) |
{{email.from}} | string | Sender email address |
{{email.subject}} | string | Email subject line |
{{email.source}} | string | Always "email" |
{{email.message_id}} | string | Unique email message ID |
{{email.has_attachments}} | boolean | Whether the email has attachments |
{{attachments}} | array | Uploaded attachment metadata (populated async) |
Example interaction prompt:
You are an assistant that processes requests received via email.
**Email from:** {{email.from}}
**Subject:** {{email.subject}}
**Request:**
{{message}}
Please analyze this request and respond appropriately.
How It Works
- User sends email to
{namespace}+{agent}@{domain} - Resend webhook receives the email and sends it to Vertesia
- System verifies sender access and email authentication (based on configuration)
- A new workflow starts with:
- Initial message from email body
- Email channel automatically configured in
user_channels(with sender's email asto_emailand thread info) - Email metadata (subject, from, attachments) available to the agent
- Agent processes the request and can use
ask_userto ask follow-up questions via email - User receives responses in their email client and can reply to continue
- When the workflow completes, the final result is automatically sent to the user via email
Attachments
Email attachments are automatically:
- Downloaded from Resend
- Uploaded to the workflow's artifact storage
- Made available to the agent for processing
Automatic Completion Email
When an email channel is configured in user_channels (automatically set for email-started workflows), the system will automatically send the workflow result to the user via email when the workflow completes. This ensures users who interact via email always receive their results without needing UI access.
The completion email:
- Includes the full workflow output
- Maintains email threading if part of an existing conversation
- Uses the same reply-to address format, allowing users to continue the conversation
Reply Address Format
All email flows use a consistent reply-to address format:
r+{routeKey}@{inbound_domain}
Where runId is the Temporal workflow run ID with dashes removed (to comply with RFC 5321's 64-character local-part limit).
When a reply is received:
- The run ID is extracted from the address
- Temporal is queried to find the workflow
- Project and account IDs are retrieved from search attributes
- The Resend integration settings are used for webhook verification
- The email content is sent as a
UserInputsignal to the workflow
Best Practices
For Ask User via Email
- Configure the LLM environment and model for email formulation
- Keep questions concise and numbered for easy reference
- Provide sufficient context for users to answer without accessing the UI
For Email-Started Workflows
- Document the email address format for users
- Consider setting up
Allowed Sender Domainsfor security - Design agents to be self-contained (don't assume UI access)
- Handle email attachments appropriately in your agent logic
Security Recommendations
- Keep
Require Email Authenticationenabled to prevent email spoofing - Keep
Require Project Accessenabled unless you specifically need public access - Use
Allowed Sender Domainsto restrict access to specific organizations - Regularly rotate your Resend API key and webhook secret
Troubleshooting
Emails Not Being Received
- Verify MX records are correctly configured
- Check Resend webhook is active and pointing to the correct URL
- Verify
Webhook Secretmatches between Resend and your Vertesia configuration
Replies Not Reaching Workflow
- Check the workflow is still running (not completed or timed out)
- Verify the reply-to address format is correct
- Check Resend webhook logs for delivery status
Email-Started Workflows Failing
- If
Require Project Accessis enabled, verify the sender has project access in Vertesia - If
Require Email Authenticationis enabled, check DKIM/SPF authentication is passing - Verify the interaction exists and is configured as an agent
- Check the Resend integration is enabled in Project Settings > Integrations
