diff --git a/gmail-sentiment-analysis/Cards.gs b/gmail-sentiment-analysis/Cards.gs index dde0a71fc..5b1e16759 100644 --- a/gmail-sentiment-analysis/Cards.gs +++ b/gmail-sentiment-analysis/Cards.gs @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ - /** * Builds the card to display in the side panel of gmail. * @return {CardService.Card} The card to show to the user. @@ -28,14 +27,16 @@ function buildHomepageCard() { .setImageStyle(CardService.ImageStyle.CIRCLE) .setTitle("Analyze your Gmail"); - const analyzeSentimentAction = CardService.newAction().setFunctionName('analyzeSentiment'); + const analyzeSentimentAction = CardService.newAction() + .setFunctionName('analyzeSentiment'); const analyzeSentimentBtn = CardService.newTextButton() .setText('Analyze emails') .setOnClickAction(analyzeSentimentAction) .setTextButtonStyle(CardService.TextButtonStyle.FILLED) .setBackgroundColor('#FF0000'); - const generateSampleEmailAction = CardService.newAction().setFunctionName('generateSampleEmails'); + const generateSampleEmailAction = CardService.newAction() + .setFunctionName('generateSampleEmails'); const generateSampleEmailsBtn = CardService.newTextButton() .setText('Generate sample emails') @@ -43,7 +44,9 @@ function buildHomepageCard() { .setTextButtonStyle(CardService.TextButtonStyle.FILLED) .setBackgroundColor('#34A853'); - const buttonSet = CardService.newButtonSet().addButton(generateSampleEmailsBtn).addButton(analyzeSentimentBtn); + const buttonSet = CardService.newButtonSet() + .addButton(generateSampleEmailsBtn) + .addButton(analyzeSentimentBtn); const section = CardService.newCardSection() .addWidget(buttonSet); @@ -62,4 +65,4 @@ function buildNotificationResponse(notificationText) { .setNotification(notification); return actionResponse.build(); -} \ No newline at end of file +} diff --git a/gmail-sentiment-analysis/Code.gs b/gmail-sentiment-analysis/Code.gs index fd0b8816d..72372a106 100644 --- a/gmail-sentiment-analysis/Code.gs +++ b/gmail-sentiment-analysis/Code.gs @@ -20,4 +20,4 @@ limitations under the License. */ function onHomepageTrigger(e) { return buildHomepageCard(); -} \ No newline at end of file +} diff --git a/gmail-sentiment-analysis/Gmail.gs b/gmail-sentiment-analysis/Gmail.gs index 0a27a483e..0b67a7fb9 100644 --- a/gmail-sentiment-analysis/Gmail.gs +++ b/gmail-sentiment-analysis/Gmail.gs @@ -102,4 +102,4 @@ function generateSampleEmails() { ); return buildNotificationResponse("Successfully generated sample emails"); -} \ No newline at end of file +} diff --git a/gmail-sentiment-analysis/README.md b/gmail-sentiment-analysis/README.md index fe916d4ba..72169a2d5 100644 --- a/gmail-sentiment-analysis/README.md +++ b/gmail-sentiment-analysis/README.md @@ -20,17 +20,10 @@ identify potentially sensitive emails. * **Dedicated Time:** Set aside uninterrupted time. * **Incognito/Private Window:** **Important:** Use an incognito or private browsing window to prevent conflicts with your personal accounts. -## Lab Steps +## Steps -### Task 1: Accessing Your Lab Environment -1. Click **Start lab** (in your [Qwiklabs environment](https://explore.qwiklabs.com/classrooms/16701)). This generates temporary credentials. -2. Open the provided **Gmail URL** in your incognito window. -3. Enter the provided **Username** and **Password**. -4. Accept terms and conditions. -5. Click **Get started** in Gmail and close any informational windows. - -### Task 2: Set up Cloud Console +### Set up Cloud Console 1. Open the provided **Cloud Console URL** in your incognito window. 2. Check **I agree** and click **AGREE AND CONTINUE**. @@ -42,7 +35,7 @@ identify potentially sensitive emails. 3. Click **Enable**. -### Task 3: Set Up the Apps Script Project +### Set Up the Apps Script Project 1. Open the provided **Apps Script link** in a new incognito tab. 2. Click **New project**. @@ -60,7 +53,7 @@ identify potentially sensitive emails. 14. Return to the Apps Script tab and set the project. -### Task 4: Make a copy of the Apps Script project +### Make a copy of the Apps Script project 1. Make a copy of this [Apps Script project](https://script.google.com/corp/home/projects/1Z2gfvr0oYn68ppDtQbv0qIuKKVWhvwOTr-gCE0GFKVjNk8NDlpfJAGAr). @@ -69,13 +62,13 @@ identify potentially sensitive emails. 1. Click **Save**. -### Task 5: Deploy the Add-on +### Deploy the Add-on 1. Click **Deploy > Test deployments**. 2. Confirm **Gmail** is listed under Application(s) and click **Install**. 3. Click **Done**. -### Task 6: Verify Installation +### Verify Installation Refresh the Gmail tab. You should see a new add-on icon in the right side panel. @@ -85,7 +78,7 @@ Refresh the Gmail tab. You should see a new add-on icon in the right side panel. * Uninstall and reinstall the add-on from the Test deployments window if it's still missing. -### Task 7: Run the Add-on +### Run the Add-on 1. **Open the Add-on:** Click the add-on icon in the Gmail side panel. 2. **Authorize the Add-on:** Click **Authorize access**. Select your email and click **Allow** in the consent screen. diff --git a/gmail-sentiment-analysis/Vertex.gs b/gmail-sentiment-analysis/Vertex.gs index 221907a81..bbcec8c43 100644 --- a/gmail-sentiment-analysis/Vertex.gs +++ b/gmail-sentiment-analysis/Vertex.gs @@ -67,12 +67,16 @@ function processSentiment(emailText) { payload: JSON.stringify(request), } - const url = `https://${VERTEX_AI_LOCATION}-aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/` - + `locations/${VERTEX_AI_LOCATION}/publishers/google/models/${MODEL_ID}:generateContent` + const url = + `https://${VERTEX_AI_LOCATION}-aiplatform.googleapis.com/v1/` + + `projects/${PROJECT_ID}/` + + `locations/${VERTEX_AI_LOCATION}/` + + `publishers/google/` + + `models/${MODEL_ID}:generateContent`; const response = UrlFetchApp.fetch(url, fetchOptions); const payload = JSON.parse(response.getContentText()); const text = JSON.parse(payload.candidates[0].content.parts[0].text); return text.response; -} \ No newline at end of file +} diff --git a/gmail-sentiment-analysis/appsscript.json b/gmail-sentiment-analysis/appsscript.json index 6018fe6ae..b6e23d4f2 100644 --- a/gmail-sentiment-analysis/appsscript.json +++ b/gmail-sentiment-analysis/appsscript.json @@ -1,13 +1,13 @@ { "timeZone": "America/Toronto", "oauthScopes": [ - "https://www.googleapis.com/auth/script.external_request", "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/script.locale", - "https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/gmail.addons.execute", "https://www.googleapis.com/auth/gmail.labels", - "https://www.googleapis.com/auth/gmail.modify" + "https://www.googleapis.com/auth/gmail.modify", + "https://www.googleapis.com/auth/script.external_request", + "https://www.googleapis.com/auth/script.locale", + "https://www.googleapis.com/auth/userinfo.email" ], "addOns": { "common": { @@ -24,4 +24,4 @@ }, "exceptionLogging": "STACKDRIVER", "runtimeVersion": "V8" -} \ No newline at end of file +}