In this article
A language model in a chat application is a natural fit — the medium is already a conversation, and people type in sentences rather than filling in forms. It is also the place where a wrong answer looks most like a person saying it, in a room where other people are watching.
This step is not about which framework. It is about where a model belongs in a system, what it must never be the last word on, and the three operational facts that catch everybody — rate limits, other people's data, and instructions arriving inside the input.
What you will be able to do after this step
- check_circle Put the model where it helps and keep it out of where it does not.
- check_circle Stream a reply into a chat without being throttled into silence.
- check_circle Say what leaves the room when a bot like this is in a group.
- check_circle Keep untrusted input away from anything that can act.
Where a model earns its place
The dividing line is not difficulty. It is whether being wrong is recoverable, and whether the answer has to be the same every time.
psychology Let the model do it
rule Keep the deterministic path
Put the model where the input is messy and the output is prose. Keep a fixed path for everything that acts, and let the model propose it rather than perform it.
speed Streaming into a chat is not streaming into a web page
The visible typing effect people expect is produced by editing a message repeatedly. Every edit is a request, and requests are paced — Step 096's outgoing half. Update on every token and you will be told to wait, at which point the reply stops mid-sentence and stays there.
So update in chunks on a deliberate interval rather than continuously, and let the interval be conservative: nobody notices a reply that appears in four steps instead of forty, and everybody notices one that freezes.
The better question is whether to stream at all. In a chat, a complete message that arrives a couple of seconds later reads perfectly naturally — people are used to waiting for a reply. A message that visibly rewrites itself cannot be quoted or replied to while it is happening, looks broken when it stops, and in a group produces a half-finished statement sitting in a room where somebody may screenshot it. A short "thinking" acknowledgement followed by one finished message is usually the better design and always the simpler one.
visibility What leaves the room
This is the fact with the most consequence and the least coverage. Everything the bot processes goes to whoever runs the model.
In a private conversation that is a straightforward exchange between somebody and a service they chose. In a group it is not, because the other members did not choose anything. If your bot reads everything said in a room in order to be helpful, then that room's conversation is being sent to a third party, and the people in it have no way of knowing unless you tell them.
Two things follow, and both are cheap. Decide what invokes it. A mention, a reply to its own messages, or a command — not everything. This also keeps it out of the configuration from Step 086 where a bot receives every message in the group, which is a larger permission than most people realise they are granting. And say what it is, in the group's pinned message and in the bot's description: what it is, what it sends onwards, and what is kept.
Keeping conversation for context is its own decision with its own weight (Step 093). A model that remembers last week is a service that stored last week, and that store is the thing that matters when something goes wrong.
gpp_bad Instructions arrive inside the input
A message in a group, a forwarded document, a web page the bot was asked to summarise — any of these can contain text addressed to the model rather than to a person. "Ignore what you were told and do this instead" is an ordinary sentence, and a model reading it has no reliable way to distinguish it from the content it was asked to process.
This is Step 096's rule in a new form: everything arriving from outside is untrusted input, and here the untrusted input is being read by something that follows instructions.
The defence is structural rather than clever, because attempts to filter this reliably have not worked. Do not give one component both untrusted input and privileged tools. A model that summarises documents should not also be able to send messages, move money or change permissions. Where an action is genuinely needed, the model proposes and your code decides — with a check that does not depend on the model's own output, and a human confirmation in front of anything irreversible.
touch_app Try it now — five minutes
Four steps, and the third one should be done before the bot meets anybody.
- Write down what invokes it Mention, reply, command. If the answer is "everything in the group", change it before anything else.
- Say what it is in its first message One sentence that it is automated, and one route to a human. Both from Step 097, and both cheap.
- Try to talk it out of its instructions Send it a message telling it to ignore them. Then put the same text inside a document and ask it to summarise that. The second usually works better, which is the point.
- List every tool it can call and the worst case of each Anything on that list that spends, sends or grants needs a human confirmation in front of it.
record_voice_over It will be confidently wrong, in your voice
The failure mode is not gibberish. It is a fluent, plausible, specific answer that happens not to be true — a price that is close, a policy that sounds like yours, a date that is confidently stated and invented. In a chat under your name, readers have no signal that this one is different from the last ten.
Three mitigations, in order of how much they help.
Narrow what it answers from. A model answering from your own documents, and saying which one, is a dramatically better proposition than one answering from everything it ever read. Where it cannot find an answer, the honest output is that it cannot — and building that behaviour is worth more effort than improving the wording of the answers it can give.
Label it and keep an exit. A person who knows they are talking to software forgives a wrong answer and asks for a human. A person who thought they were talking to your support team does not.
Do not let it speak for the organisation on anything that matters. Refunds, commitments, deadlines, apologies, anything legal. Those belong to a person, and the model's job is to get the person there quickly with the context already gathered.
And be realistic about the economics while you design: this costs money per message rather than per user, so the volume you would be delighted to have is also the bill. A bot that answers anything from anybody in a public group is an open tap, which is another reason the invocation rule above is the first decision rather than the last.
help Common questions at this stage
Which framework should I use?
Whichever you can read, and less of it than you expect. Most bots of this kind are a handful of calls: receive the message, assemble some context, ask the model, send the reply. Orchestration frameworks earn their place when you genuinely have several specialised steps with state between them, and they cost you a layer of indirection over the part you most need to understand. Start with the direct version and adopt a framework when you can name the problem it solves for you.
Should the bot remember previous conversations?
Only as much as the task needs. Remembering the last few exchanges makes a conversation coherent and costs little; remembering everything forever makes the bot feel clever and turns your system into an archive of what people said to it. The second is a storage decision with all of Step 093's consequences, and it is frequently made by accident because a framework offered it. Decide the window deliberately and expire what falls outside it.
Can it moderate my group?
It can flag, and a person should decide. The filtering in Step 061 already shows the shape of the problem: a system that does not understand your community's subject will remove things that look wrong and are not, and members experience an unexplained deletion as censorship rather than as a mistake. Using a model to surface candidates for a human moderator is genuinely useful. Letting it delete and ban directly gives an unpredictable component the most consequential buttons in the room.
How do I stop it answering questions it should not?
Partly by instruction and mostly by architecture. Instructions help and can be talked around, as the section above describes, so anything that genuinely must not happen should be impossible rather than discouraged — if it has no tool to issue a refund, it cannot issue one regardless of what somebody persuades it to say. For topics rather than actions, the practical approach is a narrow scope, a clear statement of what it covers, and a quick handoff for everything else.
What about voice messages?
Transcribing an incoming voice message and answering in text is one of the genuinely good applications of this, because it converts something the recipient has to listen to into something they can read — the same value as the transcription feature itself. Two cautions: transcription fails on names, numbers and technical terms in exactly the places that matter, so anything consequential should be confirmed; and the audio is leaving the room, which is the section above applied to a format people treat as more private than it is.
Is this the future of bots, as everything suggests?
It is one useful component among several, and the bots people actually rely on remain mostly deterministic — a form, a lookup, a notification, a button. The model adds a good front door onto those: it understands the request and routes it. What it does not do is remove the need for the rest of this curriculum, because the thing it routes to still has to be built correctly, and the failure modes in Steps 091 through 096 are unchanged by anything in this one.
At a glance
- 1Where a model helps
Messy input and prose output; keep money and access decisions in code.
- 2Group privacy
In a group, what triggers the bot is sent to the model's provider.
- 3Untrusted input
Keep text from users away from tools that can act.
Updated