APM

>Agent Skill

@microsoft/competitive-intelligence

skilldata

Analyzes opportunity data and activity notes to generate competitive intelligence including win/loss rates by competitor, patterns, and rep-ready battlecard talking points. Use when user asks "how are we doing against [competitor]", "competitive analysis", "competitor win rate", "battlecard for [competitor]", "competitive landscape", "why are we losing to [competitor]", or "competitor intelligence".

data
apm::install
$apm install @microsoft/competitive-intelligence
apm::skill.md
---
name: competitive-intelligence
description: Analyzes opportunity data and activity notes to generate competitive intelligence including win/loss rates by competitor, patterns, and rep-ready battlecard talking points. Use when user asks "how are we doing against [competitor]", "competitive analysis", "competitor win rate", "battlecard for [competitor]", "competitive landscape", "why are we losing to [competitor]", or "competitor intelligence".
metadata:
  author: Dataverse
  version: 1.0.0
  category: sales-analytics
---

# Competitive Intelligence

Competitive insights are often locked in deal notes, lost opportunity records, and anecdotal rep knowledge. This skill mines Dataverse to surface structured competitive intelligence: which competitors appear most frequently, where deals are being lost to them, what deal patterns correlate with wins vs losses, and what talking points reps should use. This is the Dataverse-internal equivalent of competitive research — drawing from closed deal history rather than external sources.

## Instructions

### Step 1: Identify Competitor or Analysis Scope
Accept input from the user:
- **Specific competitor name** (to analyze one rival)
- **All competitors** (for a full competitive landscape view)
- **Time range** (default: last 12 months)
- **Segment filter** (by owner, territory, deal size, or industry)

Calculate date range for analysis: `createdon >= '[start_date]'`

#### Step 2: Identify Lost Deals with Competitor Information

**Important:** The `opportunity` entity does not have a direct `competitorid` field — the opportunity-to-competitor relationship is many-to-many (`opportunitycompetitors_association`). When an opportunity is closed, Dynamics 365 creates an `opportunityclose` activity record which **does** have a direct `competitorid` lookup. Use `opportunityclose` for structured competitor data on closed deals.

**Query closed-lost opportunityclose records:**
```
SELECT oc.opportunityid, oc.competitorid, oc.description, oc.createdon,
       oc.actualrevenue
FROM opportunityclose oc
WHERE oc.statecode = 1
AND oc.createdon >= '[start_date]'
ORDER BY oc.createdon DESC
```

Then join to the `opportunity` table by `opportunityid` to get deal details:
```
SELECT opportunityid, name, estimatedvalue, actualclosedate, salesstage,
       description, ownerid, customerid, closeprobability
FROM opportunity
WHERE statecode = 2
AND actualclosedate >= '[start_date]'
ORDER BY actualclosedate DESC
```

**Note:** If `opportunityclose` is not populated (competitor not selected at close), fall back to text pattern matching in opportunity description fields as described in Step 3.

**Fetch competitor names if competitor table is used:**
```
SELECT competitorid, name, websiteurl, overview, strengths, weaknesses,
       opportunitiescomments, threatscomments
FROM competitor
```

#### Step 3: Mine Opportunity Descriptions for Competitor Mentions
For opportunities without structured competitor fields, search text fields for competitor names:
```
SELECT opportunityid, name, estimatedvalue, statecode, actualclosedate,
       salesstage, description, currentsituation, customerneed, customerpainpoints
FROM opportunity
WHERE statecode IN (1, 2)
AND actualclosedate >= '[start_date]'
```

Search description, currentsituation, and customerpainpoints for known competitor keywords or names provided by the user. Categorize each mention as:
- Win with competitor present (statecode = 1)
- Loss to competitor (statecode = 2)

#### Step 4: Pull Competitor Annotations from Activities
Search activity notes for competitor mentions:
```
SELECT annotationid, notetext, subject, objectid, createdon
FROM annotation
WHERE createdon >= '[start_date]'
```

Search notetext for competitor name patterns. Extract:
- Context of mention (evaluation, objection, price comparison)
- Outcome (linked opportunity won or lost)
- Frequency of mention

Also search phonecall and appointment descriptions:
```
SELECT activityid, subject, description, regardingobjectid, statecode
FROM phonecall
WHERE createdon >= '[start_date]'
```

#### Step 5: Calculate Win/Loss Rates by Competitor

From Step 2, you now have two lists of opportunityids: `[lost_opportunityids]` (from `opportunityclose` where `competitorid` matches and deal was lost) and `[won_opportunityids]` (from a separate `opportunityclose` query for won deals). Run an additional query to capture won opportunityclose records for this competitor:

```
SELECT oc.opportunityid, oc.createdon, oc.actualrevenue
FROM opportunityclose oc
WHERE oc.competitorid = '[competitorid]'
AND oc.createdon >= '[start_date]'
```

Cross-reference these opportunityids against `opportunity.statecode` to split into won vs lost buckets. Then aggregate:

**Won opportunities where competitor was present:**
```
SELECT COUNT(opportunityid) as won_count, SUM(estimatedvalue) as won_value
FROM opportunity
WHERE statecode = 1
AND actualclosedate >= '[start_date]'
```
Filter results programmatically to only those opportunityids found in the won opportunityclose results above.

**Lost opportunities to competitor:**
```
SELECT COUNT(opportunityid) as lost_count, SUM(estimatedvalue) as lost_value
FROM opportunity
WHERE statecode = 2
AND actualclosedate >= '[start_date]'
```
Filter results programmatically to only those opportunityids in `[lost_opportunityids]` from Step 2.

Calculate:
- **Win rate** = won_count / (won_count + lost_count) × 100
- **Average deal size (wins)** vs **average deal size (losses)**
- **Average sales cycle (wins)** vs **average sales cycle (losses)**

#### Step 6: Identify Deal Patterns

For won deals with competitor present vs lost deals to competitor, compare:

**Deal size distribution:**
```
SELECT COUNT(opportunityid) as count, SUM(estimatedvalue) as total_value
FROM opportunity
WHERE statecode = 1
AND estimatedvalue < 25000
```
Filter results programmatically to only those opportunityids in `[won_opportunityids]`. Repeat for medium ($25K-$100K) and enterprise (>$100K) segments; run equivalent queries for `statecode = 2` filtered to `[lost_opportunityids]`.

**Industry distribution:**
```
SELECT account.industrycode, COUNT(opportunity.opportunityid) as count
FROM opportunity
JOIN account ON opportunity.customerid = account.accountid
WHERE opportunity.statecode = 2
AND opportunity.actualclosedate >= '[start_date]'
GROUP BY account.industrycode
```
Filter results programmatically to only those opportunityids in `[lost_opportunityids]` from Step 2.

**Stage at loss:**
```
SELECT salesstage, COUNT(opportunityid) as lost_count, SUM(estimatedvalue) as lost_value
FROM opportunity
WHERE statecode = 2
AND actualclosedate >= '[start_date]'
GROUP BY salesstage
```
Filter results programmatically to only those opportunityids in `[lost_opportunityids]` from Step 2.

#### Step 7: Identify Common Objections and Pain Points
From text mining in Step 4, categorize recurring themes from notes and activity descriptions when competitor is mentioned:
- **Price objections:** Look for "cheaper", "lower cost", "price", "pricing"
- **Feature gaps:** Look for "missing", "doesn't support", "can't do", "limitation"
- **Existing relationship:** Look for "incumbent", "already using", "switching cost", "prefer"
- **Brand recognition:** Look for "heard of", "well-known", "trusted", "market leader"
- **Implementation concerns:** Look for "complex", "timeline", "integration", "support"

Count frequency of each theme across deal notes.

#### Step 8: Extract Win Patterns
For won deals where this competitor was present, identify common factors:

**Qualification strength in wins:**
```
SELECT budgetstatus, decisionmaker, need, purchasetimeframe, purchaseprocess,
       COUNT(opportunityid) as count
FROM opportunity
WHERE statecode = 1
AND actualclosedate >= '[start_date]'
GROUP BY budgetstatus, decisionmaker, need, purchasetimeframe, purchaseprocess
```
Filter results programmatically to only those opportunityids in `[won_opportunityids]` from Step 5.

Note which BANT patterns appear most often in wins — these inform the competitive playbook.

**Activity volume in wins vs losses:**
Count total activities per opportunity for wins and losses separately using activitypointer to identify engagement differences.

#### Step 9: Generate Competitive Intelligence Report

```
COMPETITIVE INTELLIGENCE REPORT
Competitor: [Competitor Name]
Period: [Start Date] – [End Date]
Generated: [Today's Date]
═══════════════════════════════════════════════════════════

EXECUTIVE SUMMARY
───────────────────────────────────────────────────────────
Deals Analyzed: [n won] wins / [n lost] losses
Win Rate (competitive): [n]%
Revenue Won (competitive): $[value]
Revenue Lost to Competitor: $[value]

COMPETITIVE PERFORMANCE BY DEAL SIZE
───────────────────────────────────────────────────────────
Small (<$25K):     Win rate [n]%  | [n] won, [n] lost
Medium ($25K-$100K): Win rate [n]% | [n] won, [n] lost
Enterprise (>$100K): Win rate [n]% | [n] won, [n] lost

WHERE WE LOSE
───────────────────────────────────────────────────────────
Most losses occur at: [Stage] stage ([n]% of losses)
Top industries lost: [Industry 1] ([n] deals), [Industry 2] ([n] deals)
Average deal size lost: $[value] vs average deal size won: $[value]

COMMON OBJECTIONS (from deal notes)
───────────────────────────────────────────────────────────
1. Price/Cost concerns — mentioned in [n]% of lost deals
2. [Feature gap] — mentioned in [n]% of lost deals
3. [Incumbent relationship] — mentioned in [n]% of lost deals

WIN PATTERNS (what works in competitive deals)
───────────────────────────────────────────────────────────
✓ Economic buyer engaged: [n]% of wins vs [n]% of losses
✓ Budget confirmed before Propose: [n]% of wins vs [n]% of losses
✓ Higher activity volume: [n] avg activities (wins) vs [n] (losses)
✓ Shorter sales cycle: [n] avg days (wins) vs [n] avg days (losses)

BATTLECARD: [COMPETITOR NAME]
───────────────────────────────────────────────────────────

Their strengths (from deal notes):
• [Strength extracted from notes]
• [Strength extracted from notes]

Common objections and responses:
• "They're cheaper" → [Response based on win patterns]
• "[Feature gap]" → [Response/workaround]
• "We already know them" → [Response focused on differentiation]

Where we win:
• [Scenario 1 — e.g., enterprise deals with complex integration needs]
• [Scenario 2 — e.g., accounts with active support issues with competitor]
• [Scenario 3 — e.g., deals where economic buyer is engaged early]

Where to be careful:
• [Risk area 1 — e.g., SMB price-sensitive deals]
• [Risk area 2 — e.g., industries where competitor has strong presence]

RECOMMENDED ACTIONS
───────────────────────────────────────────────────────────
1. [Specific action based on loss patterns]
2. [Coaching recommendation for reps]
3. [Process change to improve win rate]
═══════════════════════════════════════════════════════════
```

### Output Format
Deliver a two-part output:
1. **Intelligence report** — quantitative win/loss analysis with patterns
2. **Battlecard** — rep-ready talking points, objection responses, and when-to-use guidance

### Example Interaction

**User Input:**
"Show me competitive intelligence on Acme Corp for the last 6 months."

**Skill Output:**
```
COMPETITIVE INTELLIGENCE REPORT
Competitor: Acme Corp | Period: Sep 2025 – Mar 2026
═══════════════════════════════════════════════════════════

EXECUTIVE SUMMARY
Win Rate vs Acme Corp: 38% (vs 61% overall win rate)
Revenue Won: $420,000 | Revenue Lost to Acme: $680,000

COMPETITIVE PERFORMANCE BY DEAL SIZE
Small (<$25K): 55% win rate — strongest segment
Medium ($25K-$100K): 32% win rate — significant gap
Enterprise (>$100K): 18% win rate — critical weakness

WHERE WE LOSE
Most losses at: Propose stage (67% of losses)
Top industries: Financial Services (5 deals), Healthcare (3 deals)

COMMON OBJECTIONS
1. Price — mentioned in 71% of lost deals
2. Existing integration with their platform — 43% of lost deals
3. Acme's brand recognition in FSI — 29% of lost deals

WIN PATTERNS
✓ Economic buyer engaged early: 78% of wins vs 22% of losses
✓ POC completed before proposal: 64% of wins vs 11% of losses

BATTLECARD: ACME CORP
"They're cheaper" → "Our TCO over 3 years is [X]% lower due to..."
"We use their platform" → "Our API integrates in <2 hours — here's a reference customer..."
```

### Dataverse Tables Used
| Table | Purpose |
|-------|---------|
| `opportunity` | Win/loss records and deal details |
| `opportunityclose` | Structured competitor data on closed deals (has direct `competitorid` lookup) |
| `competitor` | Structured competitor profiles |
| `account` | Industry and firmographic context |
| `activitypointer` | Activity volume comparison |
| `annotation` | Mining notes for competitive mentions |
| `phonecall` | Call descriptions for competitor mentions |

### Key Fields Reference
**opportunity:**
- `statecode` (STATE) - Open(0), Won(1), Lost(2)
- `description` (MULTILINE TEXT) - General opportunity notes
- `currentsituation` (MULTILINE TEXT) - Customer's current environment
- `actualclosedate` (DATE) - When deal was closed
- `salesstage` (CHOICE) - Stage at close
- Note: `opportunity` has no direct `competitorid` field — the relationship is many-to-many via `opportunitycompetitors_association`. Use `opportunityclose.competitorid` for closed deal competitor data.

**opportunityclose:**
- `opportunityid` (LOOKUP) - Links to the closed opportunity
- `competitorid` (LOOKUP) - Competitor selected at close (direct lookup, use this for competitive analysis)
- `description` (MULTILINE TEXT) - Close reason / notes entered at time of close
- `actualrevenue` (MONEY) - Final deal value at close
- `statecode` (STATE) - Activity completion state
- `createdon` (DATETIME) - When the close activity was created

**competitor:**
- `name` (NVARCHAR) - Competitor name
- `strengths` (MULTILINE TEXT) - Known strengths
- `weaknesses` (MULTILINE TEXT) - Known weaknesses
- `overview` (MULTILINE TEXT) - General description
- `opportunitiescomments` (MULTILINE TEXT) - Where we win
- `threatscomments` (MULTILINE TEXT) - Where we lose

### Configurable Parameters
- Analysis period (default: last 12 months)
- Minimum deal count threshold for statistical confidence (default: 5 deals)
- Competitor name keywords for text mining (configurable list)
- Deal size segmentation thresholds

## Examples

### Example 1: Specific Competitor Analysis

**User says:** "How are we doing against ACME Corp?"

**Actions:**
1. Search opportunityclose records for competitorid matching ACME
2. Query won and lost deals with ACME as competitor
3. Calculate win/loss rates and deal value analysis
4. Mine activity notes for competitive mentions
5. Generate battlecard talking points

**Result:**
```
COMPETITIVE ANALYSIS: ACME CORP (Last 12 Months)

HEAD-TO-HEAD RECORD:
Wins: 8 deals ($420K) | Losses: 12 deals ($680K)
Win Rate: 40% (vs 55% overall win rate)

WHERE WE LOSE:
- Price objection in 67% of losses
- Mid-market segment: 25% win rate

WHERE WE WIN:
- Enterprise deals: 62% win rate
- When technical eval involved: 71% win rate

BATTLECARD:
"They're cheaper" → "Our TCO over 3 years is 23% lower..."
"We use their platform" → "Our API integrates in <2 hours..."
```

### Example 2: Full Competitive Landscape

**User says:** "Show me the competitive landscape for Q4"

**Actions:**
1. Query all opportunityclose records with competitor data for Q4
2. Group by competitor name
3. Calculate win rates and deal values per competitor
4. Rank by frequency and threat level

**Result:**
```
Q4 COMPETITIVE LANDSCAPE

| Competitor | Encounters | Win Rate | Avg Deal |
|------------|------------|----------|----------|
| ACME Corp  | 20 deals   | 40%      | $55K     |
| Globex     | 14 deals   | 57%      | $72K     |
| Initech    | 8 deals    | 75%      | $45K     |

TOP THREAT: ACME Corp (high volume, low win rate)
STRONG AGAINST: Initech (technical differentiation)
```

### Example 3: Loss Pattern Analysis

**User says:** "Why are we losing to Globex?"

**Actions:**
1. Query lost opportunities with Globex as competitor
2. Analyze opportunity descriptions and close notes
3. Extract common patterns and objections
4. Generate actionable insights

**Result:**
```
GLOBEX LOSS ANALYSIS (8 losses, $340K)

COMMON PATTERNS:
- 75% lost at Proposal stage (late loss)
- Avg sales cycle: 45 days (vs our 38 day avg)
- 5/8 losses in Financial Services vertical

TOP OBJECTIONS (from notes):
1. "Existing Globex relationship" (3 deals)
2. "Integration concerns" (3 deals)
3. "Reference requests unfulfilled" (2 deals)

RECOMMENDATION:
- Engage technical resources earlier in Financial Services
- Build reference library for banking customers
```

## Troubleshooting

### Error: No competitor data found
**Cause:** Competitors not being recorded at deal close, or competitor table empty
**Solution:**
- Check if opportunityclose records have competitorid populated
- Fall back to text mining in opportunity descriptions
- Recommend enabling competitor tracking in close workflow

### Error: Insufficient data for analysis
**Cause:** Too few deals with specific competitor to draw conclusions
**Solution:**
- Expand time range beyond default 12 months
- Combine with related competitors for aggregate view
- Note statistical limitations in output

### Error: Win rate appears inaccurate
**Cause:** opportunityclose only captures explicit competitor selection; many deals may not have competitor recorded
**Solution:**
- Cross-reference with text mining results
- Note coverage percentage in output
- Recommend better competitor capture at deal close