Skip to content

Commit a1c5100

Browse files
authored
chore: Minor updates (#519)
1 parent e6ca6da commit a1c5100

File tree

6 files changed

+29
-29
lines changed

6 files changed

+29
-29
lines changed

gmail-sentiment-analysis/Cards.gs

+8-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
1817
/**
1918
* Builds the card to display in the side panel of gmail.
2019
* @return {CardService.Card} The card to show to the user.
@@ -28,22 +27,26 @@ function buildHomepageCard() {
2827
.setImageStyle(CardService.ImageStyle.CIRCLE)
2928
.setTitle("Analyze your Gmail");
3029

31-
const analyzeSentimentAction = CardService.newAction().setFunctionName('analyzeSentiment');
30+
const analyzeSentimentAction = CardService.newAction()
31+
.setFunctionName('analyzeSentiment');
3232
const analyzeSentimentBtn = CardService.newTextButton()
3333
.setText('Analyze emails')
3434
.setOnClickAction(analyzeSentimentAction)
3535
.setTextButtonStyle(CardService.TextButtonStyle.FILLED)
3636
.setBackgroundColor('#FF0000');
3737

38-
const generateSampleEmailAction = CardService.newAction().setFunctionName('generateSampleEmails');
38+
const generateSampleEmailAction = CardService.newAction()
39+
.setFunctionName('generateSampleEmails');
3940

4041
const generateSampleEmailsBtn = CardService.newTextButton()
4142
.setText('Generate sample emails')
4243
.setOnClickAction(generateSampleEmailAction)
4344
.setTextButtonStyle(CardService.TextButtonStyle.FILLED)
4445
.setBackgroundColor('#34A853');
4546

46-
const buttonSet = CardService.newButtonSet().addButton(generateSampleEmailsBtn).addButton(analyzeSentimentBtn);
47+
const buttonSet = CardService.newButtonSet()
48+
.addButton(generateSampleEmailsBtn)
49+
.addButton(analyzeSentimentBtn);
4750

4851
const section = CardService.newCardSection()
4952
.addWidget(buttonSet);
@@ -62,4 +65,4 @@ function buildNotificationResponse(notificationText) {
6265
.setNotification(notification);
6366

6467
return actionResponse.build();
65-
}
68+
}

gmail-sentiment-analysis/Code.gs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ limitations under the License.
2020
*/
2121
function onHomepageTrigger(e) {
2222
return buildHomepageCard();
23-
}
23+
}

gmail-sentiment-analysis/Gmail.gs

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,4 @@ function generateSampleEmails() {
102102
);
103103

104104
return buildNotificationResponse("Successfully generated sample emails");
105-
}
105+
}

gmail-sentiment-analysis/README.md

+7-14
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,10 @@ identify potentially sensitive emails.
2020
* **Dedicated Time:** Set aside uninterrupted time.
2121
* **Incognito/Private Window:** **Important:** Use an incognito or private browsing window to prevent conflicts with your personal accounts.
2222

23-
## Lab Steps
23+
## Steps
2424

25-
### Task 1: Accessing Your Lab Environment
2625

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.
32-
33-
### Task 2: Set up Cloud Console
26+
### Set up Cloud Console
3427

3528
1. Open the provided **Cloud Console URL** in your incognito window.
3629
2. Check **I agree** and click **AGREE AND CONTINUE**.
@@ -42,7 +35,7 @@ identify potentially sensitive emails.
4235
3. Click **Enable**.
4336

4437

45-
### Task 3: Set Up the Apps Script Project
38+
### Set Up the Apps Script Project
4639

4740
1. Open the provided **Apps Script link** in a new incognito tab.
4841
2. Click **New project**.
@@ -60,7 +53,7 @@ identify potentially sensitive emails.
6053
14. Return to the Apps Script tab and set the project.
6154

6255

63-
### Task 4: Make a copy of the Apps Script project
56+
### Make a copy of the Apps Script project
6457

6558
1. Make a copy of this
6659
[Apps Script project](https://script.google.com/corp/home/projects/1Z2gfvr0oYn68ppDtQbv0qIuKKVWhvwOTr-gCE0GFKVjNk8NDlpfJAGAr).
@@ -69,13 +62,13 @@ identify potentially sensitive emails.
6962
1. Click **Save**.
7063

7164

72-
### Task 5: Deploy the Add-on
65+
### Deploy the Add-on
7366

7467
1. Click **Deploy > Test deployments**.
7568
2. Confirm **Gmail** is listed under Application(s) and click **Install**.
7669
3. Click **Done**.
7770

78-
### Task 6: Verify Installation
71+
### Verify Installation
7972

8073
Refresh the Gmail tab. You should see a new add-on icon in the right side panel.
8174

@@ -85,7 +78,7 @@ Refresh the Gmail tab. You should see a new add-on icon in the right side panel.
8578
* Uninstall and reinstall the add-on from the Test deployments window if it's still missing.
8679

8780

88-
### Task 7: Run the Add-on
81+
### Run the Add-on
8982

9083
1. **Open the Add-on:** Click the add-on icon in the Gmail side panel.
9184
2. **Authorize the Add-on:** Click **Authorize access**. Select your email and click **Allow** in the consent screen.

gmail-sentiment-analysis/Vertex.gs

+7-3
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,16 @@ function processSentiment(emailText) {
6767
payload: JSON.stringify(request),
6868
}
6969

70-
const url = `https://${VERTEX_AI_LOCATION}-aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/`
71-
+ `locations/${VERTEX_AI_LOCATION}/publishers/google/models/${MODEL_ID}:generateContent`
70+
const url =
71+
`https://${VERTEX_AI_LOCATION}-aiplatform.googleapis.com/v1/` +
72+
`projects/${PROJECT_ID}/` +
73+
`locations/${VERTEX_AI_LOCATION}/` +
74+
`publishers/google/` +
75+
`models/${MODEL_ID}:generateContent`;
7276

7377
const response = UrlFetchApp.fetch(url, fetchOptions);
7478
const payload = JSON.parse(response.getContentText());
7579
const text = JSON.parse(payload.candidates[0].content.parts[0].text);
7680

7781
return text.response;
78-
}
82+
}

gmail-sentiment-analysis/appsscript.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"timeZone": "America/Toronto",
33
"oauthScopes": [
4-
"https://www.googleapis.com/auth/script.external_request",
54
"https://www.googleapis.com/auth/cloud-platform",
6-
"https://www.googleapis.com/auth/script.locale",
7-
"https://www.googleapis.com/auth/userinfo.email",
85
"https://www.googleapis.com/auth/gmail.addons.execute",
96
"https://www.googleapis.com/auth/gmail.labels",
10-
"https://www.googleapis.com/auth/gmail.modify"
7+
"https://www.googleapis.com/auth/gmail.modify",
8+
"https://www.googleapis.com/auth/script.external_request",
9+
"https://www.googleapis.com/auth/script.locale",
10+
"https://www.googleapis.com/auth/userinfo.email"
1111
],
1212
"addOns": {
1313
"common": {
@@ -24,4 +24,4 @@
2424
},
2525
"exceptionLogging": "STACKDRIVER",
2626
"runtimeVersion": "V8"
27-
}
27+
}

0 commit comments

Comments
 (0)