• AI Academy
  • Posts
  • đź“š Filter incoming emails automatically with AI

đź“š Filter incoming emails automatically with AI

How we use ChatGPT to categorize and route inbox messages

Reading Time: 4 minutes

Hello AI Enthusiast,

Today, we're sharing how we automated the sorting of emails received at AI Academy's general inbox. We'll show you how we built a system that uses ChatGPT to analyze, categorize, and route incoming messages to the right team members automatically.

The Problem

Managing a busy general email inbox (you know, that [email protected] address) can be overwhelming. At AI Academy, we were spending a lot of time manually sorting through partnership requests, support tickets, questions about our programs, and other general inquiries.

Sound familiar?

What's your biggest challenge with managing a general inbox?

Login or Subscribe to participate in polls.

How We Do It: A Step-by-Step Guide

Let's walk through how we built our AI-powered email filtering system using Gmail, ChatGPT, and Make. We'll show you how we automated this process while maintaining the human touch where it matters.

Step 1: Set Up the Classification System

First, we defined our email categories:

  • Partnerships

  • Support requests

  • Course inquiries

  • Marketing/PR

  • Other

Step 2: Build the Automation Flow

Here's how we connected everything using Make:

Complete Make automation workflow

Our workflow uses four main modules:

a. Gmail Module: Monitors our general email inbox

Gmail trigger settings

b. OpenAI Module: ChatGPT analyzes the email and returns structured data in JSON format.

Before building our automation, we create a prompt and test it out. Only when satisfied with the outputs we add it to the OpenAI module. Here’s the prompt we used:

Act as a helpful assistant for [Company Name], a company specializing in [Company Description]. I will give you an email (subject and content), you will have to categorize it according to the category description I will give you here.

CATEGORIES:
Partnerships: Any business collaboration, corporate training, or partnership requests
Support: Technical issues, access problems, or student assistance
Courses: Questions about courses, pricing, or enrollment
Marketing: Press inquiries, marketing collaborations, or PR requests
Other: Anything that doesn't fit the above categories

Respond in JSON format with these fields:
{
  "category": "chosen category",
  "confidence": "high/medium/low",
  "reasoning": "brief explanation",
}

EMAIL SUBJECT: {{1.subject}}
EMAIL CONTENT: {{1.text}}

OUTPUT:

Our prompt extracts 3 key information from emails:

  1. Category

  2. Confidence of the model (to ensure that every email will always go to the correct team member)

  3. Reasoning (to debug and improve the automation)

The answer, formatted as JSON, helps us structure the information consistently:

ChatGPT module’s output

ℹ️ JSON (JavaScript Object Notation) is a simple way to organize data in a format that's easy for both humans and machines to read.

c. JSON Module: Parses the structured data.

This structured format acts as a bridge between ChatGPT's analysis and our automation, ensuring a correct filtering process.

JSON parser configuration

JSON parsing results

d. Filtering requests: we set up different filter to match the correct email with each team member.

Email routing rules

Partnership filter details

e. Slack module: to send the information needed to answer to the right team member

Slack notification setup

Want to build automations like this one? Well, this is the kind of project you'll learn to build in our Bootcamp. You'll identify your pain points, frame them as AI opportunities, and build practical automations with 1-on-1 support.

While our 2024 cohorts are complete, why not start 2025 right? Join our January bootcamp.

Your Turn

Ready to set up your own email filtering system? Here's a simple exercise to get started:

  1. List your common email categories (aim for 4-6)

  2. Write one classification prompt for ChatGPT

  3. Test it with 5 sample emails

  4. Start building your automation

Maybe start automating just one category first and then expand.

Want to get even more practical? Explore hands-on AI learning with AI Academy:

We'll be back with more AI tips soon!