Integrate Gemini Enterprise Agents with Google Workspace

1. Before you begin

7zN3mxxU73oY8Gi.png

What is Gemini Enterprise?

Gemini Enterprise is an advanced agentic platform that brings the best of Google AI to every employee, for every workflow. It empowers teams to discover, create, share, and run AI agents in one secure environment.

  • Access advanced models: Users get immediate access to Google's most powerful multimodal AI, including Gemini, to tackle complex business challenges.
  • Utilize specialized agents: The suite includes ready-to-use Google agents for research, coding, and note-taking to provide immediate value.
  • Empower every employee: No-code and pro-code options allow staff across all departments to build and manage their own custom agents for workflow automation.
  • Ground agents in data: Agents can be securely connected to internal company data and third-party applications to ensure their responses are contextually accurate.
  • Centralized governance: Administrators can visualize and audit all agent activity to ensure the organization meets strict security and compliance standards.
  • Expand with ecosystems: The platform integrates with a wide network of partner applications and service providers to extend automation across different systems.

127f2ed7d484722c.png

What is Google Workspace?

Google Workspace is a collection of cloud-based productivity and collaboration solutions designed for individuals, schools, and businesses:

  • Communication: Professional email services (Gmail), video conferencing (Meet), and team messaging (Chat).
  • Content Creation: Tools for writing documents (Docs), building spreadsheet (Sheets), and designing presentations (Slides).
  • Organization: Shared calendars (Calendars) and digital note-taking (Keep).
  • Storage: Centralized cloud space for saving and sharing files securely (Drive).
  • Management: Administrative controls to manage users and security settings (Workspace Admin Console).

What kind of custom integrations?

Google Workspace and Gemini Enterprise create a powerful feedback loop where Workspace provides real-time data and collaboration context, while Gemini Enterprise offers the models, agentic reasoning, and orchestration required to automate intelligent workflows.

  • Smart connectivity: Google-managed data stores, APIs, and MCP servers (Google-managed and custom) allows agents to securely and seamlessly access Workspace data and take actions on behalf of users.
  • Custom agents: Using no-code designers or pro-code frameworks, teams can build specialized agents grounded in admin-governed Workspace data and actions.
  • Native integration: Workspace add-ons bridge the gap between AI systems and applications like Chat and Gmail, whether through dedicated UI components or background processes. This allows agents to meet users exactly where they are for instantaneous, context-aware assistance.

By combining the robust productivity ecosystem of Google Workspace with the advanced agentic power of Gemini Enterprise, organizations can transform their operations through custom, data-grounded AI agents that automate complex workflows directly within the tools their teams already use every day.

Prerequisites

If you want to follow all the steps on your own environment, you'll need:

What you will build

In this codelab, we build three solutions with Gemini Enterprise AI agents tightly integrated with Google Workspace. They'll demonstrate architectural patterns that can be used to interact with data, actions, and UIs.

No-code custom agent

This agent allows users to search data and take actions for Workspace in their natural language. It relies on the following elements:

  • Model: Gemini.
  • Data & actions: Gemini Enterprise data stores for Google Workspace (Calendar, Gmail, Drive, NotebookLM), Google Search.
  • Agent building tools: Gemini Enterprise Agent Designer.
  • Agent host: Gemini Enterprise.
  • UI: Gemini Enterprise Web app.

90e42539e5959634.png60e62437ce29a818.png

Pro-code custom agent

This agent allows users to search data and take actions for Workspace in their natural language using custom tools and rules. It relies on the following elements:

  • Model: Gemini.
  • Data & actions: Gemini Enterprise data stores for Google Workspace (Calendar, Gmail, Drive, NotebookLM), Google Search, Google-managed Agent Search's Model Context Protocol (MCP) server, custom tool function to send Google Chat messages (via Google Chat API).
  • Agent building tools: Agent Development Kit (ADK).
  • Agent host: Agent Runtime.
  • UI: Gemini Enterprise Web app.

1647ebff031c42e7.pnga8087d2351e77fb4.png

Default agent as Google Workspace add-on

This agent allows users to search data for Workspace in their natural language within the context of Workspace app UIs. It relies on the following elements:

  • Model: Gemini.
  • Data: Gemini Enterprise data stores for Google Workspace (Calendar, Gmail, Drive, NotebookLM), Google Search.
  • Agent host: Gemini Enterprise.
  • UI: Google Workspace add on for Chat and Gmail (easily extendable to Calendar, Drive, Docs, Sheets, and Slides).
  • Google Workspace add on: Apps Script, Gemini Enterprise APIs, contextual (user metadata, selected Gmail message).

c8c63fb3f324fecf.pngd33b8cb50ee251b7.png

What you will learn

  • The integration points between Gemini Enterprise and Google Workspace that enable data and actions.
  • The no-code and pro-code options to build custom agents hosted in Gemini Enterprise.
  • The ways users can access agents from the Gemini Enterprise web app and Google Workspace applications.

Easy access to this codelab

82JGvYaTp8dhuvv.png

2. Get set up

Review concepts

Gemini Enterprise app

A Gemini Enterprise app provides search results, actions, and agents to your end users. The term app can be used interchangeably with the term engine in the context of APIs. An app must be connected to a data store in order to use the data from it to serve search results, answers, or actions.

Gemini Enterprise web app

A Gemini Enterprise web app is associated with a Gemini Enterprise app. It functions as a centralized AI home base where employees use a single chat interface to search across siloed company data, run specialized AI agents for complex workflows, and generate professional-grade content with enterprise-level privacy.

Initialize and access resources

In this section, you access and configure the following resources from your preferred web browser.

Gemini Enterprise app

Open the Google Cloud console in a new tab, then follow these steps:

  1. Select your project.
  2. In the Google Cloud search field, search and select Gemini Enterprise, then click + Create app. If you do not have a license for Gemini Enterprise, you will be prompted to activate a 30-day free trial license.

  1. Set the App name to codelab.
  2. An ID is generated based on the name and is displayed under the field, copy it.
  3. Set the Multi-region to global (Global).
  4. Click Create.

8712ada39377205e.png

  1. The app is created and you are automatically redirected to Gemini Enterprise > Overview.
  2. Under Get Full access, click Set up identity.
  3. In the new screen, select Use Google Identity and click Confirm Workforce Identity.

3209c156eff4ba43.png

  1. The configuration is saved and you are automatically redirected to Gemini Enterprise > Overview.
  2. Navigate to Configurations.
  3. In the tab Feature Management, turn Enable agent designer on, click Save.

f0cd9da419b41cb6.png

Gemini Enterprise web app

Open Gemini Enterprise from the Cloud console in a new tab, then follow these steps:

  1. Click the app named codelab.
  2. Copy the URL that shows up as we will use it to navigate it to the Gemini Enterprise web app in next steps.

b46ee6176744565d.png

3. No-code custom agent

This agent allows users to search data and take actions for Workspace in their natural language. It relies on the following elements:

  • Model: Gemini.
  • Data & actions: Gemini Enterprise data stores for Google Workspace (Calendar, Gmail, Drive, NotebookLM), Google Search.
  • Agent building tools: Gemini Enterprise Agent Designer.
  • Agent host: Gemini Enterprise.
  • UI: Gemini Enterprise Web app.

Review concepts

Gemini

Gemini is a multimodal LLM from Google. It helps people unlock their human potential so that they can augment their imagination, expand their curiosity, and enhance their productivity.

Gemini Enterprise data store

A Gemini Enterprise data store is an entity that contains the data ingested from a first-party data source such as Google Workspace or third-party applications such as Jira or Salesforce. Data stores that contain data from third-party applications are also called data connectors.

Gemini Enterprise Agent Designer

The Gemini Enterprise Agent Designer is an interactive no-code, low-code platform for creating, managing, and launching single and multi-step agents in Gemini Enterprise.

Review solution architecture

e77aafb772502aaf.png

Enable APIs

The Gemini Enterprise Workspace data stores require the enablement of APIs:

  1. In the Google Cloud console, enable the Calendar, Gmail, and People APIs:

573322606b715a69.png

  1. Click Menu ☰ > APIs & Services > Enabled APIs & Services and then confirm that Google Calendar API, Gmail API, and People API are in the list.

The Gemini Enterprise Workspace Calendar and Gmail actions require a consent screen configuration:

  1. In the Google Cloud console, click to Menu ☰ > Google Auth platform > Branding.

  1. Click Get started.
  2. Under App Information, set the App name to Codelab .
  3. In User support email, choose a support email address where users can contact you if they have questions about their consent.
  4. Click Next.
  5. Under Audience, select Internal.
  6. Click Next.
  7. Under Contact Information, enter an Email address where you can be notified about any changes to your project.
  8. Click Next.
  9. Under Finish, review the Google API Services User Data Policy and if you agree, select I agree to the Google API Services: User Data Policy.
  10. Click Continue then Create.

578c2b38219b2f7b.png

  1. The configuration is saved and you are automatically redirected to Google Auth Platform > Overview.
  2. Navigate to Data Access.
  3. Click Add or remove scopes.
  4. Copy the following scopes and paste them into the Manually add scopes field.
https://www.googleapis.com/auth/calendar.readonly
https://www.googleapis.com/auth/calendar.events
https://www.googleapis.com/auth/calendar.calendars
https://www.googleapis.com/auth/gmail.send
https://www.googleapis.com/auth/gmail.readonly
  1. Click Add to table, then Update, then Save.

874b1dda14e8f379.png

To learn more, see the full Configure OAuth consent guide.

Create OAuth client credentials

Create a new OAuth client for Gemini Enterprise to authenticate users:

  1. In the Google Cloud console, click to Menu ☰ > Google Auth platform > Clients.

  1. Click + Create client.
  2. For Application type, select Web application.
  3. Set the Name to codelab.
  4. Skip Authorized JavaScript origins.
  5. In the Authorized redirect URIs section, click Add URI and enter https://vertexaisearch.cloud.google.com/oauth-redirect.
  6. Click Create.
  7. A dialog will appear with your newly created OAuth client ID and secret. Save this information in a safe place.

a46e5ebfb851aea5.png

Create data stores

You need to create data stores to connect Gemini Enterprise to your Workspace data.

Open Gemini Enterprise from the Cloud console in a new tab, then follow these steps:

  1. Click the app named codelab.
  2. In the navigation menu, click Connected data stores.
  3. Click + New data store.
  4. In the Source, search for Google Calendar, and click Select.
  5. In the Actions section, enter the Client ID and Client Secret saved from previous steps, and then click Verify Auth and follow the steps to authenticate and authorize the OAuth client.
  6. Enable the actions Create calendar event and Update calendar event.
  7. Click Continue.

a1d76e70edec0cf.png

  1. In the Configuration section, set the Data connector name to calendar.
  2. Click Create.
  3. You are automatically redirected to Connected data stores where you can see the newly added data store.

Create the Google Gmail data store:

  1. Click + New data store.
  2. In the Source, search for Google Gmail, and click Select.
  3. In the Actions section, enter the Client ID and Client Secret saved from previous steps, and then click Verify Auth.
  4. Enable the action Send email.
  5. Click Continue.
  6. In the Configuration section, set the Data connector name to gmail.
  7. Click Create.
  8. You are automatically redirected to Connected data stores where you can see the newly added data store.

Create the Google Drive data store:

  1. Click + New data store.
  2. In the Source, search for Google Drive, and click Select.
  3. In the Data section, select All, then click Continue.
  4. In the Configuration section, set the Data connector name to drive.
  5. Click Create.
  6. You are automatically redirected to Connected data stores where you can see the newly added data store.

Create the NotebookLM data store:

  1. Click + New data store.
  2. In the Source, search for NotebookLM, and click Select.
  3. In the Configuration section, set the Data connector name to notebooklm.
  4. Click Create.
  5. You are automatically redirected to Connected data stores where you can see the newly added data store.

After a few minutes, the status of all connected data store statuses (except for NotebookLM) will be Active. If you see any errors, you can click on the data source to view the error details.

ceba9eb2480a2696.png

Test data stores

Verify that your data stores are correctly ingesting data by running some test queries.

Open the Gemini Enterprise web app URL that we copied earlier:

  1. Click Menu ☰ > New chat.
  2. In the footer of the new chat message field, click the Connectors icon and enable all connectors.
  3. You can now experiment with prompts related to the connectors. For example, in the chat, type Do I have any meetings today? and press enter.
  4. Next, try typing How many emails did I receive today? and press enter.
  5. Finally, type Give me the title of the last Drive file I created and press enter.

90e42539e5959634.png

Create custom agent

In the Gemini Enterprise web app, create a new agent using the Agent Designer:

  1. Click Menu ☰ > + New agent.
  2. In the chat, type An agent that always sends pirate-themed emails but use normal English otherwise and press enter.

2803c1dedd20433e.png

  1. The Agent Designer drafts the agent based on the prompt and opens it in the editor.
  2. Click Create

Try custom agent

Test your new agent to see how it answers questions and performs actions.

  1. In the Gemini Enterprise web app, chat with the newly created agent:
  2. Click Menu ☰ > Agents.
  3. Select the agent under Your agents.
  4. In the footer of the new chat message field, click the Connectors icon, then click Enable actions for Mail and follow the instructions to authorize the agent
  5. In the chat, type Send an email to someone@example.com saying I'll see them at Cloud Next, generate some subject and body yourself and press enter. You can replace the sample email with your email address.
  6. Click ✔️ to send the email.

60e62437ce29a818.pngd4fb65d14fdf27da.png

4. Pro-code custom agent

This agent allows users to search data and take actions for Workspace in their natural language using custom tools and rules. It relies on the following elements:

  • Model: Gemini.
  • Data & actions: Gemini Enterprise data stores for Google Workspace (Calendar, Gmail, Drive, NotebookLM), Google Search, Google-managed Agent Search's Model Context Protocol (MCP) server, custom tool function to send Google Chat messages (via Google Chat API).
  • Agent building tools: Agent Development Kit (ADK).
  • Agent host: Agent Runtime.
  • UI: Gemini Enterprise Web app.

It will be integrated in Gemini Enterprise using the bring-your-own feature so we need to go through deployment, registration, and configuration steps.

Review concepts

Gemini Enterprise Agent Platform

Gemini Enterprise Agent Platform (fka Vertex AI) is an open and comprehensive platform that empowers businesses to rapidly build, scale, govern and optimize enterprise-grade agents grounded in enterprise data.

4670fcf7a826af4d.png

Agent Development Kit (ADK)

The Agent Development Kit (ADK) is a specialized suite of tools and frameworks designed to simplify the creation of autonomous AI agents by providing pre-built modules for reasoning, memory management, and tool integration.

Model Context Protocol (MCP)

The Model Context Protocol (MCP) is an open standard designed to enable seamless, secure integration between AI applications and various data sources or tools through a universal, "plug-and-play" interface.

Function Tool

A Function tool is a predefined executable routine that an AI model can trigger to perform specific actions or retrieve real-time data from external systems, extending its capabilities beyond simple text generation.

Review solution architecture

43df337e0f3d64e8.png

Review source code

agent.py

The following code authenticates with Gemini Enterprise, initializes the Agent Search MCP and Chat API tools, and defines the agent's behavior.

  1. Authentication: It uses a helper function _get_access_token_from_context to retrieve the authentication token (CLIENT_AUTH_NAME) that Gemini Enterprise injects. This token is crucial for securely calling downstream services like Agent Search MCP and Google Chat tools.
  2. Tools Setup: It initializes vertexai_mcp, a toolset that connects to the Agent Search Model Context Protocol (MCP) server, and the send_direct_message tool. This gives the agent the ability to search through your connected data stores and send Google Chat messages.
  3. Agent Definition: It defines the root_agent using the gemini-2.5-flash model. The instructions tell the agent to prioritize using the search tool for information retrieval and the send_direct_message tool for actions, effectively grounding the agent in your enterprise data.
...
MODEL = "gemini-2.5-flash"

# Gemini Enterprise authentication injects a bearer token into the ToolContext state.
# The key pattern is "CLIENT_AUTH_NAME_<random_digits>".
# We dynamically parse this token to authenticate our MCP and API calls.
CLIENT_AUTH_NAME = "enterprise-ai"

VERTEXAI_SEARCH_TIMEOUT = 15.0

def get_project_id():
    """Fetches the consumer project ID from the environment natively."""
    _, project = google.auth.default()
    if project:
        return project
    raise Exception(f"Failed to resolve GCP Project ID from environment.")

def find_serving_config_path():
    """Dynamically finds the default serving config in the engine."""
    project_id = get_project_id()
    engines = discoveryengine_v1.EngineServiceClient