Note: This project is part of the official Google Codelabs Integrate Vertex AI Agents with Google Workspace.
This sample contains a specialized Enterprise Agent built using the Google Agent Development Kit (ADK). This agent acts as an Enterprise AI Assistant by querying user's data corpus using the Vertex AI Search MCP toolset and sending Chat messages to DM spaces using a custom Function tool & Google Chat API.
-
Dynamic Vertex AI Serving Configs: The agent automatically discovers your project's
default_collectionengine and dynamically binds its queries to thedefault_serving_config. -
Static Authentication (
ACCESS_TOKEN): The client (e.g. ADK Web) passes an authentication token in theACCESS_TOKENenvironment variable. This agent extracts the token at runtime to securely execute calls using a Bearer token. -
Graceful Timeouts: The
McpToolsetstreaming components have been intentionally configured with an explicit 15-secondtimeoutandsse_read_timeoutto prevent the agent from hanging infinitely on backend network issues. -
Google Chat Integration: The agent natively includes a
send_direct_messagetool powered by thegoogle-apps-chatSDK. This allows the AI to immediately send direct messages to users inside Google Chat. It seamlessly reuses the same authentication token extracted from theACCESS_TOKENenvironment variable.
The agent requires a valid OAuth access token to authenticate with Google APIs (Vertex AI Search, Google Chat).
To set the ACCESS_TOKEN environment variable with a valid token, you must authenticate using a Desktop app OAuth client.
- Download your Desktop app OAuth client JSON file (e.g.,
client_secret.json) in the root directory. - Authenticate using
gcloudwith the client ID and required scopes:
gcloud auth application-default login \
--client-id-file=client_secret.json \
--scopes=https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/chat.spaces,https://www.googleapis.com/auth/chat.messages- Generate the access token and set the environment variable:
export ACCESS_TOKEN=$(gcloud auth application-default print-access-token)-
Optionally, you can set the
GOOGLE_CLOUD_PROJECTandGOOGLE_CLOUD_LOCATIONenvironment variables (defaults to current gcloud project andus-central1). -
Deploy the agent locally using the ADK
webcommand:
adk web