> ## Documentation Index
> Fetch the complete documentation index at: https://help.emergent.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Suite Integration

> Connect Gmail, Calendar, Drive, and more

## What is Google Suite?

Google Suite (now called Google Workspace) includes Gmail, Google Calendar, Google Drive, Sheets, Docs, and more. You can integrate these into your app.

**Perfect for:**

* Sending emails via Gmail
* Managing calendar appointments
* Storing files in Google Drive
* Reading/writing Google Sheets
* Accessing Google Docs

## What You'll Need

<Steps>
  <Step title="Google Account">
    Any Google account works
  </Step>

  <Step title="Google Cloud Console">
    Create a project (free!)
  </Step>

  <Step title="Enable APIs">
    Turn on the Google services you need
  </Step>

  <Step title="Get Credentials">
    Create OAuth credentials
  </Step>

  <Step title="20-30 Minutes">
    A few key steps involved, but we'll guide you!
  </Step>
</Steps>

<Tip>
  Here's a helpful video to get you started.
</Tip>

<iframe src="https://www.youtube.com/embed/N66rzbLZL_4" title="YouTube video player" frameborder="0" className="w-full aspect-video rounded-xl" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen />

## Step 1: Set Up Google Cloud Project

### Create Project

1. Go to [console.cloud.google.com](https://console.cloud.google.com)
2. Click **New Project** (top right)
3. Name it (like "My App")
4. Click **Create**
5. Wait for project to be created
6. Make sure you're in the new project (check top navbar)

### Enable APIs

Depending on what you need:

**For Gmail:**

1. Search for "Gmail API" in search bar
2. Click on it
3. Click **Enable**

**For Google Calendar:**

1. Search for "Google Calendar API"
2. Click **Enable**

**For Google Drive:**

1. Search for "Google Drive API"
2. Click **Enable**

**For Google Sheets:**

1. Search for "Google Sheets API"
2. Click **Enable**

<Tip>
  Only enable what you need! You can always add more later.
</Tip>

### Create OAuth Credentials

1. Go to **APIs & Services** → **Credentials**
2. Click **Create Credentials** → **OAuth client ID**
3. If prompted, **Configure Consent Screen**:
   * Choose **External**
   * App name: Your app name
   * User support email: Your email
   * Developer email: Your email
   * Click **Save and Continue**
   * Click **Save and Continue** through scopes
   * Click **Back to Dashboard**
4. Now create OAuth client:
   * Click **Create Credentials** → **OAuth client ID**
   * Application type: **Web application**
   * Name: "My App"
   * Authorized redirect URIs: `[emergent-preview-link]/auth/callback` (Ask the agent which URI value to input)
   * Click **Create**
5. **Copy these credentials:**
   * Client ID
   * Client Secret

<Warning>
  **Keep Client Secret safe!** Don't share it publicly.
</Warning>

## Step 2: Tell the Agent What You Want

Describe which Google services you need:

### Example 1: Gmail Integration

```
I want to send emails through Gmail API.

Google Cloud credentials:
- Client ID: xxxxx.apps.googleusercontent.com
- Client Secret: xxxxx

Features:
- Send emails from my Gmail account
- Read inbox (optional)
- Search emails (optional)

Please set this up with OAuth authentication.
```

### Example 2: Google Calendar

```
Integrate Google Calendar for appointment booking.

Google Cloud credentials:
- Client ID: xxxxx.apps.googleusercontent.com
- Client Secret: xxxxx

Features:
- View user's calendar
- Create appointments
- Update/cancel appointments
- Send calendar invites
- Check availability

Please build this with OAuth.
```

### Example 3: Google Drive

```
Use Google Drive for file storage.

Google Cloud credentials:
- Client ID: xxxxx.apps.googleusercontent.com
- Client Secret: xxxxx

Features:
- Upload files to user's Drive
- List their files
- Download files
- Share files
- Create folders

Please set this up.
```

### Example 4: Google Sheets as Database

```
Use Google Sheets as a simple database.

Google Cloud credentials:
- Client ID: xxxxx.apps.googleusercontent.com
- Client Secret: xxxxx

Sheet setup:
- Sheet name: "Customer Database"
- Columns: Name, Email, Phone, Status

Features:
- Read data from sheet
- Add new rows
- Update existing rows
- Display in app

Please build this.
```

<Tip>
  **OAuth Authentication:** Users will click "Sign in with Google" to authorize your app.
</Tip>

## Step 3: Test the Integration

After setup:

<Steps>
  <Step title="Click Preview">
    In Emergent, click **Preview**
  </Step>

  <Step title="Sign in with Google">
    Click the "Sign in with Google" button
  </Step>

  <Step title="Authorize">
    Google will ask for permissions

    Click **Allow**
  </Step>

  <Step title="Test Feature">
    Try the feature:

    * Send a test email
    * Create a calendar event
    * Upload a file
    * Read from sheet
  </Step>

  <Step title="Check Google">
    Verify in Gmail/Calendar/Drive that it worked!
  </Step>
</Steps>

## Common Questions

<AccordionGroup>
  <Accordion title="Do I need a paid Google Workspace account?">
    **No!** A free personal Google account works fine.

    Google Workspace (paid) only needed if:

    * You want to send from company domain ([you@company.com](mailto:you@company.com))
    * Need admin features
    * Managing organization accounts
  </Accordion>

  <Accordion title="What are the API limits?">
    **Gmail:** 1 billion quota units per day (lots!)

    **Calendar:** 1 million queries per day

    **Drive:** 1 billion queries per day

    **Sheets:** 300 read requests per minute

    More than enough for most apps!
  </Accordion>

  <Accordion title="Is it free?">
    **Yes!** All Google APIs are free to use within the generous quotas.

    No charges unless you need enterprise features.
  </Accordion>

  <Accordion title="Can users use their own Google account?">
    Yes! That's what OAuth is for. Each user:

    1. Signs in with their Google account
    2. Authorizes your app
    3. Your app accesses their data
  </Accordion>
</AccordionGroup>

## Something Not Working?

### OAuth Error

**Tell the agent:**

```
Getting OAuth error when signing in:
[paste error]

Can you check:
1. Client ID and Secret are correct
2. Redirect URI is configured
3. Scopes are properly set
```

### Permission Denied

**Tell the agent:**

```
User authorizes but still getting permission errors.

Error: [paste error]

Can you check the OAuth scopes?
```

### API Not Enabled

**Tell the agent:**

```
Getting "API not enabled" error.

Which API should I enable in Google Cloud Console?
```

## Real Examples

### Example 1: Appointment Booking System

```
Build appointment booking with Google Calendar.

Google Cloud credentials: [will provide]

Flow:
1. Show available time slots
2. User selects time
3. Create Google Calendar event
4. Send confirmation email via Gmail
5. Send calendar invite

Features:
- Check availability
- Block out busy times
- Automatic reminders
- Reschedule/cancel

Please build this.
```

### Example 2: Email Campaign Tool

```
Send email campaigns through Gmail API.

Google Cloud credentials: [will provide]

Features:
- Upload recipient list
- Compose email template
- Send to all recipients
- Track opens/clicks
- Respect rate limits

Please set this up.
```

### Example 3: Document Generator

```
Generate documents and save to Google Drive.

Google Cloud credentials: [will provide]

Flow:
1. User fills form
2. Generate PDF/document
3. Save to their Google Drive
4. Share link

Features:
- Template system
- PDF generation
- Automatic naming
- Organize in folders

Please build this.
```

## Advanced Features

### Service Account (No OAuth)

For server-to-server access:

```
Instead of OAuth, use Service Account.

Access my Google Sheet directly without user login.
Sheet ID: [provide]

Set up service account authentication.
```

<Note>
  A spreadsheet ID can be extracted from its URL. For example, the spreadsheet ID in the URL `https://docs.google.com/spreadsheets/d/abc1234567/edit#gid=0` is "abc1234567".
</Note>

### Batch Operations

```
Optimize Google Sheets integration:
- Batch read/write operations
- Reduce API calls
- Update multiple rows at once
```

### Webhooks

```
Get notified when:
- New email arrives
- Calendar event changes
- Drive file is modified

Set up Google webhooks.
```

## Going to Production

### Update Redirect URIs

1. In Google Cloud Console → **Credentials**
2. Edit your OAuth client
3. Add production redirect URI:
   * `https://yourdomain.com/auth/callback`
4. Click **Save**

### Verify Your Domain

1. In **OAuth consent screen**
2. Click **Add domain**
3. Add your domain
4. Complete verification

### Submit for Verification (If Needed)

If requesting sensitive scopes:

1. Fill out security questionnaire
2. Submit for Google review
3. Usually takes 3-5 days

## Quick Checklist

Before going live:

* All needed APIs enabled
* OAuth working in test
* Tested core features
* Added production redirect URI
* Verified domain (if needed)
* Submitted for review (if needed)
* Tested with real Google account

## Remember

**Free to use** - No API costs

**Generous limits** - More than enough for most apps

**OAuth for user data** - Secure access

**Service account for server** - No user login needed

**Setup takes time** - But worth it!

<Info>
  Stuck? Tell the agent: "I need help with Google \[Gmail/Calendar/Drive/Sheets] integration" and describe the issue.
</Info>
