Replit Agent prompt to integrate an LLM chatbot
Wiring a chatbot into an existing app touches secrets, streaming, and persistence all at once, which is exactly where vague prompts fall apart. This one makes Replit Agent settle the provider and key handling first, then build a streaming chat panel with stored history. You end up with a bot that survives refreshes and fails readably.
Last updated
Add an LLM chatbot to the app already in this Repl without touching unrelated screens. Before writing code, tell me which provider connector you plan to use. If none is configured, ask me for an API key and store it in Secrets, never in source. Backend: a POST /api/chat route that streams tokens to the client as they arrive, plus conversations and messages tables in the existing Postgres database so a refresh restores history. Keep the system prompt in one server-side file I can edit, and never send it to the browser. UI: a chat panel with message bubbles, a streaming indicator while tokens arrive, a stop button that aborts the in-flight request, and an input that disables during generation. Render model output as markdown with code blocks. Guardrails: cap each request's history at the last twenty messages, truncating oldest first. Return a clear inline error when the key is missing or the provider rejects the call, with a retry button. Do not auto-retry on the server. Empty state: a short explainer of what the bot can do, with three clickable example questions. Done when: I can ask a question in the webview, watch the reply stream in, hit stop mid-response, refresh and see the full conversation restored from Postgres, and see a readable error card after I temporarily remove the key from Secrets.
Same task in other tools
Questions about this prompt
Which model provider will it use for the chatbot?
The prompt forces it to state a choice before building. If your workspace has a provider connector configured it should use that, otherwise it must ask for a key and put it in Secrets. Reject any build where a key string appears in source files.
Can I ground the bot in my app's own data?
Yes. After the base version works, ask for a retrieval step that queries relevant rows server-side and prepends them to the model request. Keep that assembly on the server next to the system prompt file so nothing sensitive reaches the browser.
Replies arrive all at once instead of streaming, what is wrong?
The server is buffering the response before sending it. Ask the agent to flush chunks to the client as the provider emits them, then verify by watching tokens render progressively in the webview rather than popping in as a block.