Post image

This blog explains how to build an AI-powered email Assistant that can draft, edit, and send emails, store them as vector embeddings, and retrieve similar emails using contextual search. The assistant leverages Semantic Kernel for AI operations, Neon for vector storage, and Azure OpenAI API for generative AI. Everything is hosted on Azure.

To try it,

Features

  1. AI-Powered Draft Generation: Generate email drafts from natural language input using Semantic Kernel.
  2. Direct Email Sending: Securely send emails via Microsoft Graph API.
  3. Contextual Search: Perform similarity searches across historical emails and drafts using vector embeddings.

Architecture

The project is built using three main components:

  1. React Frontend:
    • Provides a modern UI for email composition and management.
    • Integrates seamlessly with backend services.
    • Offers real-time draft previews and editing capabilities.
  2. Semantic Kernel Backend:
    • Generates email drafts using AI models from Azure OpenAI.
    • Creates vector embeddings for email content.
    • Integrates with Microsoft Graph API for secure email sending.
    • Exposes API endpoints for frontend communication.
  3. NEON Database:
    • Serves as a serverless vector database for embeddings.
    • Supports efficient similarity searches across historical emails and drafts.
    • Offers scalable, reliable storage for real-time AI applications.
Post image

Technologies Used

  • Frontend: React with modern UI components and responsive design.
  • Backend: .NET with Semantic Kernel for seamless AI integration.
  • Database: NEON Serverless PostgreSQL for storing vector embeddings.
  • Authentication: Microsoft Graph API for secure email integration.
  • AI Features: Azure OpenAI for text generation (GPT-4) and embeddings.
  • Vector Search: PostgreSQL vector operations for similarity search.

Deployment

Both the backend and frontend are containerized with Docker and deployed to Azure.

New to Neon?

Neon is a serverless Postgres database with instant provisioning, autoscaling, database branching, and a generous Free plan. Get started without a credit card. 

Why NEON is Ideal for This Use Case

Built-in support for the pgvector extension allows for quick and accurate similarity searches, enabling contextual email retrieval. Neon’s serverless architecture automatically scales with the application’s demands, ensuring efficient handling of large volumes of emails. Neon’s database branching feature enables the creation of isolated, lightweight copies of the database in seconds. You can further extend the use case by introducing the database branching to create a dedicated database for each user. So that search queries that retrieve similar emails only belong to a certain user.

Learn how to build it 

Here the repo is https://github.com/passadis/ai-mailer-semantickernel and ask us any questions in Discord.