EmailSnap is an AI-powered service that simplifies email processing by analyzing email threads, attachments, and summarizing key action items. By leveraging LLMs, EmailSnap provides users with a quick and actionable summary of their emails, allowing them to focus on what matters most.
Medium: Empower Your Email Routine with LLM Agents: 10X Efficiency Unlocked
- Automated Email Parsing: Handles complex email threads, removes redundant information, and formats the content into an easy-to-read structure.
- Attachment Processing: Automatically renames and summarizes attachments (PDFs, images, etc.) using AI, helping users quickly understand the content.
- Actionable Insights: Extracts action items and key highlights from the email body and attachments, making decision-making faster and easier.
- Email Receival: Emails are forwarded to
[email protected]
, where the service processes both the email content and its attachments. - AI-Powered Processing: Using the LangChain stack, including LangGraph and LangSmith, multiple LLM calls process different parts of the email:
- Format the email body, handle threads, and remove irrelevant content.
- Read and convert attachments (images, PDFs) into Base64 for analysis.
- Summarize the attachments and rename files based on content.
- Final Email Generation: A clean and concise email summary is generated, including key highlights, action items, and renamed attachments.
The underlying infrastructure is built using AWS services:
- SES For receiving emails.
- S3: For storing email content and attachments.
- SQS/SNS: To handle email notifications and message queueing.
- RDS (MySQL) and EC2: For running the Dockerized service and storing data
- LangChain, LangSmith for managing LLM processes and monitoring performance.
Follow next steps to run the project:
Create .env file with:
(for simplicty use openssl rand -base64 42
to generate random keys)
MYSQL_ROOT_PASSWORD=[Random]
MYSQL_DATABASE=[Random]
MYSQL_USER=[Random]
MYSQL_PASSWORD=[Random]
RDS_DATABASE_URL=[From Terraform Output]
S3_BUCKET=[From Terraform Output]
SQS_QUEUE_URL=[From Terraform Output]
OPENAI_API_KEY=[Visit OpenAI]
AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=[Optional, in case you want to run locally]
AWS_SECRET_ACCESS_KEY=[Optional, in case you want to run locally]
SUPERSET_SECRET_KEY=[Random]
SUPERSET_ADMIN_USERNAME=[Random]
SUPERSET_ADMIN_PASSWORD=[Random]
SUPERSET_ADMIN_EMAIL=[Random]
SUPERSET_DATABASE_URL=[From Terraform Output, use differnt DB name]
LANGCHAIN_TRACING_V2=true
LANGCHAIN_ENDPOINT="https://api.smith.langchain.com"
LANGCHAIN_API_KEY=[Visit Langchain]
LANGCHAIN_PROJECT=[Any value]
Follow ./ssh/Readme.md steps:
- Create a new SSH key in /shh folder;
- It will be automatically installed by Terraform on EC2
- Copy it to your
~/.ssh
and create configurations forssh emailsnap
Create a service role for Terraform
Make sure you purchased domain name;
Follow steps in ./terraform/Readme.md:
- Update variable, including domain name in variables.tf
- Apply terraform infrastructure
- On the first attempt it will fail as AWS SSL Certificate is not verifiend, go to the console, copy CNAME and add your your DNS configurations
- Apply terraform infrastructure again
- Read output variable
terraform output
- Update
.env
and~/.ssh/config
with correct output variable
- Connect to AWS RDS
- Can use dbeaver.io or similar
- Apply all migration files from Database folder
- Connect to the EC2
ssh emailsnap
- Copy
ssh
from machine:cat ./.ssh/id_rsa.pub
- Add
ssh
key to git ptovider. Gitlab/Github - Clone project
git clone ...
- cd
emailsnap-service
- run
docker-compose up
You can use nvim
to edit files, it is installed with Terrafomr (main.tf).
Open SES
dashboard:
- Find
Configuration -> Identity -> DKIM
, pressGenerate
- Copy
CNAME
records to your domain DNS provider
- Copy
- Add MX in DNS provider: Naem:
domain
; Mail server10 inbound-smtp.us-east-1.amazonaws.com
- Open
Amazon SES -> Email receiving
, select our ruledefault-rule-set
pressActivate
- Open
SNS
->Identity
-> Open our identity ->Authentification
->Custom MAIL FROM domain
: Setup and add MX to Cloudflare - Open
SNS
->Get Production Access
, provide justification for send access.
Let's take a look at a real example. I took an MRI report in PDF format from an online source, sent it to one email address, and then forwarded it to [email protected]. EmailSnap generated a new subject, highlights, and summary. It also extracted the recipient from the PDF - Dr. Ross Banner - and finally suggested a new file name: Regina Doe MRI Report, based on the patient's name and procedure.