What I Built and Why
I built Nylas Assistant, an AI-powered email assistant that integrates the Nylas API with OpenAI and the Qdrant vector database. This project implements Retrieval-Augmented Generation (RAG) mechanisms, allowing users to interact with an AI agent that can search and retrieve information from their inbox.
How It Works
The core of Nylas Assistant involves seamless integration of email data, AI-driven insights, and real-time user interaction:
Email Syncing: Upon user login, a Laravel background worker kicks off, syncing emails from the user’s inbox via the Nylas API. This is handled by the SyncEmailsToQdrant job, which processes each email to extract relevant content.
Embeddings Generation: The email content is then transformed into embeddings using the OpenAI API. These embeddings are vector representations of the email content, capturing semantic meaning.
Vector Storage with Qdrant: The generated embeddings are stored in a Qdrant vector database. Qdrant is a high-performance, vector search engine that allows for efficient similarity searches. In this context, it’s used to store and index the embeddings, enabling quick retrieval based on context during chat interactions.
AI-Powered Chat: When a user interacts with the chat UI, the OpenAI model retrieves the most relevant email embeddings from Qdrant, ensuring that the AI’s responses are contextually aware and tailored to the user’s specific email history.
I have also written a comprehensive README file on the Github repository, which also includes steps to build and configure this application, so you can try it yourself.
Demo
Code
tavsec / nylas-assistant
OpenAI and Qdrant powered AI assistant, which connects to your email inbox using Nylas API and can be used as an assistant
Nylas Assistant 🚀
Nylas Assistant is an AI-powered email assistant built with Laravel, Nylas, OpenAI, and Qdrant. Sync your inbox, parse emails, and store them as OpenAI embeddings in a Qdrant vector database. Interact with an OpenAI agent through a chat-like interface that provides context-aware responses based on your emails. ✉️💡
🎯 Features
- Email Syncing: Automatically syncs your inbox using the Nylas API.
- Email Parsing: Parses and stores emails as embeddings with OpenAI.
- AI Chat Interface: Chat with an OpenAI agent that understands your email context.
- Vector Storage: Efficient embedding storage and retrieval using Qdrant.
🛠️ Tech Stack
- Laravel: Backend framework.
- Nylas API: For email syncing and management.
- OpenAI: For generating embeddings and chat responses.
- Qdrant: Vector database for storing and querying embeddings.
🚀 Installation
- Clone the repository.
- Install dependencies.
composer install
- Set up environment variables. Add the following…
Your Journey
For this hackathon, I aimed to create an application that demonstrates the combined power of the Nylas API and the OpenAI language model. My goal was to build a chatbot assistant that provides deeper insights into a user's inbox.
I chose to develop the application using Laravel, even though PHP is not the typical choice for AI projects. I wanted to push the boundaries and see if I could build a robust AI application with it. I’m pleased with how it turned out!
The most challenging part was converting emails to vector embeddings, especially considering the large number of emails a user might have. I addressed this by dispatching asynchronous background jobs that can be batched into smaller tasks. This approach allows users to start chatting with the assistant even if email syncing is still in progress.
In the end, I created a simple chat UI that displays the chat history between the user and the assistant.
Top comments (2)
This looks great @timotej_avsec! I thing noticed is that you don't use entire body of email rather just the snippet that Nylas API provides. This is a great solution when we want to feed a long list of emails to these LLMs and Embedding models!
This is so cool! I got excited and wanted to contribute to the source code but I lack the php knowledge. I wonder if this can return references? As in if I ask for the list of emails of the people contacted me about a certain topic?