Convert your XML email archive into a smart RAG (Retrieval-Augmented Generation) source using Node.js + OpenAI
inbox-to-rag is a lightweight Node.js script that takes an XML file containing your emails and lets you ask smart questions about them — powered by OpenAI embeddings + GPT.
Great for:
- Searching your inbox intelligently
 - Prototyping RAG workflows
 - Working with email archives
 
- 📥 Load and parse 
emails.xml - 🧠 Create vector embeddings with OpenAI
 - 🧾 Compare your question to the email content
 - 🤖 Feed the most relevant chunks into GPT-4 for the final answer
 
git clone https://github.com/rastmob/inbox-to-rag.git
cd inbox-to-ragnpm installOPENAI_API_KEY=your-openai-key-hereYou can use .env.example as a starting point.
Drop your XML file in the root of the project. The structure should look something like:
<emails>
  <email>
    <subject>Invoice Reminder</subject>
    <from>john@example.com</from>
    <date>2024-12-01</date>
    <text>Just a reminder about the unpaid invoice from November.</text>
  </email>
  ...
</emails>npm startYou can change the sample question in index.js:
const answer = await askQuestion('What did John say about the invoice?', vectors);🧠 Answer:
John reminded you about an unpaid invoice from November. He likely expects a follow-up or payment soon.
- Node.js
 - OpenAI Embeddings + GPT-4
 - fast-xml-parser
 - dotenv
 
Made with ❤️ by Mehmet Alp
📬 For software development related emails: mehmet.alp@rastmobile.com
🔗 Rast Mobile
👨💻 GitHub: rastmob
MIT — use freely, improve freely 🚀