DEV Community

Cover image for Nylas Mailbox AI Assistant 🤖
Dmytro Werner
Dmytro Werner

Posted on

Nylas Mailbox AI Assistant 🤖

This is a submission for the Nylas Challenge: AI Expedition.

What I Built and Why

Hello everyone 🙂
Using Nylas-API and Cloudflare-AI I have build Mailbox AI Assistant to help:

  • organize your emails 💻
  • send congratulations to your contacts if they have birthday 🥳
  • get your next events 🎊
  • automatically summarize content from email and send the answer to emails, that were not read 📖 🤖
  • get information, how much emails I have got this week 🗓

Main idea was to automatize minor things, that you could forget, like congratulations or get information about your email and calendar.

Demo

First of all we could get information about emails of the current week. For this one I have used ´queryParams´ from Nylas API:

const messages = await nylas.messages.list({
      identifier,
      queryParams: {
        received_after: Math.floor(startOfWeek.getTime() / 1000)
      }
    });
Enter fullscreen mode Exit fullscreen mode

Image description

Second feature is to get contacts and they birthday days. If it is today, add button with functionality to send congratulations according to personal information from your contact, like name and age. This one we get from contacts using Nylas API.

const contacts = await nylas.contacts.list({
      identifier,
      queryParams: {},
    });
Enter fullscreen mode Exit fullscreen mode

Image description

Next one is to get events.

   const calendars = await nylas.calendars.find({
      identifier,
      calendarId: "primary",
    });
Enter fullscreen mode Exit fullscreen mode

Image description

And now main content with most of codes. So we have emails, that are you did not read.

    const messages = await nylas.messages.list({
      identifier,
      queryParams: {
        unread: true,
      },
    });
Enter fullscreen mode Exit fullscreen mode

Image description

You can summarize email content using cloudflare model cf/facebook/bart-large-cnn.

Image description

In the next step you can generate the answer using other cloudflare model cf/openchat/openchat-3.5-0106.

Image description

If you click send email, generated email will be send to person, that wrote this one.

Code

Submitting for Nylas AI and Communications Challenge

Using Nylas-API and Cloudflare-AI I have build Mailbox AI Assistant to help:

  • organize your emails 💻
  • send congratulations to your contacts if they have birthday 🥳
  • get your next events 🎊
  • automatically summarize content from email and send the answer to emails, that were not read 📖 🤖
  • get information, how much emails I have got this week 🗓

Your Journey

That was really interesting to use nylas api to get information from my mail account. Best part of this, that you can write directly in your request the queryParams with some conditions, that I have used for getting emails for current week.

Im most proud of finishing the main features of this project and integrating AI text generating with key features of Nylas API.

Most challenging was to create the concept and implement the logic for using AI to summarize and generate response of text. The solution for this was to create generating step by step with possibility to send response if thats ok or regenerate response.

I found documentation of Nylas very good structured and prepared. Very useful was the page with endpoints:
Documentation Nylas

List of models of cloudflare you can find under:
Cloudflare Models

Thanks a lot for organization this challenge. Made me happy to work on this one 🤗

Thanks

Top comments (0)