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

# Google Sheets

> Learn how to integrate AI agents with Google Sheets using xpander.ai. Create intelligent workflows that automate data analysis, trigger actions based on cell values, and enable natural language interaction with your spreadsheets.

## About Google Sheets

Google Sheets is a free, cloud-based spreadsheet application developed by Google. It enables users to create, edit, and collaborate on spreadsheets in real-time across various devices, including web browsers and mobile apps for Android and iOS.

Key features include:

* **Real-Time Collaboration**: Multiple users can work on the same spreadsheet simultaneously.

* **Comprehensive Functionality**: supports a wide array of functions and formulas for data manipulation, including mathematical, statistical, logical, and text functions. Users can create pivot tables, apply conditional formatting, and use data validation to ensure data integrity .

* **Data Visualization**: Users can generate various types of charts and graphs to visualize data effectively. The "Explore" feature leverages machine learning to provide insights, suggest charts, and answer questions about the data .

* **Offline Access**: With offline mode enabled, users can continue working on their spreadsheets without an internet connection. Changes made offline are synchronized automatically once connectivity is restored .

* **Integration and Compatibility**: Google Sheets is compatible with various file formats, including Microsoft Excel (.xls, .xlsx), CSV, and PDF. It also integrates with other Google services and supports add-ons to extend its functionality .

* **Automation with Google Apps Script**: Users can automate tasks and create custom functions using Google Apps Script, a JavaScript-based language. This allows for the development of macros and integration with external APIs .

## Authentication Options

Below are possible authentication options you can choose:

<Tabs>
  <Tab title="Built-in xpander.ai Auth">
    The simplest way to connect Google Sheets is by using xpander.ai's built-in authentication:

    1. Go to the **Connectors** section in the sidebar of your xpander.ai dashboard.
    2. Select **Google Sheets** from the available integrations.
    3. Click **Sign in with Google Sheets**.
    4. Grant xpander.ai permission to access your account.
    5. Your Google Sheets integration is now ready to use.

    <Note>
      This method is recommended for most users. xpander.ai securely manages your OAuth tokens without exposing any credentials.
    </Note>
  </Tab>

  <Tab title="API Access">
    ### Generate a Google Sheets API Key

    1. Log in to your [Google Cloud Console](https://console.cloud.google.com/).

    2. Create a new project or select an existing one.\\
           <img src="https://mintcdn.com/xpanderai-099931d1/pzRhrv6nqUySeaGz/images/connectors/google-sheets/img_1.png?fit=max&auto=format&n=pzRhrv6nqUySeaGz&q=85&s=8b90419df0359570468e90b137ec7e49" alt="Img 1" width="2939" height="1431" data-path="images/connectors/google-sheets/img_1.png" />

    3. Go to the [Google Cloud API Library](https://console.cloud.google.com/apis/library).\\
           <img src="https://mintcdn.com/xpanderai-099931d1/pzRhrv6nqUySeaGz/images/connectors/google-sheets/img_2.png?fit=max&auto=format&n=pzRhrv6nqUySeaGz&q=85&s=9c757d9356d9de99b195a705d1a2a4b9" alt="Img 2" width="2921" height="1412" data-path="images/connectors/google-sheets/img_2.png" />

    4. Search for and select **Google Sheets API**, then click **Enable**.

    5. In the sidebar, go to **Credentials**.

    6. Click **Create credentials**, and select **API key**.\\
           <img src="https://mintcdn.com/xpanderai-099931d1/pzRhrv6nqUySeaGz/images/connectors/google-sheets/img_3.png?fit=max&auto=format&n=pzRhrv6nqUySeaGz&q=85&s=a0f7067090546ba4471e9cb9012cf650" alt="Img 3" width="2923" height="1102" data-path="images/connectors/google-sheets/img_3.png" />

    7. Restrict the API key to Google Sheets API only (optional but recommended).\\
           <img src="https://mintcdn.com/xpanderai-099931d1/pzRhrv6nqUySeaGz/images/connectors/google-sheets/img_4.png?fit=max&auto=format&n=pzRhrv6nqUySeaGz&q=85&s=8a99c84882187d3fe8dad15d55750819" alt="Img 4" width="2924" height="1185" data-path="images/connectors/google-sheets/img_4.png" />

    ### Integrate Google Sheets into xpander.ai

    1. Go to the **Connectors** section in the sidebar of your xpander.ai dashboard.
    2. Select **Google Sheets** from the available integrations.
    3. Click **Other auth options**.
    4. Enter a **connector name**, e.g., "xpander-google-sheets".
    5. Select **Integration User** as the authentication mode.
    6. Select **API Key** as the authentication method.
    7. Paste the Google Sheets API key into the provided field.
    8. Choose **Basic** as the **Auth Type**.
    9. Save the configuration.

           <img src="https://mintcdn.com/xpanderai-099931d1/pzRhrv6nqUySeaGz/images/connectors/google-sheets/img_5.png?fit=max&auto=format&n=pzRhrv6nqUySeaGz&q=85&s=7d863a98e5a387bce2d932d40b3bd835" alt="Img 5" width="2939" height="1487" data-path="images/connectors/google-sheets/img_5.png" />

    <Warning>
      API keys provide limited functionality and are best for read-only operations on public files. For full access, use OAuth methods.
    </Warning>
  </Tab>
</Tabs>

## Integration of Google Sheets into AI Agent

Once you've configured your Google Sheets account with the authentication option(s) described above, you can integrate it into your AI agent with xpander.ai:

1. In your xpander.ai dashboard, go to the **Agent Configuration** tab and select **Tools**, then click **Add Tools**.
2. Select **Connectors**.
3. Choose **Google Sheets** with the same **connector name** you configured in the previous section (e.g., xpander-google-sheets).
4. Select the available Google Sheets operations that suit your use case.

<img src="https://mintcdn.com/xpanderai-099931d1/pzRhrv6nqUySeaGz/images/connectors/google-sheets/img_6.png?fit=max&auto=format&n=pzRhrv6nqUySeaGz&q=85&s=6ef5fa2aa1c97873beff36680c9761ec" alt="Img 6" width="2945" height="1495" data-path="images/connectors/google-sheets/img_6.png" />

## Expose Google Sheets as MCP Server

Alternatively, you can also expose your Google Sheets account as an MCP server. To do so:

1. Go to the **Connectors** section in the sidebar of your xpander.ai dashboard.
2. Select **Google Sheets** with the same **connector name** you configured in the previous section (e.g., xpander-google-sheets).
3. Click **MCP Configuration**.
4. Enter the MCP configuration into the appropriate settings of the client app you want to use (e.g., Cursor, Windsurf, Claude Desktop, etc.).

<img src="https://mintcdn.com/xpanderai-099931d1/pzRhrv6nqUySeaGz/images/connectors/google-sheets/img_7.png?fit=max&auto=format&n=pzRhrv6nqUySeaGz&q=85&s=5b14fc9dee35fccc6fc004694b09ed15" alt="Img 7" width="2947" height="1510" data-path="images/connectors/google-sheets/img_7.png" />

## AI Agent Google Sheets Prompt Library

Below are possible prompts or use cases you can try after integrating Google Sheets into your xpander AI agent:

```
Can you create a new spreadsheet titled {my_title} with a data source schedule for {my_refresh_scope}?
```

```
Can you retrieve the values in range {my_cell_range} from spreadsheet {my_spreadsheet}?
```

```
Can you copy the sheet {my_sheet} from spreadsheet {my_source_spreadsheet} to {my_destination_spreadsheet}?
```

```
Can you get the metadata {my_metadata} from spreadsheet {my_spreadsheet}?
```

## Related Resources

* [Understanding Model Context Protocol (MCP)](/guides/deploy/mcp)
* [Google Sheets API Documentation](https://developers.google.com/workspace/sheets/api/guides/concepts)
