Skip to content

AI Engineering

Brain Chat Assistant — Velocity X's In-Dashboard Claude Bot for Reps + Admins

Live Data, Real-Time Answers, Never Leave the App

🧠 💬

A field rep is wrapping up a customer call in Velocity X. They ask the Brain: "What's my next best action on Esteem Clinic?" The Claude-powered assistant streams back a routing decision: follow up with a proposal within 2 hours, their deal is stalled on a pricing objection, and it's a $47K opportunity. No tab-switch to ChatGPT. No copy-paste of context. The assistant lives inside the dashboard, can see their CRM data (via RLS), and delivers answers in 1.2 seconds. This is Brain — Velocity X's embedded AI that turns your tool from "helpful dashboard" into "mind-reading sidekick".

Why Embedded Beats Separate

Most SaaS bolt on ChatGPT integration like it's a feature checklist — pop open a modal, chat, get canned LLM wisdom unaware of your actual data. Users tab away to Velocity X, grab context, tab back to ChatGPT, paste, ask again. We inverted it: Brain lives in the dashboard sidebar, sees your live deal data, your quota pacing, your team's performance, and can answer with real numbers, not guesses. An admin asks "Who's behind quota this month?" and Brain streams back a ranked list by shortfall amount. A rep asks "Best follow-up for this deal type?" and Brain knows their customer's industry, deal stage, and historical close rate. Embedded context = answers that matter.

Architecture: Claude API + MCP Tools + RLS

The data boundary. Velocity X runs on Postgres + Supabase. Every query, every dashboard you see, is governed by RLS (Row-Level Security) — a rep can only see their own deals, an admin sees their org. Brain enforces the same boundary. When a rep asks "next best action", the tool call queries the database with `get_user_deals` — which internally filters by `auth.uid()`. Claude never sees deals you shouldn't. No custom permissioning logic, no sync bugs. RLS is the single source of truth.

The MCP setup. We use Claude's Model Context Protocol to define three tool sets: `get_rep_context` (current user's deals, pipeline, quota pace), `get_team_analytics` (if user is an admin), and `draft_follow_up` (which fetches customer notes and generates a reply). Claude sees these tools in its system prompt, calls them as-needed during response generation, and we stream chunks back to the dashboard.

{`// Velocity X MCP server — tools available to Claude
const tools = [
  {
    name: 'get_rep_context',
    description: 'Fetch this rep's open deals, pipeline total, quota vs YTD',
    inputSchema: { type: 'object', properties: { limit: { type: 'number' } } },
  },
  {
    name: 'get_team_analytics',
    description: 'Return team quota pacing, top performers, who's behind',
    inputSchema: { type: 'object', properties: { orgId: { type: 'string' } } },
  },
  {
    name: 'draft_follow_up',
    description: 'Generate a follow-up email based on visit notes and deal stage',
    inputSchema: {
      type: 'object',
      properties: { dealId: { type: 'string' }, tone: { type: 'string' } },
    },
  },
];`}

The Flow: Streaming Responses in-Dashboard

Rep types "draft a follow-up for Esteem". Brain kicks off a POST to `/api/brain-chat` with the message and user context. The Edge Function calls Claude with the message, tools, and system prompt. Claude either generates text directly or calls tools ("I need to fetch this deal's notes first"). Tool results stream back into the conversation, Claude continues generating, and each chunk returns to the dashboard as `text/event-stream`. The rep sees "Dear Esteem Clinic Owners, Following up on our conversation about..." appear word-by-word while the draft is still being generated server-side. Total time: 2 seconds. Before Brain, that was a manual email draft (5 mins) plus send confirmation.

Permissioning: RLS at the Core

A rep in Sydney can ask Brain about their deals. Brain calls `get_rep_context` with their user ID. The MCP tool runs a Postgres query with `WHERE owner_id = auth.uid()`. That rep never sees their colleague's deals, even if they ask "show me Sarah's pipeline" — the database returns an empty set. RLS happens client-unaware. An admin can flip their context to "show me team" and Brain's tool responses expand to the org. Same code path, different data boundary. No custom auth layer, no bugs.

Six FAQs

Does Brain see all our CRM data?

Only what you're allowed to see. RLS on the Postgres side means Brain's tool calls inherit your row-level permissions. A rep's Brain can't access closed/internal deals.

What if Claude hallucinates a deal number?

Tool calls are the fallback. If Claude generates text like "your top deal is $50K", that's context-less. But if you ask "which deal is my largest?", Brain calls `get_rep_context`, fetches real data, and grounds the response. Always ask for facts, not opinions.

Does this cost a fortune per message?

Nope. Claude Sonnet (the model Brain uses for speed) is ~$3 per million input tokens. A rep's question is ~50 tokens, response ~300. You're paying a fraction of a cent per query. A rep using Brain 50 times/day costs ~$0.15/day.

Can Brain call custom functions?

Yes. The MCP tools are your own functions running in an Edge Function. You can call webhooks, hit third-party APIs (Slack, Stripe, Google Sheets), or run Postgres queries. The limit is latency — keep tool calls under 2 seconds for snappy UX.

What if the network dies mid-response?

The stream breaks. Brain doesn't retry automatically. On the client, `useChat` has stored the partial message in state. Refresh and you lose it. For critical workflows (deal drafts), we auto-save to IndexedDB every 500ms — user can recover the draft if they accidentally close the tab.

Can Brain access customer email or phone?

Only if you grant the tool permission. We don't bake in email/phone APIs by default. You explicitly add a tool like `send_follow_up_email` if you want Brain to act, not just advise. This is a safety guardrail — AI should suggest, not send on its own.

The Verdict

Embedding Claude directly into your dashboard — with live data via tools and RLS-enforced boundaries — turns your CRM from a data store into a thinking partner. Reps get smarter routing, admins get instant team visibility, and nobody has to leave the app or copy-paste context. For architecture deep-dive and streaming setup, see Vercel AI SDK + Claude. To see Brain in action and pricing, visit the pricing page.

Let us make some quick suggestions?
Please provide your full name.
Please provide your phone number.
Please provide a valid phone number.
Please provide your email address.
Please provide a valid email address.
Please provide your brand name or website.
Please provide your brand name or website.