The Google Trends Agent is an AI agent designed to surface the newest Google Trends in real-time. It can identify emerging topics, analyze their velocity, and provide insights into what is currently capturing the world's attention. This is useful for content creators, marketers, and analysts who need to stay ahead of the curve. For example, a marketer could use this agent as part of their workflow to design a marketing campaign based on a trend in a specific region or city that relates to the product or service they promote.
This agent has several important limitations to be aware of:
- Dataset Constraints: The agent can only access data that exists in the public Google Trends BigQuery dataset, which contains only the top trending terms by region and time period.
- No Open-ended Searches: You cannot ask for trends on specific topics (e.g., "trending terms about AI agents") if they aren't already ranked as top terms in the dataset.
- Regional Limitations: Only regions included in the BigQuery dataset are available.
This diagram shows the detailed architecture of the agents and tools used to implement this workflow.

This agent is a sequential agent composed of two sub-agents that work together to fetch and analyze Google Trends data. The first sub-agent, TrendsQueryGeneratorAgent, generates a BigQuery SQL query from the user's request. The second sub-agent, TrendsQueryExecutorAgent, executes this query to retrieve the trends data and present it to the user. This modular design can be extended with more complex, multi-agent workflows.
| Feature | Description |
|---|---|
| Interaction Type | Conversational |
| Complexity | Medium |
| Agent Type | Sequential Agent |
| Components | Tools: BigQuery |
| Vertical | Marketing & Analytics |
- Core Logic: The agent's main logic is defined in
google_trends_agent/agent.py. - Tools: It utilizes tools to query the public Google Trends dataset on BigQuery to fetch trending data. You can explore querying the Google Trends dataset in Google Cloud Console.
- Dependencies: Key dependencies include
google-cloud-aiplatformfor the ADK and agent engine deployment,google-cloud-bigqueryandpandasfor data handling.
-
Prerequisites
- Python 3.11+
- Install uv
- A Google Cloud Platform project.
- The Google Cloud CLI.
-
Installation
# Navigate to the agent's directory cd adk-samples/python/agents/google-trends-agent # Install the package and dependencies. uv sync --dev
-
Configuration
-
Set up your Google Cloud credentials. You can set these in your shell or create a
.envfile in the agent's root directory (google-trends-agent/).# Authenticate your gcloud account gcloud auth application-default login gcloud auth application-default set-quota-project <your-project-id> # Create and populate .env file cp .env.example .env
-
Edit the
.envfile with your specific configuration:GOOGLE_CLOUD_PROJECT="<your-project-id>" GOOGLE_CLOUD_LOCATION="<your-project-location>" GOOGLE_CLOUD_STORAGE_BUCKET="<your-storage-bucket>" # Required for deployment
-
Grant the Agent Engine service account permission to run BigQuery jobs. This is required for deployment.
# Set your project ID export PROJECT_ID="<your-project-id>" # Get your project number export PROJECT_NUMBER=$(gcloud projects describe $PROJECT_ID --format="value(projectNumber)") # Grant the Agent Engine service account permission to run BigQuery jobs gcloud projects add-iam-policy-binding ${PROJECT_ID} \ --member="serviceAccount:service-${PROJECT_NUMBER}@gcp-sa-aiplatform-re.iam.gserviceaccount.com" \ --role="roles/bigquery.user"
-
You can run the agent locally using the adk command in your terminal.
-
Activate the virtual environment:
poetry shell
-
To run the agent from the CLI:
adk run . -
To run the agent from the ADK web UI:
adk web
Then select
google-trends-agentfrom the dropdown menu.
The agent can also be deployed to Vertex AI Agent Engine.
-
Ensure Prerequisites: Make sure your
GOOGLE_CLOUD_PROJECT,GOOGLE_CLOUD_LOCATION, andGOOGLE_CLOUD_STORAGE_BUCKETenvironment variables are set correctly in your.envfile. -
Run the deployment script:
poetry shell poetry install --with deployment python deployment/deploy.py
When the deployment finishes, it will output the resource ID of the remote agent deployment and update your
.envfile with theAGENT_ENGINE_ID. For example:Created remote agent: projects/<PROJECT_NUMBER>/locations/<PROJECT_LOCATION>/reasoningEngines/<AGENT_ENGINE_ID> -
Test the remote agent: Once deployed, you can interact with the remote agent by running:
python deployment/test_deployment.py
You can type
quitat any point to exit.
User: List the top 10 terms in Canada during the past 3 weeks
[TrendsQueryGeneratorAgent]:
SELECT
term,
rank,
week
FROM
`bigquery-public-data.google_trends.international_top_terms`
WHERE
refresh_date = DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)
AND country_name = 'Canada'
AND week IN (
SELECT DISTINCT
week
FROM
`bigquery-public-data.google_trends.international_top_terms`
WHERE
refresh_date = DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)
AND country_name = 'Canada'
ORDER BY
week DESC
LIMIT 3
)
ORDER BY
week DESC,
rank
LIMIT 100[TrendsQueryExecutorAgent]: The top terms in Canada for the week of 2025-07-13 are:
- usyk vs dubois
- man united vs leeds united
- rashford
- election loser nyt crossword answers
- reading vs tottenham
- blake wheeler
- france vs germany
- усик дюбуа
You can customize this agent to fit your specific needs:
- Change Data Source: Modify the agent's tools to pull trend data from different sources, such as social media APIs or other analytics platforms.
- Enhance Analysis: Add new tools to perform more in-depth analysis on the trends, deeper research (e.g. using Google Search as an additional tool) such as sentiment analysis or forecasting.
- Add Notifications: Integrate tools that send alerts via email or Slack when a new trend matching specific criteria is detected.
Use the Agent Starter Pack to create a production-ready version of this agent with additional deployment options. The easiest way is with uvx (no install needed):
uvx agent-starter-pack create my-google-trends-agent -a adk@google-trendsAlternative: Using pip and a virtual environment
# Create and activate a virtual environment
python -m venv .venv && source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install the starter pack and create your project
pip install --upgrade agent-starter-pack
agent-starter-pack create my-google-trends-agent -a adk@google-trendsThe starter pack will prompt you to select deployment options and provides additional production-ready features including automated CI/CD deployment scripts.