Skip to main content

Outbound Email

Outbound email requests manage composing, scheduling, and tracking emails sent through AI-powered communication workflows. Supports HTML/text content, attachments, templates with variable substitution, and scheduled delivery.

Source: src/core/conversation/outbound-email.schema.ts


EmailRequest

Complete outbound email request with content, recipients, attachments, and scheduling options. Supports HTML and plain text content, template-based composition with variable substitution, and scheduled delivery.

Schema: EmailRequestSchema

Attributes

AttributeTypeRequiredDefaultDescription
idstringYesUnique identifier for this email request
emailConfigurationIdstringNoEmail configuration ID for sender settings and credentials
templateIdstringNoPre-defined email template ID for structured content
toarray<EmailRecipient>YesPrimary recipients (at least one required)
ccarray<EmailRecipient> | nullNoCarbon copy recipients
bccarray<EmailRecipient> | nullNoBlind carbon copy recipients
replyTostring | nullNoReply-to email address
subjectstringYesEmail subject line (supports {{variable}} syntax)
bodyHtmlstringYesHTML content of the email body
bodyTextstringNoPlain text alternative content
variablesobjectNoTemplate variable substitutions as key-value pairs
attachmentsarray<EmailAttachment> | nullNoFile attachments (total size should not exceed 25MB)
scheduledAtnumberNoUnix timestamp in milliseconds for scheduled delivery
serviceConversationConfigIdstring | nullNoLinked conversation record ID for threading
metadataobjectNoAdditional custom metadata for campaign tracking
createdAtnumberNoUnix timestamp when created
updatedAtnumber | nullNoUnix timestamp when last updated

EmailRecipient

Email recipient with address and optional display name.

Schema: EmailRecipientSchema

Attributes

AttributeTypeRequiredDescription
emailstringYesEmail address in standard format (e.g., 'user@example.com')
namestringNoDisplay name shown in email clients (e.g., 'John Smith')

EmailAttachment

File attachment to include with an outbound email. Content must be base64-encoded.

Schema: EmailAttachmentSchema

Attributes

AttributeTypeRequiredDescription
filenamestringYesName of the attachment file (e.g., 'invoice.pdf')
contentstringYesBase64-encoded file content
contentTypestringYesMIME type (e.g., 'application/pdf', 'image/png')

CreateEmailRequest

Schema for creating a new email request. Omits auto-generated fields (id, timestamps, audit fields).

Schema: CreateEmailRequestSchema

Attributes

Same as EmailRequest, excluding: id, createdAt, updatedAt, createdBy, updatedBy, deletedAt, deletedBy, uniqueKey, version.


Example

Email Request

{
"id": "email_abc123",
"to": [
{ "email": "customer@example.com", "name": "John Smith" }
],
"cc": [
{ "email": "manager@example.com", "name": "Jane Doe" }
],
"subject": "Your Order Confirmation - #{{order_id}}",
"bodyHtml": "<h1>Thank you, {{name}}!</h1><p>Your order #{{order_id}} is confirmed.</p>",
"bodyText": "Thank you, {{name}}! Your order #{{order_id}} is confirmed.",
"variables": {
"order_id": "12345",
"name": "John"
},
"metadata": {
"campaignId": "camp_789",
"templateVersion": "v2"
},
"createdAt": 1709856000000
}

Email with Attachment

{
"to": [
{ "email": "customer@example.com" }
],
"subject": "Your Invoice",
"bodyHtml": "<p>Please find your invoice attached.</p>",
"attachments": [
{
"filename": "invoice.pdf",
"content": "JVBERi0xLjQKJeLjz9MKMyAwIG9...",
"contentType": "application/pdf"
}
]
}

Scheduled Email

{
"to": [
{ "email": "customer@example.com", "name": "Customer" }
],
"subject": "Reminder: Your appointment tomorrow",
"bodyHtml": "<p>This is a reminder about your appointment.</p>",
"scheduledAt": 1709942400000
}