Lost deal revival agent

From Othmane-Khadri/YALC-the-GTM-operating-system · View interactive version

Lost deal revival agent is an AI agent skill from the GitHub repository Othmane-Khadri/YALC-the-GTM-operating-system. Drafts revival messages for closed-lost deals when a public company signal contradicts the original objection. Receives the signal-pair watcher's fire payload, fetches the verbatim Claap objection quote, and produces a 2-line draft that quotes it back. Default output is a HubSpot task for human revi

How to use this skill

Skill file

Lost Deal Revival Agent

Receives signal-pair fire payloads from the signal-pair watcher

(src/lib/agents/signal-pair-watcher.ts) when a watched company has both

a Claap-derived closed-lost objection tag and a fresh PredictLeads signal

within a 14-day window. Fetches the verbatim Claap objection quote,

drafts a tight 2-line revival message that quotes the objection back and

names the new signal change, then writes the draft to one of two

operator-chosen output targets for human review.

**You produce drafts. You do NOT send messages. You do NOT start Lemlist

campaigns. You do NOT modify Claap recordings.**

When This Skill Applies

NOT this skill:

When invoked from Slack

If the invocation prompt mentions a Slack channel and thread, treat THAT Slack thread as your output surface instead of the chat. The drafted revival message and any progress notes go to the thread instead of the chat.

This is additive to the existing operator Slack DM in Step 5: an explicit Slack channel and thread in the invocation prompt become the output surface for that run. The process below is otherwise unchanged.

Invocation

This skill is invoked two ways:

  1. By the signal-pair watcher (primary path). The watcher reads

signal_watches.orchestrator_skill_id. Operators set that column to

lost-deal-revival-agent on watches where they want this orchestrator

to fire. The watcher then calls skill.execute(payload, context) with

the PairFiredPayload shape:

```ts

{

watchId: string

companyId: string // domain

entityName: string

signalTypes: string[]

signals: PairFiredSignal[] // [{ signalType, signalId, payload, lastSeenAt }]

firedAt: string

}

```

  1. Manually with --simulate for end-to-end testing. The agent yaml

at configs/agents/lost-deal-revival-agent.yaml documents this path.

Config

Per-tenant config at ~/.gtm-os/lost-deal-revival.json:

{
  "version": 1,
  "output_mode": "crm_task",
  "objection_signal_map_path": "~/.gtm-os/objection-signal-map.yaml",
  "claap_tool_prefix": "mcp__claap__",
  "slack_operator_id": "<U_YOUR_SLACK_ID>",
  "hubspot_owner_id": "<HUBSPOT_OWNER_ID>",
  "lemlist_campaign_prefix": "Revival -",
  "task_due_offset_hours": 24,
  "model": "claude-sonnet-4-6"
}

output_mode values:

capability.

create_campaign_with_sequence (single-step sequence). The skill

never calls set_campaign_state(start). Operator reviews and

manually starts the campaign in Lemlist if they want to send.

Required env vars (never in config):

Process

Step 1 — Validate the fire payload

Inputs from the watcher:

Load the objection-signal map at objection_signal_map_path. Parse the

signalTypes array into:

whatever non-objection types remain)

If neither is present, log malformed_payload and exit cleanly. Do

not throw.

If objection_kind is present but signal_kind is NOT in

map[objection_kind], log mismatched_pair { objection_kind, signal_kind }

and exit cleanly. This is a defensive check — the watcher should never

invoke us with a mismatched pair, but if it does, we must not write a

task or DM the operator.

Step 2 — Fetch the verbatim Claap quote

Call the Claap MCP semantic search via mcp__claap__search_meeting_recordings

(or mcp__claude_ai_Claap__search_meeting_recordings, depending on which

prefix is configured).

Search query: derived from objection_kind. The classifier prompt at

prompts/objection-classifier.md is the source of truth for what

each objection_kind looks like in natural language. Use the search to

locate the closed-lost call for this company (entityName and

companyId are both candidate filters) and pull the verbatim moment

text.

If Claap returns no transcript, hard stop with claap_no_transcript.

Do not draft against an empty quote.

If Claap returns multiple candidate quotes, pick the highest-scoring

moment whose type == 'objection'. If none are typed objection, pick

the highest-scoring moment overall.

Pass the quote through the objection classifier prompt as a sanity

check. If the classifier returns a different objection_kind than the

one in the watcher payload, log classifier_disagreement and continue

(the watcher's tag wins for routing; we only log the disagreement for

operator visibility).

Step 3 — Draft the 2-line revival message

Call the Anthropic client with the revival-copywriter prompt at

prompts/revival-copywriter.md. That prompt file is the **single

source of truth** for the revival voice. The skill code reads it from

disk at runtime and substitutes {{company_name}}, {{claap_quote}},

{{signal_kind}}, and {{signal_summary}} into it. Do not embed a

second copy of the prompt anywhere.

Inputs:

prompt treats this as the concrete fact to anchor on if no separate

KPI is supplied by the operator.

Voice rules baked into the prompt:

anchoring the concrete fact from the public change summary.

your thoughts").

best-in-class, game-changer.

like AI-native are fine.

See prompts/revival-copywriter.md for the 3 GOOD and 3 BAD examples

the LLM is shown.

Run the draft through validateMessage() from src/lib/outbound/validator.ts.

If any HARD rule fails, retry once with the violation echoed back to the

model. If the retry also fails, hard stop with dash_scan_failed.

Step 4 — Write to the configured output target

Branch on output_mode:

crm_task (default). Resolve the crm-create-task capability via

the capability registry. Build the call:

then a line with Signal: <signal_kind> — <signal_summary> (use a

colon, never a dash, to stay clean of the rail).

Capture the returned taskId.

lemlist_draft. Call the Lemlist MCP

mcp__claude_ai_Lemlist__create_campaign_with_sequence (or mcp__lemlist__

equivalent). Build:

never call set_campaign_state(start) after creation).

Capture the returned campaignId.

Step 5 — Send operator Slack DM

Build a plain-text message:

Lost deal revival drafted for <entityName>
Signal that changed: <signal_kind>

Drafted message:
<line 1>
<line 2>

Original objection: "<claap_quote>"

Output target: <HubSpot task #{taskId} | Lemlist DRAFT campaign #{campaignId}>

Send via the Slack delivery configured in ~/.gtm-os/lost-deal-revival.json

or the global Slack config (or post to the Slack thread via slack_post_message

if invoked from Slack). Use the Slack service module from

src/lib/services/slack.ts so we share the operator's existing wiring.

Step 6 — Emit a `result` event

Yield a result event with:

{
  companyId, entityName,
  objection_kind, signal_kind,
  claap_quote,
  draft: { line1, line2 },
  output_mode,
  taskId?: string,
  campaignId?: string
}

Failure modes (hard stops)

Output Quality Bar

Running on a schedule

See references/setup.md. The signal-pair watcher's daily run is the

primary fire path. The agent yaml at

configs/agents/lost-deal-revival-agent.yaml exists for the manual

--simulate path and operator discovery via agent:install.

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.