Email Buddy: An LLM-Enhanced Inbox

Email Buddy: An LLM-Enhanced Inbox

This is a submission for the Nylas Challenge: AI Expedition. What I Built and Why I built...

Published:

2 min read

Originally posted on dev.to .

What I Built and Why

I built a simplified email inbox which uses OpenAI's GPT-4o mini model to generate email drafts and determine whether or not a reply should be sent.

The email draft generation takes an email thread from Nylas, and converts into a series of messages before submitting it to OpenAI's chat completion endpoint. The chat completion then returns a draft email body.

For no-reply classification, the latest, inbound email is retrieved from the thread. The email is then submitted to the OpenAI chat completions endpoint for classification. The endpoint returns a JSON response with a boolean indicating whether or not a reply should be sent, and an explanation as to why the user may not want to send a reply.

I built this app because email draft generation seemed like a very straightforward way to combine generative AI with the Nylas APIs. Additionally, the ability to detect no-reply emails seemed useful as it could help prevent emails being sent by mistake.

Demo

Code

GitHub logo h93xV2 / email-buddy

Intelligent email assistant web app.

This is a Next.js project bootstrapped with create-next-app.

It was built for the Nylas AI and Communications Challenge. The app offers a simplified email inbox with some LLM powered features. You can read about the app in the submission post.

Getting Started

Environment Variables

First, create a .env file with the following environment variables:

  • NYLAS_CLIENT_ID
  • NYLAS_API_KEY
  • NYLAS_API_URI
  • NYLAS_TEST_GRANT
  • NYLAS_REDIRECT_URI
  • OPENAI_API_KEY

Starting the App

Next, run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
Enter fullscreen mode Exit fullscreen mode

Open http://localhost:3000 with your browser to see the result.

Learn More

This app was built with NextJS, Bulma, TanStack Query, Nylas, and OpenAI. To learn more about these technologies, take a look at the following resources:




Your Journey

For this app, I mostly used the Nylas Email APIs, but I also used the Authentication API to exchange a token for a grant. The token exchange is used to simulate a login/logout flow.

From the Email APIs, I made use of:

  • Thread retrieval.
  • Folder retrieval.
  • Message retrieval.
  • Message sending.
  • Updating threads.
  • Draft creation.

From this project, I learned a few things:

  1. Nylas makes working with emails really simple.
  2. Integrating Nylas with OpenAI was also really simple.
  3. Defining an MVP for an app is easy, but building it might not be. Designing and building a UI can often be the most time consuming part of a project.

As far as the third bullet point goes, I am a backend software engineer for my day job. The hardest part of this project, for me, was developing all the frontend components. For example, I had to bring in TanStack Query to share state across components. Before this project, I had no experience with TanStack Query. So picking this up on the fly did add a layer of stress, but was ultimately worthwhile. For future contests/hackathons, I think I will have to spend more time simplifying an idea before iterating on it.

What I'm most proud of is just getting this project to a stopping point 😅. While working on it, I found that email inboxes can be a real rabbit hole where the complexity can quickly get out of control for one person.


profile

Welcome to my blog! I am a software engineer based in Southern California, and I love sharing my thoughts and experiences about all things tech. From software development and programming to the latest tech trends and news, you’ll find it all here on my blog. Follow along to stay up to date and get insights from a real-life software engineer living and working in SoCal. Thanks for visiting!

New post!

Creating a Custom Astro Integration: Auto-Publishing to Hashnode

Click here to read more!