6 min read

Marketing Multi-Agent System built with Google Agent Development Kit (ADK)

Marketing Multi-Agent System built with Google Agent Development Kit (ADK)

This past weekend, I've been building something truly exciting for my fellow Marketing and Retail media innovators: a Marketing Multi-Agent System designed to revolutionize ad copy creation. Imagine generating both video and image-based ads entirely from the rich web and app behavior data already residing within your organization's data warehouse – all without ever leaving your familiar UI. This system acts as your dedicated 'Agent Smith' for Marketing, capable of engaging in a dialogue with you and your data, intelligently crafting audience segments, extracting powerful insights, and then translating those insights into compelling creatives. The grand finale? A concise, impactful 8-second video that encapsulates the entire campaign! 

So what is The Business Problem that I thought of solving? 

Modern marketing teams are drowning in data but starving for actionable insights. Vast amounts of customer information, especially from rich sources like Google Analytics 4 (GA4) stored in BigQuery, offer a goldmine. However, manually sifting through this data, identifying key audience segments, deriving meaningful behavioral insights, brainstorming creative concepts, and finally generating campaign materials is a time-consuming, multi-stage process that often involves several different tools and specialized roles. This can lead to slow campaign launches, missed opportunities, and a disconnect between raw data and impactful marketing actions.

How can we bridge this gap and empower marketers to go from complex data to compelling campaigns more efficiently and intelligently?

The solution could be a Marketing Multi-Agent Demo built using the Google Agent Development Kit (ADK).

I built this demo to showcase how a team of specialized AI agents can collaborate to automate and enhance the marketing campaign lifecycle.

Harnessing GA4 Data in BigQuery with Natural Language

At the heart of this is the ability to tap into valuable Google Analytics 4 (GA4) data, typically exported to and stored in Google BigQuery. This data provides a rich, event-based view of user interactions across websites and apps.

A key desired feature (though implemented with predefined segment logic in our current demo, and an area for future NL2SQL enhancement) is to allow marketers to ask questions about this data using natural language. For example, instead of writing complex SQL queries, a marketer could ideally ask:

  • "What were the top-performing products last quarter for users from Canada?"
  • "Show me the conversion rate for mobile users who came from our recent email campaign."

The Google ADK Agent Framework

The Google Agent Development Kit (ADK) provides the foundation for building our multi-agent system. It allows us to define individual agents, each with its own specialized role, tools (which can be other Python functions or even other agents), and LLM-driven decision-making capabilities. These agents can then interact within a session to achieve a larger goal.

Quick understanding of my Demo system’s File Structure

A well-organized file structure is key to managing a multi-agent project. Here’s a conceptual overview:

The Multi-Agent Workflow:

Our demo employs a pipeline of specialized agents and services, orchestrated to deliver a complete marketing campaign strategy from data to creatives.

1. The GreeterAgent (marketing_suite_agents/greeter_agent.py)

  • Role: The primary point of contact for the user. It welcomes them, explains the system's capabilities (including its use of GA4 data from BigQuery), and manages the initial interaction.
  • Key Actions:
  • Proactively offers a data overview.
  • If the user asks "what data do you have?", it uses its getdata_overview_tool_impl tool. This tool calls get_data_availability_summary from bigquery_service.py (which attempts to query your BQ schema) and presents this information directly to the user.
  • Offers the user a choice: run a predefined default campaign scenario or specify custom parameters.
  • Based on user choice, it calls its main orchestration tool: initiateand_manage_campaign_flow_tool_impl.

2. The CampaignOrchestrator Class (within marketing_suite_agents/orchestrator_agent.py)

  • Role: This is not an ADK Agent itself, but a powerful Python class that acts as the central logic engine. It's instantiated and used by the GreeterAgent's initiateand_manage_campaign_flow_tool_impl. It manages the multi-step campaign workflow.
  • Key Actions (within its execute_turn method):
  • Parameter Handling: If called for a default scenario, it uses pre-defined parameters. For custom requests, it calls generate_text_with_gemini (from tools/gemini_service.py) to parse the user's natural language request into structured parameters (segments, timeframe, product focus, creative needs).
  • State Management: It maintains the current state of the campaign (e.g., Workspaceing_data, analyzing_insights, awaiting_image_decision, generating_creatives, presenting_report).
  • Sequential Tool Function Invocation:
  • Reporting: Compiles a final report string with attributions to the different "service" steps.

3. Data Source: GA4 in BigQuery (tools/bigquery_service.py)

  • Role: This service module handles all direct interactions with Google BigQuery.
  • Key Functions:
get_date_range(): Parses natural language timeframes (e.g., "last month") into YYYYMMDD start/end dates.
get_segment_data_from_bq(): Constructs and executes SQL queries against your GA4 BigQuery tables (using the ENV_GCP_PROJECT_ID, ENV_GA4_DATASET_ID, ENV_GA4_TABLE_PATTERN from .env) to fetch data for specified segments and date ranges. The SQL includes logic to define common segments like "new_users," "purchasers," "mobile_users," etc.
get_data_availability_summary(): Attempts to query INFORMATION_SCHEMA.COLUMNS of a representative GA4 table (e.g., events_20210131 for the public dataset) to provide a list of available columns/dimensions. It also tries to get the min/max event dates.

4. LLM Interaction (tools/gemini_service.py)

  • Role: Manages all calls to the Gemini Large Language Model.
  • Key Functions:
generate_text_with_gemini(): The core function. It takes a text prompt and an optional image path (for multimodal context). If GENAI_SDK_AVAILABLE is True (meaning a valid GEMINI_API_KEY is found in .env), it makes a real API call to the specified Gemini model (e.g., gemini-1.5-pro-latest). It handles requesting JSON output if needed and provides robust dummy fallbacks. 

This function is used for:

  • Parsing campaign parameters by the CampaignOrchestrator.
  • Generating insights text by the InsightAgent's logic.
  • Generating creative text (headlines, body, visual concept descriptions, image generation prompts) by the CreativeAgent's logic.
generate_image_and_save(): Currently saves a dummy Pillow image but is structured with TODO comments for integrating real AI image generation calls (e.g., to Vertex AI Imagen or a future Gemini image model). It takes a text prompt and an optional inspiration image path.

5. Specialist Agent Logic (Tool Implementations in data_fetcher_agent.py, insight_agent.py, creative_agent.py)

6. InsightAgent (_analyze_behavior_tool_impl): Takes data JSONs, constructs a detailed prompt, and calls generate_text_with_gemini to get textual insights and a product suggestion.

Now, this one was interesting as It gave me results that I wasnt even sure that existed in BigQuery. So, I checked in BQ if this actually existed or this is hallucinating.

CreativeAgent (_generate_full_creative_package_tool_impl): Takes insights, product, and optional image path. Calls generate_text_with_gemini for ad copy, visual concept (inspired by uploaded image if present), and image generation prompts.

And, What is the final result? - It is a full detailed report on what could be the campaign based on the insights from the data. I also asked it to generate me prompts that i will pass onto Google Cloud VEO model to create a video for me!

And a Video based on the Visual concept!

Play

Isn't this cool?

Here is the full Demo..