Sign In

/How to classify incoming emails using AI

Used Tools:

Gmail | OpenAI | Make | Airtable

Managing a cluttered inbox can be overwhelming, so I set up an AI-powered system to automatically tag and sort my emails by topic and urgency. Using Gmail, OpenAI, Make, and Airtable, I created a workflow that analyzes incoming emails and organizes them accordingly. The setup took about an hour and required intermediate technical skills. Now, my inbox is more organized, and I can focus on the emails that matter most.
How to classify incoming emails using AI

Managing a flood of incoming emails can be overwhelming, especially when trying to prioritize and organize them effectively. By leveraging AI, you can automate the classification of your emails based on topics or urgency, streamlining your workflow and ensuring that important messages are promptly addressed. In this guide, I’ll walk you through setting up an automated system using Gmail, OpenAI, Make (formerly Integromat), and Airtable. This setup will automatically tag and sort your emails, helping you maintain an organized inbox.

**Introduction**

Email overload is a common challenge, but with the right tools, you can automate the process of sorting and tagging your emails. By integrating Gmail with AI capabilities from OpenAI, and using Make to orchestrate the workflow, you can classify incoming emails by topic or urgency. Storing the results in Airtable allows for easy management and retrieval. This setup is achievable in about an hour and requires an intermediate skill level.

**Step-by-Step Guide**

**1. Set Up a New Scenario in Make**

First, create a new scenario in Make to handle the automation process.

– **Create a New Scenario**: Log in to your Make account and click on “Create a new scenario.”

– **Add Gmail Module**: Search for the Gmail app and select the “Watch Emails” module.

– **Configure the Module**:
– **Connection**: Connect your Gmail account.
– **Folder**: Select the folder you want to monitor, typically “[Gmail]/All Mail” to capture all emails.
– **Criteria**: Set to “Unread” to process only new emails.
– **Mark as Read**: Decide whether to mark emails as read after processing.
– **Max Results**: Set the maximum number of emails to process per run (e.g., 10).

**2. Process Email Content with OpenAI**

Next, use OpenAI’s GPT-4 to analyze the email content and determine its category.

– **Add OpenAI Module**: After the Gmail module, add the “OpenAI – Create Chat Completion” module.

– **Configure the Module**:
– **Connection**: Connect your OpenAI account.
– **Model**: Select “gpt-4” for advanced processing.
– **Temperature**: Set to 0.7 for balanced creativity and determinism.
– **Messages**: Input the following prompt:

“Classify the following email into one of the categories: ‘Sales’, ‘Urgent’, ‘Newsletter’, ‘Client’, ‘Other’. Email content: {{1.text}}”

Replace `{{1.text}}` with the email body from the Gmail module.

**3. Route Emails Based on Classification**

Use a Router to direct emails to different paths based on their classification.

– **Add Router Module**: Insert a Router after the OpenAI module to create multiple routes.

– **Set Up Filters for Each Category**:
– **Sales Route**:
– **Filter**: Set the condition to `{{2.choices[0].message.content}}` equals “Sales”.
– **Action**: Proceed to the next step for labeling.
– **Urgent Route**:
– **Filter**: Set the condition to `{{2.choices[0].message.content}}` equals “Urgent”.
– **Action**: Proceed to the next step for labeling.
– **Newsletter Route**:
– **Filter**: Set the condition to `{{2.choices[0].message.content}}` equals “Newsletter”.
– **Action**: Proceed to the next step for labeling.
– **Client Route**:
– **Filter**: Set the condition to `{{2.choices[0].message.content}}` equals “Client”.
– **Action**: Proceed to the next step for labeling.
– **Other Route**:
– **Filter**: Set the condition to `{{2.choices[0].message.content}}` equals “Other”.
– **Action**: Proceed to the next step for labeling.

**4. Apply Labels in Gmail**

For each route, apply the corresponding label in Gmail.

– **Add Gmail Module**: In each route, add the “Gmail – Modify Labels” module.

– **Configure the Module**:
– **Connection**: Use your Gmail connection.
– **Message ID**: Map to `{{1.id}}` from the Gmail module.
– **Labels to Add**: Select or create the appropriate label (e.g., “Sales”, “Urgent”).

**5. Log Email Data in Airtable**

Store the classified email data in Airtable for easy management.

– **Add Airtable Module**: After labeling, add the “Airtable – Create a Record” module.

– **Configure the Module**:
– **Connection**: Connect your Airtable account.
– **Base**: Select the base where you want to store the data.
– **Table**: Choose the table (e.g., “Email Classification”).
– **Fields**:
– **Email Subject**: Map to `{{1.subject}}` from the Gmail module.
– **Email Body**: Map to `{{1.text}}` from the Gmail module.
– **Classification**: Map to `{{2.choices[0].message.content}}` from the OpenAI module.
– **Received Date**: Map to `{{1.date}}` from the Gmail module.

**6. Test and Activate the Scenario**

Before going live, test the scenario to ensure everything works as expected.

– **Run the Scenario**: Click “Run once” to test the setup.

– **Check Results**: Verify that emails are correctly classified, labeled in Gmail, and logged in Airtable.

– **Activate**: Once satisfied, activate the scenario to run automatically.

**Optional Enhancements**

– **Priority Handling**: Add a step to flag emails marked as “Urgent” for immediate attention.

– **Notification System**: Set up notifications (e.g., Slack messages) for specific categories like “Sales” or “Client” to keep your team informed.

– **Advanced Categorization**: Refine the OpenAI prompt to include more nuanced categories based on your specific needs.

By following these steps, you can create an efficient system that automatically classifies and organizes your incoming emails, allowing you to focus on what matters most.

Get to know the latest in AI

Join 2300+ other AI enthusiasts, developers and founders.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Related AI Automations

How to automate internal knowledge base with AI

How to automate internal knowledge base with AI

How to automate customer onboarding with AI workflows

How to automate customer onboarding with AI workflows

How to automate invoicing with AI and Make

How to automate invoicing with AI and Make

How to summarize Slack messages into weekly digests

How to summarize Slack messages into weekly digests

How to automate resume screening with ChatGPT and Make

How to automate resume screening with ChatGPT and Make

How to extract action items from meeting notes using AI

How to extract action items from meeting notes using AI

Related AI Tools