Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.mavera.io/llms.txt

Use this file to discover all available pages before exploring further.

Scenario

G2 has thousands of reviews about your competitors — what their users love, hate, and wish for. This is competitive intelligence gold. You pull competitor reviews from G2, aggregate the sentiment data, and send it to Mave Agent for analysis. The output identifies positioning opportunities: where competitors are weak and you can win. Flow: G2 GET /survey-responses (competitor product) → Aggregate love/hate/recommend → Mavera POST /mave/chat → Positioning opportunities

Architecture

Code

import os, requests, time
from collections import defaultdict

G2 = os.environ["G2_API_KEY"]
MV = os.environ["MAVERA_API_KEY"]
G2_BASE = "https://data.g2.com/api/v1"
G2_H = {"Authorization": f"Token token={G2}", "Content-Type": "application/vnd.api+json"}
MV_H = {"Authorization": f"Bearer {MV}", "Content-Type": "application/json"}

COMPETITORS = [
    {"name": "CompetitorA", "product_id": "competitor-a-product-id"},
    {"name": "CompetitorB", "product_id": "competitor-b-product-id"},
]

all_intel = []
for comp in COMPETITORS:
    reviews = []
    page = 1
    while len(reviews) < 100:
        r = requests.get(f"{G2_BASE}/survey-responses",
            headers=G2_H,
            params={
                "filter[product_id]": comp["product_id"],
                "page[size]": 50,
                "page[number]": page,
            })
        if r.status_code == 429:
            time.sleep(1)
            continue
        r.raise_for_status()
        data = r.json().get("data", [])
        if not data:
            break
        reviews.extend(data)
        page += 1
        time.sleep(0.1)

    loves, hates, recs = [], [], []
    stars = []
    for rev in reviews:
        attrs = rev.get("attributes", {})
        stars.append(attrs.get("star_rating", 0))
        for key, val in attrs.get("comment_answers", {}).items():
            text = val if isinstance(val, str) else val.get("text", "")
            k = key.lower()
            if "love" in k or "best" in k:
                loves.append(text[:200])
            elif "dislike" in k or "hate" in k:
                hates.append(text[:200])
            elif "recommend" in k:
                recs.append(text[:200])

    avg = sum(stars) / len(stars) if stars else 0
    all_intel.append({
        "name": comp["name"],
        "review_count": len(reviews),
        "avg_rating": round(avg, 1),
        "top_loves": loves[:10],
        "top_hates": hates[:10],
        "recommendations": recs[:5],
    })

# Build analysis prompt
intel_block = ""
for ci in all_intel:
    intel_block += f"\n## {ci['name']} ({ci['review_count']} reviews, avg {ci['avg_rating']}/5)\n"
    intel_block += f"LOVE:\n" + "\n".join(f"- {l}" for l in ci["top_loves"][:5]) + "\n"
    intel_block += f"HATE:\n" + "\n".join(f"- {h}" for h in ci["top_hates"][:5]) + "\n"
    intel_block += f"RECOMMENDATIONS:\n" + "\n".join(f"- {r}" for r in ci["recommendations"][:3]) + "\n"

analysis = requests.post("https://app.mavera.io/api/v1/mave/chat",
    headers=MV_H,
    json={"message": f"""Analyze these G2 competitor reviews and identify positioning opportunities for us.

{intel_block}

Produce:
1. Each competitor's core strengths (where they're hard to beat)
2. Each competitor's vulnerabilities (where their users are frustrated)
3. Positioning opportunities (where we can win based on their weaknesses)
4. Messaging angles (specific claims we can make that competitors can't)
5. Feature gaps (what their users want that we could build/highlight)
6. Risk areas (where competitors are improving — watch list)"""}).json()

print("=== Competitive Intelligence from G2 ===")
print(analysis.get("content", "")[:2000])

Example Output

=== Competitive Intelligence from G2 ===

## CompetitorA (87 reviews, avg 4.1/5)
### Strengths (hard to beat)
- Exceptional onboarding experience (mentioned 34x)
- Strong Slack community for support

### Vulnerabilities (user frustration)
- "Reporting is stuck in 2019" — no custom dashboards (mentioned 19x)
- "API is an afterthought" — limited endpoints, poor docs (12x)
- No SSO on mid-tier plans (8x)

## Positioning Opportunities
1. **Lead with reporting**: CompetitorA's #1 complaint is our strength. Claim: "Custom dashboards in 5 minutes, not 5 sprints."
2. **Developer-first messaging**: Their API frustration creates an opening. Claim: "Full REST API with 200+ endpoints. Documentation that engineers actually like."
3. **Security as differentiator**: SSO gap at mid-tier is a compliance dealbreaker. Claim: "SSO included on every plan."

## Risk Watch
- CompetitorA recently hired a Head of API — expect improvements in 6-12 months.

Error Handling

G2 product IDs aren’t always obvious. Find them via GET /products?filter[name]=CompetitorName or from the G2 product page URL slug.
You can only access reviews for products in your G2 category. Cross-category competitor reviews require a G2 Market Intelligence subscription.