AI & MCP

A support chatbot: when it helps and what it costs

A chatbot helps when it answers from a closed corpus and hands the case to a person through a tool. When it guesses, every saved reply costs three to repair.

Key points

  • Corpus, actions and escalation are three boundaries to settle before the code.
  • Cost per conversation grows with context: every turn resends the whole history.
  • Escalation is a tool with a queue, not an apology message.

A support chatbot helps when it answers from a closed corpus and can hand the case to a person; it does damage when it guesses.

Three boundaries before the code

  • Corpus: the bot answers only from documents you own and refresh.
  • Actions: reading an order status is a tool, not a sentence the model writes.
  • Escalation: handing over to a person is a tool with a queue, not an apology message.
import { streamText, isStepCount, tool } from 'ai';
import { z } from 'zod';

const result = streamText({
  model: 'anthropic/claude-haiku-5.5',
  system: 'Answer only from the documentation corpus. Escalate when unsure.',
  messages,
  tools: {
    searchDocs: tool({
      description: 'Search the documentation corpus',
      inputSchema: z.object({ query: z.string() }),
      execute: async ({ query }) => searchDocs(query),
    }),
    handoff: tool({
      description: 'Hand the conversation to a human queue',
      inputSchema: z.object({ reason: z.string() }),
      execute: async ({ reason }) => openTicket(reason),
    }),
  },
  stopWhen: isStepCount(3),
});

The cost per conversation

The bill is input tokens times price plus output tokens times price, with the context growing on every turn. With Haiku 5.5 at $0.10 and $0.50 per million, a thousand conversations of 2,000 input tokens and 300 output tokens cost $0.20 plus $0.15, so $0.35.

The test that decides

Take thirty real questions with the expected answer written next to each. Count how many answers the bot takes from the corpus, how many are wrong and how many escalate. If the wrong ones are not zero, the corpus or the prompt is not ready.

The step limit has to be raised on purpose: with isStepCount(1) generation stops at the first tool call and the model never uses the result. Three steps cover search, read and answer; every extra step costs a whole prompt.

The limitation

Every turn pays for the tool schema: 3,655 bytes of definitions are input tokens on every request, even when the bot calls no tool. And a bot that is right on thirty questions is not a bot that is right on three hundred.

Where to continue

Ready-made chat parts are in chat blocks 2026, tool shape in designing an MCP tool, the transport comparison in MCP or REST. The records: 1,556 blocks, 111,985 components, the 21st.dev sidebar.

Frequently asked questions

Does a chatbot reduce tickets or move them?

It reduces them only when the corpus covers the recurring questions and the bot closes the case, not when it points at the documentation. Measure conversations closed without an agent, not messages exchanged.

How do I stop the bot from inventing answers?

Ground it in a retrieved corpus and escalate when the context has no answer. A prompt that forbids invention is not enough: you need a code path that opens the ticket.

What does one conversation cost?

It depends on tokens. With Haiku 5.5 at $0.10 input and $0.50 output per million, a conversation of 2,000 input tokens and 300 output tokens costs $0.00035. Above 100,000 prompt tokens the model price rises fivefold.

Why does the bot stop after the tool call?

Because stopWhen defaults to isStepCount(1) in the AI SDK: generation ends at the first call. Raise the limit to three steps if you want the model to use the tool result.

Does support need an LLM at all?

Not always. If there are ten answers and they rarely change, a decision tree with links works better and costs nothing. A model earns its place when people phrase questions in unpredictable ways.