Skip to content

Commit f9f8895

Browse files
committed
docs: Update README
1 parent ad1779c commit f9f8895

File tree

1 file changed

+94
-24
lines changed

1 file changed

+94
-24
lines changed

gmail-sentiment-analysis/README.md

Lines changed: 94 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,103 @@
1-
# Gmail sentiment analysis with Vertex AI
1+
# Gmail Sentiment Analysis with Gemini and Vertex AI
22

3-
## Project Description
3+
This project guides you through building a Google Workspace Add-on that
4+
leverages Gemini and Vertex AI for conducting sentiment analysis on emails in
5+
Gmail. The add-on automatically identifies emails with a negative tone and
6+
labels them accordingly, helping prioritize customer service responses or
7+
identify potentially sensitive emails.
48

5-
Google Workspace Add-on that extends Gmail and adds sentiment analysis capabilities.
9+
## What you'll learn
610

7-
## Prerequisites
11+
* Build a Google Workspace Add-on
12+
* Integrate Vertex AI with Google Workspace
13+
* Implement OAuth2 authentication
14+
* Apply sentiment analysis
15+
* Utilize Apps Script
816

9-
* Google Cloud Project (aka Standard Cloud Project for Apps Script) with billing enabled
17+
## Setup and Requirements
1018

11-
## Set up your environment
19+
* **Web Browser:** Chrome (recommended)
20+
* **Dedicated Time:** Set aside uninterrupted time.
21+
* **Incognito/Private Window:** **Important:** Use an incognito or private browsing window to prevent conflicts with your personal accounts.
1222

13-
1. Create a Cloud Project
14-
1. Enable the Vertex AI API
15-
1. Create a Service Account and grant the role `Vertex AI User`
16-
1. Create a private key with type JSON. This will download the JSON file for use in the next section.
17-
1. Open an Apps Script Project bound to a Google Sheets Spreadsheet
18-
1. From Project Settings, change project to GCP project number of Cloud Project from step 1
19-
1. Add a Script Property. Enter `service_account_key` as the property name and paste the JSON key from the service account as the value.
20-
1. Add OAuth2 v43 Apps Script Library using the ID `1B7FSrk5Zi6L1rSxxTDgDEUsPzlukDsi4KGuTMorsTQHhGBzBkMun4iDF`.
21-
1. Add the project code to Apps Script
23+
## Lab Steps
2224

23-
Alternatively, make a copy of this [Apps Script project](https://script.google.com/corp/home/projects/1Z2gfvr0oYn68ppDtQbv0qIuKKVWhvwOTr-gCE0GFKVjNk8NDlpfJAGAr)
25+
### Task 1: Accessing Your Lab Environment
2426

25-
## Usage
27+
1. Click **Start lab** (in your [Qwiklabs environment](https://explore.qwiklabs.com/classrooms/16701)). This generates temporary credentials.
28+
2. Open the provided **Gmail URL** in your incognito window.
29+
3. Enter the provided **Username** and **Password**.
30+
4. Accept terms and conditions.
31+
5. Click **Get started** in Gmail and close any informational windows.
2632

27-
1. Create a label in Gmail with this exact text and emojy (case sensitive!): UPSET TONE 😡
28-
1. In Gmail, click on the Productivity toolbox icon (icon of a spy) in the sidepanel.
29-
1. The sidepanel will open up. Grant the Add-on autorization to run.
30-
1. The Add-on will load. Click on the blue button "Identify angry customers."
31-
1. Close the Add-on by clicking on the X in the top right corner.
32-
1. It can take a couple of minutes until the label is applied to the messages that have a negative tone.
33-
1. If you don't want to wait until the labels are added, you can refresh the browser.
33+
### Task 2: Set up Cloud Console
34+
35+
1. Open the provided **Cloud Console URL** in your incognito window.
36+
2. Check **I agree** and click **AGREE AND CONTINUE**.
37+
38+
### Enable Vertex AI API
39+
40+
1. Open the provided link to enable the Vertex AI API.
41+
2. Click **Next** to confirm the project.
42+
3. Click **Enable**.
43+
44+
45+
### Task 3: Set Up the Apps Script Project
46+
47+
1. Open the provided **Apps Script link** in a new incognito tab.
48+
2. Click **New project**.
49+
3. Rename the project to "Gmail Sentiment Analysis with Gemini and Vertex AI".
50+
4. In Project Settings (gear icon), select "Show 'appsscript.json' manifest file in editor".
51+
5. In Project Settings, under Google Cloud Platform (GCP) Project, click **Change project**.
52+
6. Copy the **Project number** (numerical value, not Project ID) from Cloud Console.
53+
7. Paste the Project number into the Apps Script project settings and click **Set project**.
54+
8. Click the **OAuth Consent details** link in the error message.
55+
9. Click **CONFIGURE CONSENT SCREEN**.
56+
10. Select **Internal** for User Type and click **CREATE**.
57+
11. Set the App name to "Gmail Sentiment Analysis with Gemini and Vertex AI".
58+
12. Set the User support email and Developer contact information using the provided email.
59+
13. Click **SAVE AND CONTINUE** twice.
60+
14. Return to the Apps Script tab and set the project.
61+
62+
63+
### Task 4: Make a copy of the Apps Script project
64+
65+
1. Make a copy of this
66+
[Apps Script project](https://script.google.com/corp/home/projects/1Z2gfvr0oYn68ppDtQbv0qIuKKVWhvwOTr-gCE0GFKVjNk8NDlpfJAGAr).
67+
1. Rename the Apps Script project to `Gmail Sentiment Analysis with Gemini and Vertex AI`.
68+
1. Make sure to replace `[ADD YOUR GCP PROJECT ID HERE]` in `Vertex.gs` with your actual **Project ID**.
69+
1. Click **Save**.
70+
71+
72+
### Task 5: Deploy the Add-on
73+
74+
1. Click **Deploy > Test deployments**.
75+
2. Confirm **Gmail** is listed under Application(s) and click **Install**.
76+
3. Click **Done**.
77+
78+
### Task 6: Verify Installation
79+
80+
Refresh the Gmail tab. You should see a new add-on icon in the right side panel.
81+
82+
**Troubleshooting:**
83+
84+
* Refresh the browser if the add-on isn't visible.
85+
* Uninstall and reinstall the add-on from the Test deployments window if it's still missing.
86+
87+
88+
### Task 7: Run the Add-on
89+
90+
1. **Open the Add-on:** Click the add-on icon in the Gmail side panel.
91+
2. **Authorize the Add-on:** Click **Authorize access**. Select your email and click **Allow** in the consent screen.
92+
3. **Generate sample emails:** Click the green "Generate sample emails" button.
93+
4. **Wait for emails:** Wait for the sample emails to appear in your inbox, or refresh.
94+
5. **Start the analysis:** Click the red "Analyze emails" button.
95+
6. **Wait for labels:** Wait for the "UPSET TONE 😡" label to appear on negative emails, or refresh.
96+
7. **Close the Add-on:** Click the X in the top right corner of the side panel.
97+
98+
99+
## Congratulations!
100+
101+
You've completed the Gmail Sentiment Analysis with Gemini and Vertex AI lab!
102+
You now have a functional Gmail add-on for prioritizing emails. Experiment
103+
further by customizing the sentiment analysis or adding new features!

0 commit comments

Comments
 (0)