Message
Represents a single communication sent through any channel (email, SMS, WhatsApp, push, letter). Tracks the complete message lifecycle from draft to delivery with status transitions, scheduling, and provider integration. Supports templates, attachments, and detailed delivery metrics.
Properties
| Property | Type | Mode | Description | Required |
|---|---|---|---|---|
| channel | CommunicationChannel | stored | Reference to the communication channel used to send this message, defining the medium and provider configuration Example: | Required |
| type | string | stored | The type of message based on delivery medium Values: Example: | Required |
| status | string | stored | Current delivery status of the message in its lifecycle Values: Example: | Required |
| sender | json | stored | Information about the message sender, including name, address or phone number, and optional reply-to address Example: | Required |
| senderPerson | Person | stored | Reference to the person entity when the sender is a known person in the system | Optional |
| senderOrganization | Organization | stored | Reference to the organization entity when the sender is a known organization in the system | Optional |
| recipient | Person | stored | Reference to the person entity receiving this message, when the recipient is a known entity in the system Example: | Optional |
| recipientAddress | string | stored | Direct contact address for the recipient such as email address, phone number, or postal address when recipient entity is not available Example: | Optional |
| subject | string | stored | Subject line or title of the message, primarily used for email and letter formats Example: | Optional |
| content | text | stored | The main body content of the message in plain text, HTML, or markdown format Example: | Required |
| contentType | string | stored | Format specification for the message content Values: Example: | Required |
| template | MessageTemplate | stored | Reference to the message template used to generate this message content Example: | Optional |
| templateVariables | json | stored | Key-value pairs of variables substituted into the template to generate the final message content Example: | Optional |
| attachments | json | stored | Array of file attachments included with the message, containing filename, content type, size, and storage reference Example: | Optional |
| priority | string | stored | Delivery priority level affecting queue processing order and delivery urgency Values: Example: | Required |
| scheduledAt | datetime | stored | Scheduled date and time for sending the message, allowing deferred delivery Example: | Optional |
| sentAt | datetime | stored | Timestamp when the message was successfully sent to the delivery provider or channel Example: | Optional |
| deliveredAt | datetime | stored | Timestamp when the message was confirmed as delivered to the recipient's device or mailbox Example: | Optional |
| readAt | datetime | stored | Timestamp when the recipient opened or read the message, if tracking is enabled and supported Example: | Optional |
| failedAt | datetime | stored | Timestamp when the message delivery failed or bounced | Optional |
| failureReason | string | stored | Detailed explanation of why the message delivery failed, including error codes or provider responses | Optional |
| externalReference | ExternalReference | stored | Reference to the message record in the external communication provider system for tracking and webhook correlation | Optional |
| metadata | json | stored | Additional custom data associated with this message for integration, analytics, or business-specific tracking purposes Example: | Optional |
| isDelivered | boolean | calculated | Indicates whether the message has been successfully delivered to the recipient Example: | Required |
| isFailed | boolean | calculated | Indicates whether the message delivery has permanently failed or bounced | Required |
| deliveryDurationSeconds | integer | calculated | Time elapsed in seconds between sending and delivery confirmation Example: | Optional |
Examples
Example 1
{
"@type": "Message",
"channel": "channel-email-001",
"type": "email",
"status": "delivered",
"sender": {
"name": "Acme Corp",
"address": "orders@acme.com",
"replyTo": "support@acme.com"
},
"recipient": "person-123",
"recipientAddress": "john.doe@example.com",
"subject": "Your order #12345 has shipped",
"content": "<html><body><h1>Order Shipped</h1><p>Dear John, your order has been shipped and will arrive within 3-5 business days.</p></body></html>",
"contentType": "html",
"template": "template-order-shipped",
"templateVariables": {
"customerName": "John",
"orderNumber": "12345",
"estimatedDelivery": "3-5 business days"
},
"attachments": [
{
"filename": "invoice-12345.pdf",
"contentType": "application/pdf",
"size": 52480,
"url": "https://storage.acme.com/invoices/12345.pdf"
}
],
"priority": "normal",
"scheduledAt": null,
"sentAt": "2025-11-27T14:30:00Z",
"deliveredAt": "2025-11-27T14:31:15Z",
"readAt": "2025-11-27T15:45:30Z",
"failedAt": null,
"failureReason": null,
"externalReference": {
"@type": "ExternalReference",
"systemName": "SendGrid",
"externalId": "msg_abc123def456"
},
"metadata": {
"campaignId": "order-notifications",
"orderId": "12345",
"customerSegment": "premium"
},
"isDelivered": true,
"isFailed": false,
"deliveryDurationSeconds": 75
}Example 2
{
"@type": "Message",
"channel": "channel-sms-001",
"type": "sms",
"status": "queued",
"sender": {
"name": "AlertService",
"address": "+15551234567"
},
"recipient": "person-456",
"recipientAddress": "+15559876543",
"subject": null,
"content": "Your verification code is 837492. It will expire in 10 minutes.",
"contentType": "text",
"template": "template-verification-code",
"templateVariables": {
"code": "837492",
"expiryMinutes": "10"
},
"attachments": null,
"priority": "urgent",
"scheduledAt": null,
"sentAt": null,
"deliveredAt": null,
"readAt": null,
"failedAt": null,
"failureReason": null,
"externalReference": {
"@type": "ExternalReference",
"systemName": "Twilio",
"externalId": "sm_xyz789abc"
},
"metadata": {
"purpose": "authentication",
"attemptNumber": 1
},
"isDelivered": false,
"isFailed": false,
"deliveryDurationSeconds": null
}Example 3
{
"@type": "Message",
"channel": "channel-whatsapp-001",
"type": "whatsapp",
"status": "failed",
"sender": {
"name": "Customer Support",
"address": "+15551112222"
},
"recipient": null,
"recipientAddress": "+44123456789",
"subject": null,
"content": "Thank you for contacting us. Your support ticket #8899 has been created and our team will respond within 24 hours.",
"contentType": "text",
"template": "template-support-ticket-created",
"templateVariables": {
"ticketNumber": "8899",
"responseTime": "24 hours"
},
"attachments": null,
"priority": "high",
"scheduledAt": null,
"sentAt": "2025-11-27T12:15:00Z",
"deliveredAt": null,
"readAt": null,
"failedAt": "2025-11-27T12:15:45Z",
"failureReason": "Recipient phone number not registered on WhatsApp",
"externalReference": {
"@type": "ExternalReference",
"systemName": "WhatsApp",
"externalId": "msg_fail_001"
},
"metadata": {
"ticketId": "8899",
"department": "technical-support",
"retryAttempts": 3
},
"isDelivered": false,
"isFailed": true,
"deliveryDurationSeconds": null
}Example 4
{
"@type": "Message",
"channel": "channel-postal-001",
"type": "letter",
"status": "draft",
"sender": {
"name": "Legal Department",
"address": "123 Corporate Blvd, Suite 500, New York, NY 10001"
},
"recipient": "person-789",
"recipientAddress": "456 Customer Lane, Apt 3B, Los Angeles, CA 90001",
"subject": "Important Contract Amendment Notice",
"content": "Dear Valued Customer,\n\nThis letter serves as formal notification of amendments to your service agreement. Please review the enclosed documentation carefully.\n\nSincerely,\nLegal Department",
"contentType": "text",
"template": null,
"templateVariables": null,
"attachments": [
{
"filename": "amended-contract.pdf",
"contentType": "application/pdf",
"size": 128000,
"url": "https://storage.acme.com/legal/contracts/amendment-789.pdf"
}
],
"priority": "high",
"scheduledAt": "2025-12-05T08:00:00Z",
"sentAt": null,
"deliveredAt": null,
"readAt": null,
"failedAt": null,
"failureReason": null,
"externalReference": null,
"metadata": {
"documentType": "legal-notice",
"requiresSignature": true,
"contractId": "contract-789"
},
"isDelivered": false,
"isFailed": false,
"deliveryDurationSeconds": null
}Example 5
{
"@type": "Message",
"channel": "channel-push-001",
"type": "push",
"status": "read",
"sender": {
"name": "App Notifications",
"address": "app://notifications"
},
"recipient": "person-321",
"recipientAddress": null,
"subject": "New comment on your post",
"content": "Sarah Johnson commented: 'Great article! Very insightful analysis.'",
"contentType": "text",
"template": "template-comment-notification",
"templateVariables": {
"commenterName": "Sarah Johnson",
"commentText": "Great article! Very insightful analysis.",
"postTitle": "Understanding Distributed Systems"
},
"attachments": null,
"priority": "normal",
"scheduledAt": null,
"sentAt": "2025-11-27T11:00:00Z",
"deliveredAt": "2025-11-27T11:00:02Z",
"readAt": "2025-11-27T11:05:30Z",
"failedAt": null,
"failureReason": null,
"externalReference": {
"@type": "ExternalReference",
"systemName": "Firebase",
"externalId": "notification_xyz123"
},
"metadata": {
"postId": "post-567",
"commentId": "comment-890",
"deepLink": "app://posts/567/comments/890"
},
"isDelivered": true,
"isFailed": false,
"deliveryDurationSeconds": 2
}