Skip to main content

What you’ll build

A B2B SaaS risk radar. For each customer, the agent reads:
  • Intercom — support conversations, response times, sentiment.
  • Slack — messages in their shared channel, tone, who’s showing up.
  • HubSpot — renewal date, deal size, contact engagement.
  • Stripe — subscription status, MRR trend, failed charges.
  • Zendesk — open tickets, escalation history.
  • GitHub — issues they’ve filed on your repo, PRs they’ve contributed.
Every morning, the agent produces a ranked list of customers at risk, with the specific signals behind each call.

The code

import { AgentRouter } from '@copass/agent-router';
import open from 'open';

const router = new AgentRouter({
  auth: { type: 'api-key', key: process.env.COPASS_API_KEY! },
  sandboxId: process.env.COPASS_SANDBOX_ID!,
});

// Six sources feeding the same sandbox.
await router.integrations.connect('intercom', { onConnectUrl: open, scope: 'org' });
await router.integrations.connect('slack_v2', { onConnectUrl: open, scope: 'workspace' });
await router.integrations.connect('hubspot',  { onConnectUrl: open, scope: 'org' });
await router.integrations.connect('stripe',   { onConnectUrl: open, scope: 'org' });
await router.integrations.connect('zendesk',  { onConnectUrl: open, scope: 'org' });
await router.integrations.connect('github',   { onConnectUrl: open, scope: 'org' });

for await (const event of router.run({
  provider: 'anthropic',
  model: 'claude-opus-4-7',
  system: `You are a customer success analyst. For each active customer, cross-reference:
  • Intercom — response sentiment, unanswered messages, tone shift.
  • Slack — quiet-then-loud patterns, negative tone, lost champions.
  • HubSpot — renewal within 90 days, declining contact engagement.
  • Stripe — MRR drop, failed charges, downgrades.
  • Zendesk — escalations, ticket aging, repeat complaints.
  • GitHub — open bugs they filed, unresponded PRs.

Produce a ranked list of the top 10 at-risk customers. For each, cite the specific signals
across at least 3 of the 6 sources. Score risk (low / medium / high / critical).
Skip customers where the signals only come from one source — we need corroboration.`,
  message: 'Generate today\'s customer health report.',
  endUserId: 'cs-team',
})) {
  if (event.type === 'text')      process.stdout.write(event.text);
  if (event.type === 'tool_call') console.log(`\n${event.name}`);
}

What’s happening

  • Signals only matter when they corroborate — the prompt forces the agent to reach across 3+ sources before flagging a customer. Single-source signals are noise; cross-source patterns are real.
  • One sandbox, one view — six separate SaaS dashboards become one report. The CS team stops tab-switching; the data does the joining.
  • Same pattern for any segment — swap the sources for product-health (PostHog + Sentry + Datadog + GitHub + Linear) and you have an engineering version of the same radar.

Make it yours

  • Per-customer deep dive — loop per customer id, pass it as endUserId, get a detailed per-account brief with window-aware continuity week to week.
  • Auto-route interventions — append For critical customers, draft a Slack message to their success owner and the deal's account exec. Slack write is already connected.
  • Weight by MRRWeight risk by annual contract value; a quiet $500k account outranks a loud $5k trial. The agent reads Stripe and HubSpot to do the math.