Other

Oct 31, 2025

How to Build an Email Summariser and Sentiment Analyser using Gmail API

Written By :

Arya Chandra

How to Build an E-Mail Summarizer and Sentiment Analyser using Gmail API

In this tutorial, we’ll walk through how to build an AI-powered Email Summarizer using the Gmail API on Emergent - no deep technical background required. By the end, you’ll have a simple web app that can read your unread emails, summarize them in plain language, and even analyze their tone.

Before we start, let’s understand what this means in simple terms.

The Gmail API is like a bridge that lets your app talk to your Gmail account securely (with your permission). Instead of you logging in and manually checking emails, your app can automatically fetch them, read the text, and perform smart actions - all while keeping your data safe.

We’ll also use AI to make sense of your inbox. The app will summarize long emails into short, clear bullet points so you can see what’s important at a glance. It’ll assign priority scores (so you instantly know which emails need attention) and use a simple technique called sentiment analysis (using a python library called VADER) to tell whether an email’s tone feels positive, neutral, or negative.

Emergent makes all this easy because you don’t have to write or debug complex code yourself. You’ll just describe what you want your app to do - like “fetch unread emails and summarize them” - and Emergent will generate the backend logic, integrations, and even the user interface automatically.

By the end of this tutorial, you’ll have:

  • A working Gmail integration.

  • AI summaries for each unread email.

  • A priority scoring system to sort important messages.

  • Sentiment analysis labels that reveal tone at a glance.

Let’s start by setting up the foundation of our app: connecting it with Gmail through the Gmail API.

Here’s how the final app looks like: 


Building on Emergent

Once you’re on Emergent, creating your app begins with a single detailed prompt. This is where you describe exactly what you want the app to do - Emergent’s AI then builds it for you automatically.

Here’s the exact prompt we used to create the Gmail AI Summarizer app:

Prompt Used:

Build an app using the Gmail API that connects to a user's Gmail account, fetches their unread emails, and generates an intelligent summary dashboard.

Core Features

  1. Gmail Integration

  • Authenticate the user with Google OAuth.

  • Fetch unread emails, including sender, subject, short body/snippet, and timestamp.

  1. AI Summarization

  • Use an AI model (like OpenAI or Gemini) to summarize each unread email into 2-3 concise bullet points.

  • Generate an overall “Daily Inbox Summary” that combines insights from all unread emails.

  1. Priority Scoring System

  • Assign a priority score (1-100) to each email using the following logic:

    • Frequent senders or known contacts → higher score.

    • Keywords such as “urgent,” “ASAP,” “important,” “invoice,” or “payment” → higher score.

    • Promotional or automated senders → lower score.

  • Display color-coded priority indicators: High, Medium, Low.

  1. Sentiment Analysis

  • Perform sentiment analysis on each email’s snippet or summary using VADER.

  • Categorize each as Positive, Neutral, or Negative.

  • Display the sentiment result beside each summarized email.

  1. Dashboard Display

  • Show:

    • Total unread emails

    • Combined AI-generated summary

    • Individual email summaries with sender, subject, priority score, and sentiment tag

  • Include simple filters such as: “High Priority,” “Positive,” and “Negative.”

  1. Data Flow

  • Step 1: Authenticate and fetch unread emails.

  • Step 2: Apply AI summarization, sentiment analysis, and scoring.

  • Step 3: Display processed data on a clean, minimal dashboard.

Ensure secure handling of Gmail and AI API credentials. Optimize for fast loading and intuitive visualization.

Explaining the Prompt (in Simple Terms)

Let’s break down what this prompt actually means.

  • Gmail Integration:
    This part tells Emergent to connect your app to Gmail securely using Google OAuth. It ensures users give permission before their emails are accessed.

  • AI Summarization:
    Here, Emergent uses an AI model (like GPT or Gemini) to read each unread email and summarize it into 2-3 quick bullet points. This helps you scan through long messages easily.

  • Priority Scoring System:
    The app automatically scores emails from 1-100 based on how important they might be. It looks for signs of urgency (“ASAP,” “invoice,” “meeting”), known senders, or promotional words to decide which emails matter most.

  • Sentiment Analysis (VADER):
    VADER (Valence Aware Dictionary and sEntiment Reasoner) is a simple NLP tool that measures whether text sounds positive, neutral, or negative. For example, “Thanks for your help!” would be positive, while “I’m disappointed by the delay” would be negative.
    This helps you quickly grasp the tone of each message without reading it all.

  • Dashboard Display:
    Finally, everything comes together on a single web dashboard. You’ll see your unread emails, summaries, priority scores, and sentiment results - all in one view. You can even filter emails by sentiment or importance.


Agent’s Questions and Answers

After entering the prompt, Emergent’s AI agent asks a few clarifying questions to finalize the build setup. Please Note: The questions will be different for every user.
Here’s what it asked - and the answers we provided:

Agent asked:

  1. AI Model for Summarization - Which provider should I use?
    a. OpenAI GPT-5 (latest model)
    b. Claude Sonnet 4
    c. Gemini 2.5 Pro

  2. API Keys - How should I handle credentials?
    a. You'll provide your own Gmail API and AI API keys
    b. Use Emergent LLM key for AI
    c. Combination of your Gmail API key + Emergent LLM key for AI

  3. User Authentication - How should users sign in?
    a. Google OAuth (via Gmail API)
    b. Simple username/password + Gmail OAuth
    c. Google OAuth only (no user system)

  4. UI/UX Style - Any preference?
    a. Clean minimal dashboard with light colors
    b. Modern professional with rich colors
    c. Your choice - make it look great!

Our Answers:

  1. a. OpenAI GPT-5

  2. c. I’ll provide my Gmail API Key + Emergent LLM Key for AI

  3. a. Google OAuth

  4. c. Your choice - make it look great!

With these inputs, Emergent automatically starts generating your app - wiring up the Gmail API, authentication flow, backend logic, and the clean web dashboard where your summarized inbox will appear.

Providing Gmail API Credentials

After the initial build, the agent prompted for the Gmail API credentials to test the full authentication flow. Here’s exactly what it asked:

“The app is ready for further testing. To proceed with a comprehensive evaluation of the full flow, could you please provide your Gmail API credentials:

Gmail API Client ID
Gmail API Client Secret

You can obtain these credentials from the Google Cloud Console by following these steps:

  1. Visit https://console.cloud.google.com/

  2. Create a new project or select an existing one

  3. Enable the Gmail API

  4. Create OAuth 2.0 credentials

  5. Add the authorized redirect URI (This is my redirect URL - your URL will be different and will be provided by the agent):
    https://email-summarizer-1.preview.emergentagent.com/gmail-callback

Once you share these details, I can conduct a thorough test of the authentication and email fetching processes.”

Once you paste your Client ID and Client Secret, Emergent finalizes the Gmail integration - enabling your app to securely fetch and summarize your unread emails in real time.

Setting up your Gmail API

Step-by-step: Create credentials in Google Cloud Console 

Follow these simple steps to get the Client ID and Client Secret that your app will use to access Gmail. I’ll explain what each step does in plain language.

1) Open Google Cloud Console

  1. Go to https://console.cloud.google.com and sign in with the Google account you want to use for development. This is the same place Google developers manage APIs and credentials.

2) Create a new project (or pick an existing one)

  1. Click the project selector at the top and choose New Project.

  2. Give it a friendly name like Email-Summarizer and click Create. A project is just a workspace that keeps settings, APIs, and credentials organized.

3) Enable the Gmail API

  1. In the left menu, go to APIs & Services → Library.

  2. Search for Gmail API, open it, and click Enable. Enabling the API lets apps in your project talk to Gmail (with the user’s permission).

4) Configure the Credentials

  1. You will see an option to configure the credentials on the top of the screen under ‘Enabled APIs and Services’. Click on Create Credentials

  2. Next you have to configure the Credential Type. The GMail API will be auto selected you just need to allow user data under “What data will you be accessing?” Click on Next.

  3. After this you will have to fill in the OAuth Consent Screen App Information where you will have to fill in App Name (Email Summarizer), User Support Email (Your Email)  and Developer Contact Information (Your Email). Once done click on Save and Continue.

  4. The next section will be about Scopes. No changes required here. Leave it as it is. Click Save and Continue.

  5. The Next Section (OAuth Client ID) will ask for what type of application it is - select Web Application. Once you select that you will see an option to add a redirect URL. Ask the agent for the redirect URL if it has not provided it already. Paste the URL in the redirect URL section. 

  6. Once done you can download your credentials in JSON Format. You will find your Client ID and Client Secret in it. You can now provide the Client ID and Client Secret to the agent.

Here's how to do it:


Your App Is Now Ready to Use

Once you’ve added your Gmail Client ID and Client Secret, Emergent finalizes the build and connects everything together - the Gmail API, AI summarization logic, priority scoring, and sentiment analysis. The app is now live and ready for you to test.

When you open the preview link, you’ll see a clean, minimal dashboard that automatically fetches your unread Gmail messages (after you log in securely through Google). Within a few seconds, the AI begins analyzing and organizing your inbox.

Here’s what happens behind the scenes:

  1. Authenticate with Google:
    The app first asks for permission to access your Gmail account using OAuth. This ensures your data stays private and secure.

  2. Fetch Unread Emails:
    Once connected, it retrieves all your unread emails - including the sender, subject, short body, and timestamp.

  3. AI Summarization:
    The app sends each email’s text to the AI model (GPT-5) and receives back concise 2–3 line summaries.

  4. Priority Scoring:
    Each email is assigned a score between 1 and 100 based on its urgency, importance, and sender pattern. For instance, an “invoice” from a known client gets a high score, while a promotional mailer gets a low one.

  5. Sentiment Analysis (VADER):
    The app runs a quick tone check on each email summary - tagging it as Positive, Neutral, or Negative. This helps you understand at a glance whether a message carries good news, feedback, or a problem that might need attention.

  6. Dashboard Display:
    Finally, all this information is displayed in an intuitive dashboard. You’ll see:

    • Your total unread emails

    • Individual email summaries with priority tags and sentiment icons

    • Quick filters to view only High Priority, Positive, or Negative emails

It’s like having an intelligent assistant that reviews your inbox every morning and tells you what really matters - all in one clean, interactive dashboard.

Generate beautiful designs in seconds and export to HTML or Figma. Powerful prompt builder with hundreds of templates for responsive web design.

Copyright

Emergentlabs 2024

Design and built by

the awesome people of Emergent 🩵

Generate beautiful designs in seconds and export to HTML or Figma. Powerful prompt builder with hundreds of templates for responsive web design.

Copyright

Emergentlabs 2024

Design and built by

the awesome people of Emergent 🩵

Generate beautiful designs in seconds and export to HTML or Figma. Powerful prompt builder with hundreds of templates for responsive web design.

Copyright

Emergentlabs 2024

Design and built by

the awesome people of Emergent 🩵