feat: Introduce AI Sales Intelligence Agent Team with multi-agent pipeline for generating competitive sales battle cards, including competitor research, feature analysis, SWOT analysis, objection handling, and visual comparison generation. Update README with detailed usage instructions and examples, and add necessary requirements for dependencies.

This commit is contained in:
Shubhamsaboo
2026-01-06 19:39:41 -08:00
parent 89beb8a77c
commit 4b2ac4a47c
5 changed files with 974 additions and 0 deletions

View File

@@ -0,0 +1,315 @@
# 👨🏻‍💼 AI Sales Intelligence Agent Team
A multi-agent AI pipeline that generates competitive sales battle cards in real-time, built with [Google ADK](https://google.github.io/adk-docs/) and Gemini 3.
**Give it a competitor + your product** → Get a complete battle card with positioning strategies, objection handling scripts, and visual comparisons.
## Features
- 🔍 **Live Research** - Real-time web search for competitor intelligence
- 📊 **Feature Analysis** - Deep dive into competitor product capabilities
- 🎯 **Positioning Intel** - Uncover how competitors position against you
- ⚖️ **SWOT Analysis** - Honest strengths/weaknesses comparison
- 💬 **Objection Scripts** - Ready-to-use responses for sales calls
- 📄 **Battle Card** - Professional HTML battle card for reps
- 📈 **Comparison Infographic** - AI-generated visual comparison (Gemini image)
## What It Does
Given a competitor and your product, the pipeline automatically:
1. **Researches the competitor** - Company, funding, customers, reviews
2. **Analyzes their features** - Capabilities, integrations, pricing
3. **Uncovers positioning** - Their messaging, personas, analyst coverage
4. **Creates SWOT analysis** - Where you win, where they win
5. **Generates objection scripts** - Top 10 objections with responses
6. **Builds battle card** - Professional HTML for sales reps
7. **Creates comparison chart** - Visual feature-by-feature comparison
## Quick Start
### 1. Navigate to Project
```bash
cd awesome-llm-apps/advanced_ai_agents/multi_agent_apps/agent_team/ai_sales_intelligence_team
```
### 2. Set Environment
```bash
export GOOGLE_API_KEY=your_api_key
```
### 3. Install & Run
```bash
pip install -r requirements.txt
adk web
```
### 4. Try It
Open `http://localhost:8000` and try:
- *"Create a battle card for Salesforce. We sell HubSpot."*
- *"Battle card against Slack - we're selling Microsoft Teams"*
- *"Help me compete against Zendesk, I sell Freshdesk"*
## Example Prompts
| Your Product | Competitor | Prompt |
|--------------|------------|--------|
| HubSpot | Salesforce | "Create a battle card for Salesforce. We sell HubSpot." |
| Asana | Monday.com | "Battle card against Monday.com, I sell Asana" |
| Zoom | Microsoft Teams | "Competitive analysis: Zoom vs our product Teams" |
| Notion | Confluence | "Help me compete against Confluence, we're Notion" |
---
## Pipeline Architecture
```
User Query: "Battle card for Salesforce. We sell HubSpot."
┌─────────────────────────────────────────────────────────────────┐
│ BattleCardPipeline (SequentialAgent) │
│ │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────┐ │
│ │ Stage 1 │ │ Stage 2 │ │ Stage 3 │ │
│ │ Competitor │───▶│ Product │───▶│ Positioning │ │
│ │ Research │ │ Features │ │ Analyzer │ │
│ └─────────────────┘ └─────────────────┘ └─────────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────┐ │
│ │ Stage 4 │ │ Stage 5 │ │ Stage 6 │ │
│ │ SWOT │───▶│ Objection │───▶│ Battle Card │ │
│ │ Analysis │ │ Handler │ │ Generator │ │
│ └─────────────────┘ └─────────────────┘ └─────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────┐ │
│ │ Stage 7 │ │
│ │ Comparison │ │
│ │ Chart │ │
│ └─────────────┘ │
└─────────────────────────────────────────────────────────────────┘
Artifacts: battle_card.html, comparison_chart.png
```
---
## Agent Details
### Stage 1: Competitor Research Agent
**Purpose:** Gathers comprehensive competitor intelligence through web search.
| Property | Value |
|----------|-------|
| Model | `gemini-3-flash-preview` |
| Tools | `google_search` |
| Output Key | `competitor_profile` |
**Researches:**
- Company overview (founded, HQ, size, funding)
- Target market and ideal customers
- Products and pricing tiers
- Recent news, launches, acquisitions
- Customer reviews (G2, Capterra, TrustRadius)
---
### Stage 2: Product Feature Agent
**Purpose:** Deep analysis of competitor product capabilities.
| Property | Value |
|----------|-------|
| Model | `gemini-3-flash-preview` |
| Tools | `google_search` |
| Output Key | `feature_analysis` |
**Analyzes:**
- Core features and capabilities
- Integrations and ecosystem
- Technical architecture (cloud, API, mobile)
- Pricing details and hidden costs
- Known limitations from reviews
---
### Stage 3: Positioning Analyzer Agent
**Purpose:** Uncovers competitor positioning and messaging strategy.
| Property | Value |
|----------|-------|
| Model | `gemini-3-pro-preview` |
| Tools | `google_search` |
| Output Key | `positioning_intel` |
**Discovers:**
- Marketing messaging and taglines
- Target personas they focus on
- How they position against YOUR product
- Analyst coverage (Gartner, Forrester, G2)
- Social proof and case studies
---
### Stage 4: SWOT Analysis Agent
**Purpose:** Creates honest strengths/weaknesses analysis.
| Property | Value |
|----------|-------|
| Model | `gemini-3-pro-preview` |
| Tools | None (synthesis) |
| Output Key | `swot_analysis` |
**Produces:**
- Top 5 competitor strengths (with evidence)
- Top 5 competitor weaknesses
- Where YOU win against them
- Competitive landmines to set in deals
---
### Stage 5: Objection Handler Agent
**Purpose:** Creates scripts for handling competitive objections.
| Property | Value |
|----------|-------|
| Model | `gemini-3-pro-preview` |
| Tools | None (synthesis) |
| Output Key | `objection_scripts` |
**Creates:**
- Top 10 objections with scripted responses
- Proof points for each response
- Killer questions to ask prospects
- Trap-setting phrases for early in deals
---
### Stage 6: Battle Card Generator Agent
**Purpose:** Generates professional HTML battle card.
| Property | Value |
|----------|-------|
| Model | `gemini-3-flash-preview` |
| Tools | `generate_battle_card_html` |
| Output Key | `battle_card_result` |
**Battle Card Includes:**
- Quick stats header
- At-a-glance comparison (We Win / They Win / Toss-up)
- Feature comparison table
- Objection handling cheat sheet
- Killer questions
- Landmines to set
**Artifact:** `battle_card_TIMESTAMP.html`
---
### Stage 7: Comparison Chart Agent
**Purpose:** Creates visual comparison infographic using Gemini image generation.
| Property | Value |
|----------|-------|
| Model | `gemini-3-flash-preview` |
| Tools | `generate_comparison_chart` (uses `gemini-2.0-flash-exp`) |
| Output Key | `chart_result` |
**Infographic Features:**
- AI-generated professional comparison graphic
- Side-by-side feature comparison visualization
- Color-coded scores (green = you, red = competitor)
- Key differentiators highlighted
- Overall verdict badge
**Artifact:** `comparison_infographic_TIMESTAMP.png`
---
## Project Structure
```
ai_battle_card_agent/
├── __init__.py # Exports root_agent
├── agent.py # All 7 agents + pipeline
├── tools.py # Battle card HTML + comparison chart tools
├── outputs/ # Generated artifacts saved here
├── requirements.txt # Dependencies
└── README.md # This file
```
## Generated Artifacts
All artifacts are saved to the **Artifacts tab** in ADK web and the **`outputs/`** folder:
```
outputs/
├── battle_card_20260104_143052.html # Full battle card document
└── comparison_infographic_20260104_143105.png # AI-generated comparison visual
```
| Artifact | Format | Description |
|----------|--------|-------------|
| Battle Card | HTML | Sales-ready competitive battle card |
| Comparison Infographic | PNG/JPG | AI-generated visual comparison (Gemini image) |
---
## Battle Card Sections
The generated HTML battle card includes:
1. **Header** - Competitor name, last updated date
2. **Quick Stats** - 5-6 one-liner facts
3. **At a Glance** - Three columns: We Win | They Win | Toss-up
4. **Feature Comparison** - Table with checkmarks
5. **Their Strengths** - Red indicators (be honest!)
6. **Their Weaknesses** - Green indicators (opportunities)
7. **Objection Handling** - Top 5 with quick responses
8. **Killer Questions** - Questions to ask prospects
9. **Landmines** - Traps to set in competitive deals
---
## ADK Features Demonstrated
| Feature | Usage |
|---------|-------|
| **SequentialAgent** | 7-stage pipeline orchestration |
| **google_search** | Real-time competitor research |
| **Custom Tools** | HTML battle card, AI-generated infographics |
| **Image Generation** | Gemini image model for comparison visuals |
| **Artifacts** | Saving battle cards per session |
| **State Management** | Passing research between stages via `output_key` |
| **Coordinator Pattern** | Root agent routes to pipeline |
## Models Used
| Agent | Model | Why |
|-------|-------|-----|
| CompetitorResearch | `gemini-3-flash-preview` | Fast web search |
| ProductFeature | `gemini-3-flash-preview` | Fast web search |
| PositioningAnalyzer | `gemini-3-pro-preview` | Strategic analysis |
| SWOT | `gemini-3-pro-preview` | Deep synthesis |
| ObjectionHandler | `gemini-3-pro-preview` | Script quality |
| BattleCardGenerator | `gemini-3-flash-preview` | HTML generation |
| ComparisonChart Agent | `gemini-3-flash-preview` | Orchestration |
| Comparison Tool | `gemini-3-pro-image-preview` | Image generation |
---
## Learn More
- [Google ADK Documentation](https://google.github.io/adk-docs/)
- [Multi-Agent Patterns in ADK](https://developers.googleblog.com/developers-guide-to-multi-agent-patterns-in-adk/)
- [Gemini API](https://ai.google.dev/gemini-api/docs)

View File

@@ -0,0 +1,6 @@
"""AI Battle Card Agent - Multi-Agent Pipeline for Competitive Sales Intelligence"""
from .agent import root_agent
__all__ = ["root_agent"]

View File

@@ -0,0 +1,441 @@
from google.adk.agents import LlmAgent, SequentialAgent
from google.adk.tools import google_search
from .tools import generate_battle_card_html, generate_comparison_chart
# ============================================================================
# Stage 1: Competitor Research Agent
# ============================================================================
competitor_research_agent = LlmAgent(
name="CompetitorResearchAgent",
model="gemini-3-flash-preview",
description="Researches competitor company information using web search",
instruction="""
You are a competitive intelligence analyst researching a competitor company.
The user will specify:
- **Competitor**: The company to research (name or URL)
- **Your Product**: The product you're selling against them
Use google_search to gather comprehensive competitor intelligence:
**RESEARCH THESE AREAS:**
1. **Company Overview**
- Founded when, HQ location, company size
- Funding history and investors
- Key leadership and executives
2. **Target Market**
- Who are their ideal customers?
- What industries do they focus on?
- Company size they target (SMB, Mid-market, Enterprise)
3. **Products & Pricing**
- Main product offerings
- Pricing tiers and models
- Free trial or freemium options
4. **Recent News**
- Product launches
- Acquisitions or partnerships
- Leadership changes
5. **Customer Sentiment**
- Search G2, Capterra, TrustRadius reviews
- Common complaints and praise
- NPS or satisfaction scores if available
Be thorough and cite specific sources where possible.
""",
tools=[google_search],
output_key="competitor_profile",
)
# ============================================================================
# Stage 2: Product Feature Agent
# ============================================================================
product_feature_agent = LlmAgent(
name="ProductFeatureAgent",
model="gemini-3-flash-preview",
description="Analyzes competitor product features and capabilities",
instruction="""
You are a product analyst comparing competitor features.
COMPETITOR PROFILE:
{competitor_profile}
Use google_search to deeply analyze their product capabilities:
**ANALYZE THESE AREAS:**
1. **Core Features**
- Main functionality and capabilities
- Unique features they promote
- What problems they solve
2. **Integrations & Ecosystem**
- Native integrations
- API availability
- Marketplace/app ecosystem
3. **Technical Architecture**
- Cloud vs. on-premise options
- Mobile apps
- Security certifications (SOC2, GDPR, etc.)
4. **Pricing Details**
- Price per seat/user
- What's included in each tier
- Add-ons and hidden costs
- Contract requirements
5. **Limitations**
- Feature gaps mentioned in reviews
- Scalability concerns
- Known technical issues
Create a detailed feature inventory for comparison.
""",
tools=[google_search],
output_key="feature_analysis",
)
# ============================================================================
# Stage 3: Positioning Analyzer Agent
# ============================================================================
positioning_analyzer_agent = LlmAgent(
name="PositioningAnalyzer",
model="gemini-3-pro-preview",
description="Analyzes competitor positioning and messaging",
instruction="""
You are a marketing strategist analyzing competitor positioning.
COMPETITOR PROFILE:
{competitor_profile}
FEATURE ANALYSIS:
{feature_analysis}
Use google_search to uncover their positioning strategy:
**ANALYZE THESE AREAS:**
1. **Messaging & Taglines**
- Their homepage headline
- Key value propositions
- How they describe themselves
2. **Target Personas**
- Who do they market to?
- Job titles mentioned in marketing
- Use cases they highlight
3. **Competitive Positioning**
- How do THEY position against YOUR product?
- Comparison pages they have
- Claims they make about competitors
4. **Analyst Coverage**
- Gartner Magic Quadrant position
- Forrester Wave placement
- G2 Grid position
5. **Social Proof**
- Customer logos they showcase
- Case studies and testimonials
- Awards and recognition
Identify messaging we can counter or leverage.
""",
tools=[google_search],
output_key="positioning_intel",
)
# ============================================================================
# Stage 4: Strengths & Weaknesses Agent
# ============================================================================
swot_agent = LlmAgent(
name="StrengthsWeaknessesAgent",
model="gemini-3-pro-preview",
description="Synthesizes SWOT analysis from research",
instruction="""
You are a competitive strategist creating a SWOT analysis.
COMPETITOR PROFILE:
{competitor_profile}
FEATURE ANALYSIS:
{feature_analysis}
POSITIONING INTEL:
{positioning_intel}
**CREATE A BRUTALLY HONEST SWOT ANALYSIS:**
## Their Strengths (Where They Beat Us)
- List 5 genuine strengths
- Include evidence from reviews/market position
- Be honest about where they're better
## Their Weaknesses (Where We Beat Them)
- List 5 genuine weaknesses
- Cite specific complaints from reviews
- Identify feature gaps
## Our Advantages
- Where does OUR product win?
- What do customers love about us vs. them?
- Technical or pricing advantages
## Competitive Landmines
- Questions to ask prospects that expose their weaknesses
- Topics to bring up that favor us
- Traps to set in competitive deals
Be strategic but honest. Sales reps lose credibility if we overstate our advantages.
""",
output_key="swot_analysis",
)
# ============================================================================
# Stage 5: Objection Handler Agent
# ============================================================================
objection_handler_agent = LlmAgent(
name="ObjectionHandlerAgent",
model="gemini-3-pro-preview",
description="Creates objection handling scripts",
instruction="""
You are a sales enablement expert creating objection handling scripts.
COMPETITOR PROFILE:
{competitor_profile}
SWOT ANALYSIS:
{swot_analysis}
**CREATE OBJECTION HANDLING SCRIPTS:**
For each objection, provide:
1. **The Objection**: What the prospect says
2. **Why They Say It**: The underlying concern
3. **Your Response**: A scripted, confident response
4. **Proof Points**: Evidence to support your response
**COMMON OBJECTIONS TO ADDRESS:**
1. "We're already using [Competitor]"
2. "[Competitor] is the market leader"
3. "[Competitor] has more features"
4. "[Competitor] is cheaper"
5. "Our team already knows [Competitor]"
6. "[Competitor] integrates with our stack"
7. "We've heard [Competitor] has better support"
8. "[Competitor] is more secure/compliant"
9. "All the analysts recommend [Competitor]"
10. "We just renewed with [Competitor]"
**ALSO INCLUDE:**
## Killer Questions
Questions that expose competitor weaknesses when asked to prospects.
## Trap-Setting Phrases
Things to say early in the sales cycle that position us favorably for later.
Make responses conversational and confident, not defensive.
""",
output_key="objection_scripts",
)
# ============================================================================
# Stage 6: Battle Card Generator Agent
# ============================================================================
battle_card_generator_agent = LlmAgent(
name="BattleCardGenerator",
model="gemini-3-flash-preview",
description="Generates professional HTML battle card",
instruction="""
You create professional sales battle cards.
COMPETITOR PROFILE:
{competitor_profile}
FEATURE ANALYSIS:
{feature_analysis}
SWOT ANALYSIS:
{swot_analysis}
OBJECTION SCRIPTS:
{objection_scripts}
Use the generate_battle_card_html tool to create a professional battle card.
**PREPARE THIS DATA FOR THE TOOL:**
Compile all the research into a structured format:
1. **Quick Stats** (1-liner facts)
2. **Positioning Summary** (how to position against them)
3. **Feature Comparison** (key features, us vs. them)
4. **Their Strengths** (be honest)
5. **Their Weaknesses** (where we win)
6. **Top Objections & Responses** (quick reference)
7. **Killer Questions** (to ask prospects)
8. **Landmines** (traps to set)
Pass this compiled data to generate_battle_card_html.
The tool will create a sales-friendly HTML battle card that reps can use during calls.
""",
tools=[generate_battle_card_html],
output_key="battle_card_result",
)
# ============================================================================
# Stage 7: Comparison Chart Agent
# ============================================================================
comparison_chart_agent = LlmAgent(
name="ComparisonChartAgent",
model="gemini-3-flash-preview",
description="Creates visual comparison infographic using AI image generation",
instruction="""
You create visual comparison infographics for sales teams using AI image generation.
COMPETITOR PROFILE:
{competitor_profile}
FEATURE ANALYSIS:
{feature_analysis}
SWOT ANALYSIS:
{swot_analysis}
Use the generate_comparison_chart tool to create a visual comparison infographic.
**PREPARE COMPARISON DATA:**
Create a comprehensive comparison summary including:
1. **Overall Verdict** - Who wins overall and why
2. **Feature Scores** - List 8-10 key features with ratings:
- Feature name
- Their score (1-10)
- Our score (1-10)
- Winner indicator
3. **Key Differentiators** - Top 3 areas where we clearly win
4. **Watch Areas** - Where they have advantage
5. **Verdict Summary** - One-line recommendation
Example comparison_data format:
```
OVERALL: HubSpot leads 7-3 over Salesforce
FEATURE COMPARISON:
- Ease of Use: Them 6/10, Us 9/10 ✓
- Enterprise Features: Them 9/10, Us 7/10 ✗
- Pricing Value: Them 4/10, Us 8/10 ✓
- Integrations: Them 8/10, Us 8/10 =
- Support Quality: Them 6/10, Us 8/10 ✓
KEY WINS: Ease of use, Pricing, Support
THEIR ADVANTAGE: Enterprise features, Brand recognition
VERDICT: Recommend HubSpot for SMB/Mid-market deals
```
Pass this to generate_comparison_chart with:
- competitor_name: The competitor's name
- your_product_name: Your product's name
- comparison_data: The full comparison summary above
The tool uses Gemini's image generation to create a professional infographic.
""",
tools=[generate_comparison_chart],
output_key="chart_result",
)
# ============================================================================
# Battle Card Pipeline (SequentialAgent)
# ============================================================================
battle_card_pipeline = SequentialAgent(
name="BattleCardPipeline",
description="Complete battle card pipeline: Research → Features → Positioning → SWOT → Objections → Battle Card → Chart",
sub_agents=[
competitor_research_agent,
product_feature_agent,
positioning_analyzer_agent,
swot_agent,
objection_handler_agent,
battle_card_generator_agent,
comparison_chart_agent,
],
)
# ============================================================================
# Root Agent (Coordinator)
# ============================================================================
root_agent = LlmAgent(
name="BattleCardAnalyst",
model="gemini-3-flash-preview",
description="AI-powered competitive intelligence analyst for sales teams",
instruction="""
You are a competitive intelligence analyst helping sales teams win against competitors.
**WHAT YOU NEED FROM THE USER:**
1. **Competitor**: The company to analyze (name or URL)
2. **Your Product**: What you're selling (so we can compare)
**EXAMPLES OF VALID REQUESTS:**
- "Create a battle card for Salesforce. We sell HubSpot."
- "Battle card against Slack - we're selling Microsoft Teams"
- "Competitive analysis of Zendesk vs our product Freshdesk"
- "Help me compete against Monday.com, I sell Asana"
**WHEN USER PROVIDES BOTH:**
→ transfer_to_agent to "BattleCardPipeline"
The pipeline will:
1. Research the competitor thoroughly
2. Analyze their product features
3. Uncover their positioning strategy
4. Create SWOT analysis
5. Generate objection handling scripts
6. Create a professional battle card
7. Generate a visual comparison chart
**IF USER ONLY PROVIDES COMPETITOR:**
Ask them: "What product are you selling against [Competitor]?"
**FOR GENERAL QUESTIONS:**
Answer questions about competitive selling, battle cards, or how you can help.
After analysis, summarize key findings and mention the generated artifacts.
""",
sub_agents=[battle_card_pipeline],
)
__all__ = ["root_agent"]

View File

@@ -0,0 +1,3 @@
google-adk>=1.0.0
google-genai>=1.0.0

View File

@@ -0,0 +1,209 @@
"""Custom tools for the Battle Card Pipeline.
Provides HTML battle card generation and comparison chart creation.
"""
import logging
from pathlib import Path
from datetime import datetime
from google.adk.tools import ToolContext
from google.genai import types, Client
logger = logging.getLogger("BattleCardPipeline")
# Create outputs directory for generated files
OUTPUTS_DIR = Path(__file__).parent / "outputs"
OUTPUTS_DIR.mkdir(exist_ok=True)
async def generate_battle_card_html(
battle_card_data: str,
tool_context: ToolContext
) -> dict:
"""Generate a professional HTML battle card for sales teams.
Args:
battle_card_data: Compiled competitive intelligence data
tool_context: ADK tool context for artifact saving
Returns:
dict with status and artifact info
"""
current_date = datetime.now().strftime("%B %d, %Y")
prompt = f"""Generate a professional sales battle card in HTML format.
**DATE: {current_date}**
This is a competitive battle card for sales reps to use during deals.
Style it for SALES TEAMS with:
- Clean, scannable design (reps glance at this during calls)
- Color coding: GREEN for our advantages, RED for competitor strengths
- Collapsible sections for detailed content
- Quick-reference format at the top
- Dark blue (#1e3a5f) and orange (#f97316) color scheme
- Print-friendly layout
COMPETITIVE INTELLIGENCE DATA:
{battle_card_data}
**REQUIRED SECTIONS:**
1. **Header** - Competitor name, logo placeholder, last updated date
2. **Quick Stats** - 5-6 one-liner facts about the competitor
3. **At a Glance** - 3 columns: They Win | We Win | Toss-up
4. **Feature Comparison** - Table with checkmarks/X marks
5. **Positioning** - How to position against them (2-3 sentences)
6. **Their Strengths** - Honest list with red indicators
7. **Their Weaknesses** - List with green indicators (our opportunities)
8. **Objection Handling** - Top 5 objections with quick responses
9. **Killer Questions** - Questions to ask prospects
10. **Landmines** - Traps to set in competitive deals
Make it visually impressive but FAST TO SCAN. Sales reps have seconds, not minutes.
Generate complete, valid HTML with embedded CSS and JavaScript for collapsible sections."""
try:
client = Client()
response = await client.aio.models.generate_content(
model="gemini-3-flash-preview",
contents=prompt,
)
html_content = response.text
# Clean up markdown wrapping if present
if "```html" in html_content:
start = html_content.find("```html") + 7
end = html_content.rfind("```")
html_content = html_content[start:end].strip()
elif "```" in html_content:
start = html_content.find("```") + 3
end = html_content.rfind("```")
html_content = html_content[start:end].strip()
# Save as ADK artifact
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
artifact_name = f"battle_card_{timestamp}.html"
html_artifact = types.Part.from_bytes(
data=html_content.encode('utf-8'),
mime_type="text/html"
)
version = await tool_context.save_artifact(filename=artifact_name, artifact=html_artifact)
logger.info(f"Saved battle card artifact: {artifact_name} (version {version})")
# Also save to outputs folder
filepath = OUTPUTS_DIR / artifact_name
filepath.write_text(html_content, encoding='utf-8')
return {
"status": "success",
"message": f"Battle card saved as '{artifact_name}' - view in Artifacts tab",
"artifact": artifact_name,
"version": version
}
except Exception as e:
logger.error(f"Error generating battle card: {e}")
return {"status": "error", "message": str(e)}
async def generate_comparison_chart(
competitor_name: str,
your_product_name: str,
comparison_data: str,
tool_context: ToolContext
) -> dict:
"""Generate a visual comparison infographic using Gemini image generation.
Args:
competitor_name: Name of the competitor
your_product_name: Name of your product
comparison_data: Feature comparison data with scores and highlights
tool_context: ADK tool context for artifact saving
Returns:
dict with status and artifact info
"""
prompt = f"""Create a professional competitive comparison infographic.
**COMPARISON: {your_product_name} vs {competitor_name}**
Style: Clean, modern, sales-ready infographic
Colors:
- Green (#22c55e) for {your_product_name} (your product)
- Red (#ef4444) for {competitor_name} (competitor)
- Dark blue (#1e3a5f) for headers and text
- White background
**DATA TO VISUALIZE:**
{comparison_data}
**INFOGRAPHIC LAYOUT:**
1. **Header** - "{your_product_name} vs {competitor_name}" prominently at top
2. **Score Overview** - Large visual showing overall winner
3. **Feature Comparison** - Side-by-side bars or ratings for each feature
4. **Key Differentiators** - Icons highlighting where {your_product_name} wins
5. **Bottom Line** - Clear verdict/recommendation badge
**DESIGN REQUIREMENTS:**
- Professional, enterprise-ready aesthetic
- Easy to read at a glance
- Color-coded clearly (green = us, red = them)
- Include checkmarks for wins, X marks for losses
- Make it look like a Gartner or Forrester comparison graphic
- Data-rich but not cluttered
Generate a visually compelling infographic that sales reps can share with prospects."""
try:
client = Client()
response = await client.aio.models.generate_content(
model="gemini-3-pro-image-preview",
contents=prompt,
config=types.GenerateContentConfig(
response_modalities=["TEXT", "IMAGE"]
)
)
# Look for image in response
for part in response.candidates[0].content.parts:
if part.inline_data and part.inline_data.mime_type.startswith("image/"):
image_bytes = part.inline_data.data
mime_type = part.inline_data.mime_type
# Save as ADK artifact
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
ext = "png" if "png" in mime_type else "jpg"
artifact_name = f"comparison_infographic_{timestamp}.{ext}"
image_artifact = types.Part.from_bytes(data=image_bytes, mime_type=mime_type)
version = await tool_context.save_artifact(filename=artifact_name, artifact=image_artifact)
logger.info(f"Saved comparison infographic: {artifact_name} (version {version})")
# Also save to outputs folder
filepath = OUTPUTS_DIR / artifact_name
filepath.write_bytes(image_bytes)
return {
"status": "success",
"message": f"Comparison infographic saved as '{artifact_name}' - view in Artifacts tab",
"artifact": artifact_name,
"version": version,
"comparison": f"{your_product_name} vs {competitor_name}"
}
return {
"status": "partial",
"message": "Image generation not available, text description provided",
"description": response.text if response.text else "No content generated"
}
except Exception as e:
logger.error(f"Error generating comparison infographic: {e}")
return {"status": "error", "message": str(e)}