Intelligent Communication System with n8n and LLM
In today’s article, I’d like to share a project that significantly streamlines daily communication by combining the capabilities of n8n, Airtable, and language models. This system allows sending SMS and email messages to contacts using text commands interpreted by an LLM, with additional verification and archiving mechanisms.
🔍 Project Overview
The created system enables sending SMS and email messages through text commands, retrieving communication history, scheduling messages for future delivery, and storing all communication in Airtable. Before executing any action, the system implements a verification step to prevent miscommunication due to potential LLM misinterpretation.
📋 Data Structure
The system is based on two main tables in Airtable:
Contacts Table:
- Name - contact’s full name
- Phone - phone number
- Email - email address
- Default contact type - preferred contact method (Email or SMS)
- Contact type - contact category (Professional, Private)
Messages Table:
- Contacts - relationship to the contacts table
- Delivery Method - delivery method (Email or SMS)
- Subject - message subject
- Message - message content
- Status - message status (Done, Todo)
- Send Date - date and time of sending
🔧 How It Works
The central element of the system is n8n - a no-code workflow automation tool. The Alice application (https://heyalice.app/) serves as the user interface that processes text commands and passes them to the n8n endpoint in the form of a JSON structure.
The workflow consists of these steps:
- User enters a text command into Alice
- LLM within Alice interprets the command and creates a JSON structure
- The request is sent to the n8n endpoint
- n8n processes the request and executes the appropriate workflow
- Before executing the action, a confirmation email is sent for verification
The main n8n workflow includes Webhook (entry point), Split Out (separating operations), Loop Over Items (processing each operation), Switch (distinguishing between Create and Read operations), and integrations with Airtable, Gmail, and Twilio.
🔒 LLM Integration & JSON Structure
The integration with language models is handled through Alice (https://heyalice.app/), which uses a specific prompt to generate structured JSON from natural language input. Here’s the prompt that enables this functionality:
As your Communication Manager, I'll extract information from our conversation and format it as a valid JSON array containing message or query objects compatible with the API.
JSON Structure for message creation and retrieval:
"operations": [
{
"operation": "Create",
"recipient": "contact_name",
"subject": "subject of the message",
"message": "message_content",
"sendDate": "future date/time for sending (ISO format, empty - '' if not specified)",
"deliveryMethod": "Phone or Email (empty - '' if not specified)"
},
{
"operation": "Read",
"filters": {
"name": "search string for recipient name (optional)",
"status": "status filter (empty string if not explicitly specified)",
"fromDate": "start date/time for filtering (ISO format, optional)",
"toDate": "end date/time for filtering (ISO format, optional)"
},
"limit": number_of_messages_to_return
}
// Additional objects as needed
]
Example for creating messages:
"operations": [
{
"operation": "Create",
"recipient": "Jan Kowalski",
"subject": "Meeting title",
"message": "I confirm the meeting date on March 20.",
"sendDate": "2025-03-20T14:30:00",
"deliveryMethod": "Email"
},
{
"operation": "Create",
"recipient": "Anna Nowak",
"subject": "Payment reminder",
"message": "Please settle the invoice by the end of the week.",
"sendDate": "",
"deliveryMethod": "Phone"
}
]
Example for retrieving messages:
"operations": [
{
"operation": "Read",
"filters": {
"name": "Jan Kowalski",
"status": "",
"fromDate": "2025-03-23T14:00:00",
"toDate": "2025-03-23T17:00:00"
},
"limit": 10
}
]
Example for mixed operations:
"operations": [
{
"operation": "Create",
"recipient": "Jan Kowalski",
"subject": "Project meeting",
"message": "I invite you to the project meeting.",
"sendDate": "2025-03-25T10:00:00",
"deliveryMethod": "Email"
},
{
"operation": "Read",
"filters": {
"status": "",
"fromDate": "2025-03-23T00:00:00",
"toDate": "2025-03-24T23:59:59"
},
"limit": 5
}
]
Current datetime: {{CURRENT_DATETIME}}
Important notes:
1. CRITICAL: Always return a JSON ARRAY wrapped in square brackets [ ], even for single operations
2. Never return a JSON object wrapped in curly braces { } as the root element
3. Maintain consistent structure for all array elements
4. Handle multiple concurrent requests in single conversation
5. Each object must include the "operation" field set to either "Create" or "Read"
6. For "Create" operations, include recipient, subject, message, sendDate and deliveryMethod
7. For "Read" operations, include filters with optional name, status, fromDate, toDate, and limit fields
8. When no specific status filter is provided for a "Read" operation, leave the status field as an empty string ("")
I will always respond exclusively with properly formatted JSON array regardless of conversation context.
The system understands two main types of operations:
- Create - creating new messages to send
- Read - reading communication history with filtering
Both operations can be combined in a single request, allowing for sophisticated workflows such as sending a message and then retrieving recent communication history with the same contact.
Security and Verification
To prevent errors from LLM misinterpretation, the system implements a two-step verification process:
- LLM interprets commands and creates a JSON structure
- The system sends a confirmation email with action details
- Only after approval is the action executed
This security layer is crucial when automating communication based on AI interpretation of natural language.
🔗 Summary
This project demonstrates how n8n, Airtable, and language models can be used to create an intelligent communication system that significantly facilitates daily work. The primary advantage is using natural language commands instead of learning complicated interfaces or remembering data structures.
The real power of this system comes from combining multiple technologies:
- Alice app for natural language processing and endpoint connection
- n8n for workflow automation and integration
- Airtable for structured data storage
- Email verification for security