Get started

How we analyze why deals are won and lost

The win-loss agent we run on Kortix — a weekly cron reads every HubSpot deal closed-won or closed-lost since the last run and posts the patterns by segment, competitor, price, and stage of death to Slack.

Written by
The OpenChatly Team
Published
May 16, 2026
Reading time
7 min read
Topics
Sales, Case Study, Enterprise

Every closed deal is a data point about why customers choose us or choose someone else, but the reason usually lives in one line of a HubSpot field, written by a rep in a hurry between calls. Read one at a time, those lines say nothing. Read across a hundred deals a quarter, they say exactly where we're strong, where a competitor is beating us, and where our own pipeline quietly falls apart.

We run a win-loss analysis agent on Kortix that reads closed deals from HubSpot every week and posts the patterns to our sales Slack channel. It only reads deal data; the single output is the Slack post. This is how we watch our own win rate.

Team
Kortix
Runs on
Weekly cron
Connected systems
HubSpot · Slack
Mode
Read-only · one Slack post per week

The problem

Close reasons and competitor mentions get logged in HubSpot because the CRM asks for them, not because anyone reads them back. A closed-lost deal gets a one-line reason and maybe a competitor field, then disappears into the pipeline history. Nobody aggregates it, so the same loss pattern — a competitor consistently winning on price in one segment, a deal category that reliably dies at the same stage — can repeat for two quarters before a sales leader notices it by gut feel in a QBR.

The common approaches don't fix this. A win-rate number on a dashboard tells you the score changed, not why. A quarterly deal-review deck is thorough but looks back three months too late to change this week's playbook. And nobody wants to be the person who reads two hundred close-reason fields by hand every Monday.

What we built

On Kortix, a weekly cron triggers an agent. It spawns a fresh session (a cloud sandbox) with read-only access to HubSpot, pulls every deal closed-won or closed-lost since the last run, and breaks the outcomes down by segment, competitor, price band, and the stage where lost deals actually die. It synthesizes the patterns into themes and concrete recommendations, and posts the summary to Slack. It writes nothing back to HubSpot.

How it works

1

Copy the setup prompt into a new session

Open your Kortix workspace, start a new session, paste this prompt and send it. The agent writes the agent file, the win-loss skill and the weekly trigger, and opens a change request for you to review. Prefer clicks? Choose Use this template instead.

Setup prompt

Set up a weekly win-loss analysis agent in this workspace.

  1. Create the agent agents/win-loss-analysis.md. Its job is to find patterns in closed HubSpot deals and post them to Slack. It may use the HubSpot connector, read-only.

  2. Create the skill skills/win-loss-patterns/SKILL.md with these rules:

    • Read every deal closed won or closed lost in the last 7 days, with closed_lost_reason and competitor read verbatim.
    • Report the win rate and the won and lost value for the window.
    • Break outcomes down by segment, by competitor, by price band from our own deal sizes, and by the stage where lost deals died.
    • Cluster close reasons into themes by meaning. Report a blank field as not recorded. Never guess.
    • Pair every theme with one concrete recommendation, and post it all to #sales.
    • Never write to HubSpot, and never contact a rep or a prospect.
  3. Add a cron trigger weekly-win-loss-review to kortix.yaml. It runs the win-loss-analysis agent every Monday at 09:00 with the prompt "Load the win-loss-patterns skill and post this week's win-loss analysis to #sales."

  4. Tell me which of these connectors are not connected yet.

  5. Open a change request with all of it. Do not merge it.

2

Connect your tools

Open Connectors in your workspace and connect your CRM with read-only access, and Slack for the post. Credentials are brokered server-side and never enter the agent's machine.

HubSpot

Reads deals closed won and lost in the lookback window.

Or useSalesforcePipedrive
Required
Gong

Adds a call quote that supports each loss theme.

Or useGoogle Drive
Optional
Slack

Posts the themes and recommendations.

Or useMicrosoft Teams
Required
3

Run it once with this prompt

Merge the change request, then start a session with the win-loss-analysis agent and send this prompt. Check the themes against what your reps tell you before you let the schedule take over.

Prompt

Run one win-loss analysis on HubSpot. Read only. Change nothing.

  1. Read every deal closed won or closed lost in the last 7 days, with closed_lost_reason and competitor.
  2. Compute the win rate and the won and lost value.
  3. Break the outcomes down by segment, competitor, price band and the stage where lost deals died.
  4. Cluster the close reasons into themes and pair each theme with one recommendation.
  5. Post it all to #sales.
4

Let the weekly schedule take over

The change request added this trigger to kortix.yaml. From now on the agent runs every Monday at 09:00, each run in a new session on its own cloud computer. To change the time, edit the cron line, or open Triggers in the workspace.

kortix.yaml
triggers:- slug: weekly-win-loss-review  name: Weekly win-loss review  on:    cron: "0 0 9 * * 1"  run:    agent: win-loss-analysis    prompt: Load the win-loss-patterns skill and post this week's win-loss analysis to #sales.
5

Keep HubSpot read-only

The agent reads closed deals and writes nothing back, not even to fill a blank close reason. It never contacts a rep or a lost prospect. The Slack post is its only output, and the sales team decides what to change in the playbook.

6

Read the weekly analysis

Each run ends with one message in #sales. This is what a run looks like in the session:

Weekly win-loss review · Mon 09:00
Load the win-loss-patterns skill and post this week's win-loss analysis to #sales.
Worked for 2m 29s
hubspot · search deals (closed)hubspot · get stage history × 19slack · post message → #sales

31 deals closed this week: 12 won and 19 lost, a 39% win rate. Most lost deals died at Proposal, and the top theme is price on the enterprise tier. Recommendation: review enterprise packaging.

Illustrative example. Your numbers depend on your closed deals.

The pattern

A weekly cron spawns a fresh session with a read-only connector into HubSpot. The breakdown rules live as a skill. The agent reads every closed deal and writes nothing but the Slack post.

Make it do more

Once it works, paste any of these into the same session.

Quarterly trend

On the first Monday of each quarter, compare win rate by segment and by competitor to the previous quarter.

Flag missing close reasons

List the lost deals this week that have no close reason, with their owners, so a manager can follow up.

Add call evidence

Once Gong is connected, add one quote from the last call of each lost deal that supports its theme.

Guardrails

The agent reads every closed deal in HubSpot, so its access is scoped and one-directional:

  • Isolation. Every run happens in its own isolated sandbox. The session is granted access only to HubSpot, and only the Slack post is written back out.
  • Scoped secrets. The HubSpot credential is encrypted in the Secrets Manager and injected into the sandbox at runtime, scoped to the agents you grant them to or the logs.
  • Read-only. The connector into HubSpot is read-only. The agent cannot change a deal's stage, close reason, competitor field, or amount; it can only report on what's already there.
  • Report only. The agent never contacts a rep, a prospect, or a lost deal. It surfaces the pattern; a human decides what to do about it.
  • Everything is code. The agent's breakdown rules, skill, and HubSpot permissions are files in the repo, versioned and changed through a reviewed change request rather than a dashboard setting.

The outcome

Closed deals rescored from HubSpot's current state
Every week
Nothing written back to any HubSpot deal
Read-only
Segment, competitor, price, and stage of death in one post
4 cuts

Win-loss reasons that used to sit unread in a HubSpot field now arrive as one weekly summary in the channel where the sales team already works, with the themes named and a recommendation attached to each. The agent only reads; the people decide what to change in the playbook.

On this page

  • The problem
  • What we built
  • How it works
  • Make it do more
  • Guardrails
  • The outcome

Run this yourself

Install this exact setup — agent, connectors, schedule, and guardrails — in a guided flow.

More use cases.

  • How we handle GDPR data-subject requests on a deadline

    Legal·July 11, 2026

  • OpenChatly

    How we keep our docs in sync with the code

    Documentation·July 5, 2026

  • OpenChatly

    How we QA every pull request automatically

    QA·July 5, 2026

Own your AI.Start today, in our cloud.

Start for free

OpenChatly is the AI workspace for everything. One person directing, agents executing, from goal to finished work.

©2026 OpenChatly AI.沪ICP备2025124785号-5

Resource guide

  • Product overview
  • Skills marketplace

Terms of service

  • User agreement
  • Privacy policy

Contact us