Skip to main content
Article
google-duet-aigoogle-workspacegenerative-aiproductivitygoogle-docsgmailgoogle-sheetsgcloud

Automate Tasks in Google Workspace with Duet AI

Leverage Google Duet AI inside Workspace apps like Docs, Sheets, and Gmail to draft content, summarize information, and analyze data. This pack shows you how to use its core features to boost productivity.

beginner15 min4 steps
The play
  1. Draft a document in Google Docs
    In a new Google Doc, click the 'Help me write' button. Enter a prompt for Google Duet AI, such as 'Write a project plan for launching a new mobile app'. Review the generated draft and use the refinement tools to adjust tone or elaborate.
  2. Summarize an email thread in Gmail
    Open a long email conversation in Gmail. At the top of the thread, look for the 'Summarize this conversation' button with the Google Duet AI icon. Click it to get a bulleted summary of the key points without reading every message.
  3. Organize data in Google Sheets
    In a Google Sheet with raw data, select your data range. Click the 'Help me organize' button in the sidebar. Use natural language prompts like 'Create a pivot table showing sales by region' and let Google Duet AI generate the table and formulas for you.
  4. Generate Cloud commands with Duet AI
    In the Google Cloud console, open the Cloud Shell. You can ask Google Duet AI for gcloud commands directly. Type a comment starting with '#' and your question, for example: '# how to create a firewall rule to allow ssh'. Duet AI will suggest the command.
Starter code
#!/bin/bash
# This script uses the gcloud CLI, which integrates with Google Duet AI,
# to generate a Python script for a common cloud task.

# Prerequisites: 
# 1. Google Cloud SDK installed (https://cloud.google.com/sdk/docs/install)
# 2. Authenticate: `gcloud auth login`
# 3. Set project: `gcloud config set project YOUR_PROJECT_ID`
# 4. Enable the Cloud AI Companion API: `gcloud services enable cloudaicompanion.googleapis.com`

PROMPT="a Python script that uses google-cloud-storage to list all buckets in a project"

echo "-----------------------------------------------------"
echo "Asking Duet AI to generate a Python script..."
echo "Prompt: $PROMPT"
echo "-----------------------------------------------------"

# Use gcloud alpha code suggest to generate code from a prompt
gcloud alpha code suggest "$PROMPT" --language=python
Automate Tasks in Google Workspace with Duet AI — Action Pack