1. Before you begin
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.
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:
- A basic knowledge of Google Cloud and Python.
- A Google Cloud project you are an owner of with billing. To check that an existing project has billing enabled, see Verify the billing status of your projects. To create a project and set up billing, see Create a Google Cloud project. To change project ownership, see Manage project members or change project ownership.
- Gemini Enterprise Standard / Plus editions enabled. To compare Gemini Enterprise editions, see Compare editions of Gemini Enterprise. If you do not have a license for Gemini Enterprise, you will have the option to create a trial license in the next step.
- A Business or Enterprise Google Workspace account with access to Google Chat and smart features turned on.
- The Google Cloud CLI installed and initialized for your Google Cloud project.
- Python 3.11+ installed, see instructions on the official Python website.
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.


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.


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).


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

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:
- Select your project.
- 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.
- Set the App name to
codelab. - An ID is generated based on the name and is displayed under the field, copy it.
- Set the Multi-region to
global (Global). - Click Create.

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

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

Gemini Enterprise web app
Open Gemini Enterprise from the Cloud console in a new tab, then follow these steps:
- Click the app named
codelab. - Copy the URL that shows up as we will use it to navigate it to the Gemini Enterprise web app in next steps.

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

Enable APIs
The Gemini Enterprise Workspace data stores require the enablement of APIs:
- In the Google Cloud console, enable the Calendar, Gmail, and People APIs:

- Click Menu ☰ > APIs & Services > Enabled APIs & Services and then confirm that Google Calendar API, Gmail API, and People API are in the list.
Configure the OAuth consent screen
The Gemini Enterprise Workspace Calendar and Gmail actions require a consent screen configuration:
- In the Google Cloud console, click to Menu ☰ > Google Auth platform > Branding.
- Click Get started.
- Under App Information, set the App name to
Codelab. - In User support email, choose a support email address where users can contact you if they have questions about their consent.
- Click Next.
- Under Audience, select Internal.
- Click Next.
- Under Contact Information, enter an Email address where you can be notified about any changes to your project.
- Click Next.
- 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.
- Click Continue then Create.

- The configuration is saved and you are automatically redirected to Google Auth Platform > Overview.
- Navigate to Data Access.
- Click Add or remove scopes.
- 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
- Click Add to table, then Update, then Save.

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:
- In the Google Cloud console, click to Menu ☰ > Google Auth platform > Clients.
- Click + Create client.
- For Application type, select Web application.
- Set the Name to
codelab. - Skip Authorized JavaScript origins.
- In the Authorized redirect URIs section, click Add URI and enter
https://vertexaisearch.cloud.google.com/oauth-redirect. - Click Create.
- A dialog will appear with your newly created OAuth client ID and secret. Save this information in a safe place.

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:
- Click the app named
codelab. - In the navigation menu, click Connected data stores.
- Click + New data store.
- In the Source, search for Google Calendar, and click Select.
- 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.
- Enable the actions Create calendar event and Update calendar event.
- Click Continue.

- In the Configuration section, set the Data connector name to
calendar. - Click Create.
- You are automatically redirected to Connected data stores where you can see the newly added data store.
Create the Google Gmail data store:
- Click + New data store.
- In the Source, search for Google Gmail, and click Select.
- In the Actions section, enter the Client ID and Client Secret saved from previous steps, and then click Verify Auth.
- Enable the action Send email.
- Click Continue.
- In the Configuration section, set the Data connector name to
gmail. - Click Create.
- You are automatically redirected to Connected data stores where you can see the newly added data store.
Create the Google Drive data store:
- Click + New data store.
- In the Source, search for Google Drive, and click Select.
- In the Data section, select All, then click Continue.
- In the Configuration section, set the Data connector name to
drive. - Click Create.
- You are automatically redirected to Connected data stores where you can see the newly added data store.
Create the NotebookLM data store:
- Click + New data store.
- In the Source, search for NotebookLM, and click Select.
- In the Configuration section, set the Data connector name to
notebooklm. - Click Create.
- 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.

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:
- Click Menu ☰ > New chat.
- In the footer of the new chat message field, click the Connectors icon and enable all connectors.
- You can now experiment with prompts related to the connectors. For example, in the chat, type
Do I have any meetings today?and pressenter. - Next, try typing
How many emails did I receive today?and pressenter. - Finally, type
Give me the title of the last Drive file I createdand pressenter.

Create custom agent
In the Gemini Enterprise web app, create a new agent using the Agent Designer:
- Click Menu ☰ > + New agent.
- In the chat, type
An agent that always sends pirate-themed emails but use normal English otherwiseand pressenter.

- The Agent Designer drafts the agent based on the prompt and opens it in the editor.
- Click Create
Try custom agent
Test your new agent to see how it answers questions and performs actions.
- In the Gemini Enterprise web app, chat with the newly created agent:
- Click Menu ☰ > Agents.
- Select the agent under Your agents.
- 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
- In the chat, type
Send an email to someone@example.com saying I'll see them at Cloud Next, generate some subject and body yourselfand pressenter. You can replace the sample email with your email address. - Click ✔️ to send the email.


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.

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

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.
- Authentication: It uses a helper function
_get_access_token_from_contextto 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. - Tools Setup: It initializes
vertexai_mcp, a toolset that connects to the Agent Search Model Context Protocol (MCP) server, and thesend_direct_messagetool. This gives the agent the ability to search through your connected data stores and send Google Chat messages. - Agent Definition: It defines the
root_agentusing thegemini-2.5-flashmodel. The instructions tell the agent to prioritize using the search tool for information retrieval and thesend_direct_messagetool 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
