Opening Problem Statement
Meet Sarah, a busy project manager juggling multiple deadlines and countless emails daily. Every morning, she spends nearly two hours sifting through her overflowing inbox to find important messages, action items, and urgent deadlines. This manual process leads to missed deadlines, overlooked tasks, and a lot of unnecessary stress. Sarah needs a solution that can help her quickly extract the essence of her emails, highlight urgent matters, and notify her instantly on a convenient platform like LINE messenger.
That’s exactly where this n8n workflow comes into play. It reads Sarah’s emails automatically, leverages AI to summarize their content intelligently, highlights deadlines and actions, and pushes these summaries directly to her LINE messenger, making her mornings more productive and less overwhelming.
What This Automation Does
This tailored automation designed in n8n performs the following actions every time it runs:
- Reads emails automatically from Sarah’s inbox via IMAP, capturing sender, subject, and full email content.
- Uses AI summarization via Openrouter AI applying a powerful “meta-llama/llama-3.1-70b-instruct” model to provide concise summaries.
- Highlights urgent emails and deadlines by detecting action items and marking deadlines in bold with an emoji for urgency.
- Filters out unimportant messages with brief one-sentence summaries, keeping noise minimal.
- Sends summarized content directly to Sarah’s LINE messenger, ensuring updates are accessible anytime on mobile devices.
- Eliminates manual email triage, saving Sarah at least 90 minutes every day.
Prerequisites ⚙️
- n8n account (self-hosted or cloud)
- IMAP email account credentials (e.g., Gmail configured for IMAP access) 📧
- Openrouter.ai account with an API key for AI summarization 🔐
- LINE Messaging API channel access token to send messages 💬
- API credentials for HTTP header authentication 🔑
Step-by-Step Guide
1. Set up the “Read emails (IMAP)” node
Navigate to Nodes > Add Node > Email > IMAP Email. Configure your email account credentials to connect via IMAP. For Gmail, enable IMAP in your Gmail settings and generate an app password if using two-factor authentication.
Parameters to configure:
- Set “Post Process Action” to “Nothing” to avoid marking emails as read automatically.
- Test the connection and ensure emails appear in the node data.
Visual tip: You should see emails flowing through this node once activated.
Common mistake: Forgetting to enable IMAP access in your email account settings.
2. Configure the “Send email to A.I. to summarize” HTTP Request node
Choose Nodes > HTTP Request. Set the method to POST and the URL to https://openrouter.ai/api/v1/chat/completions.
Use the following JSON body (adjust to your email fields):
{
"model": "meta-llama/llama-3.1-70b-instruct:free",
"messages": [
{
"role": "user",
"content": "I want you to read and summarize all the emails. If it's not important, just give me a short summary with less than 10 words.nnHighlight as important if it is, add an emoji to indicate it is urgent:nFor the relevant content, find any action items and deadlines. Sometimes I need to sign up before a certain date or pay before a certain date, please highlight that in the summary for me.nnPut the deadline in BOLD at the top. If the email is not important, keep the summary short to 1 sentence only.nnHere's the email content for you to read:nSender email address: {{ encodeURIComponent($json.from) }}nSubject: {{ encodeURIComponent($json.subject) }}n{{ encodeURIComponent($json.textHtml) }}"
}
]
}Authentication: Use HTTP Header Auth with header “Authorization” set as “Bearer YOUR_OPENROUTER_API_KEY”.
Visual tip: Once triggered, the node will receive AI-completed JSON responses.
Common mistake: Using incorrect API keys or missing the “Bearer ” prefix in the auth header.
3. Configure the “Send summarized content to messenger” HTTP Request node
Add another HTTP Request node. Set method as POST, URL as https://api.line.me/v2/bot/message/push.
JSON body example to send captured AI summary to your LINE user ID:
{
"to": "YOUR_LINE_USER_ID",
"messages": [
{
"type": "text",
"text": "{{ $json.choices[0].message.content.replace(/n/g, "\n") }}"
}
]
}Authentication: Use HTTP Header Auth with “Authorization” and value “Bearer YOUR_CHANNEL_ACCESS_TOKEN” obtained from the LINE API Console.
Visual tip: Your LINE messenger should receive the summarized email text instantly.
Common mistake: Using the outdated official LINE node instead of HTTP Request + header auth.
4. Link the nodes
Connect the output of the “Read emails (IMAP)” node to the “Send email to A.I. to summarize” node, then connect this to the “Send summarized content to messenger” node. This creates a streamlined data flow.
Expected Outcome: When emails arrive, AI-powered summaries will be pushed to LINE messenger automatically.
Customizations ✏️
- Change AI model: In the HTTP Request node to Openrouter AI, update the “model” parameter to other models like “gpt-4o” for more advanced or specific summarization.
- Adjust summary length: Modify the prompt content in the HTTP Request node by changing the instructions to make summaries longer or shorter.
- Filter emails: Add an extra node (like a Function node) to filter emails by sender or keywords before sending to AI, so only priority emails are summarized.
- Send to multiple LINE users: Modify the “to” field in the LINE node’s JSON body to send summaries to different recipients group-wise.
Troubleshooting 🔧
Problem: “401 Unauthorized” error on AI or LINE API calls
Cause: Incorrect or missing API key, or faulty header authorization.
Solution: Double-check your API keys and ensure the “Authorization” header includes “Bearer ” prefix with your token.
Problem: No emails read or no data output from the IMAP node
Cause: IMAP settings incorrect or emails not accessible.
Solution: Confirm IMAP is enabled on your email account, verify login credentials, and test the connection manually.
Problem: Summaries are too short or irrelevant
Cause: The prompt sent to the AI needs refinement.
Solution: Edit the JSON body prompt instructions for the AI node to be clearer and more explicit about what you want.
Pre-Production Checklist ✅
- Verify IMAP connection reads emails correctly by checking sample output.
- Test Openrouter AI HTTP request node independently to ensure AI responses look correct.
- Check LINE messaging node sends test messages to your LINE user ID.
- Ensure API keys for both AI and LINE are up-to-date and valid.
- Test running the entire workflow manually before scheduling automation.
Deployment Guide
Activate your workflow in n8n (toggle from inactive to active). Schedule it on a regular interval or trigger it manually to run. Monitor executions in the n8n dashboard’s Execution List for any errors or anomalies.
If self-hosting n8n, ensure your environment has access to the internet for API calls and your email server.
FAQs
Can I use Gmail instead of other email providers?
Yes! Gmail supports IMAP, just ensure you enable IMAP access and use app passwords if two-factor authentication is enabled.
Does this workflow consume API credits on Openrouter AI?
Openrouter offers free tiers; usage limits depend on your plan. Monitor usage on your Openrouter dashboard.
Is my email data secure with this workflow?
Emails are processed within secure API calls and your n8n environment. Avoid sharing API keys publicly and use secure credential storage in n8n.
Conclusion
By following this detailed guide, you’ve set up a powerful, AI-powered email summarization system that reads your inbox, highlights important info, and sends concise summaries straight to your LINE messenger. You’ve saved yourself hours daily and reduced the risk of missing deadlines or forgetting critical tasks.
Next up, you could enhance this workflow by integrating calendar reminders for deadlines or adding Slack notifications for team updates.
Congratulations on automating an essential, time-consuming task with n8n and Openrouter AI! Keep exploring, and soon you’ll automate even more of your daily workload effortlessly.