A chatbot implementation outline. The code fragments below illustrate the flow; check the current SDK documentation and complete error handling, authentication and quota controls before deploying.
Use Case Examples
- Customer support tier 1
- Internal knowledge base
- Lead qualification
- Order status
- HR FAQ
Tech Stack 2026
- Frontend: React + Vercel AI SDK
- API: Vercel Edge / Fly.io
- LLM: Claude / OpenAI
- Vector DB: pgvector / Pinecone
- DB: Supabase / Postgres
Step 1 — Define Scope
Niche it:
- Topic: [SPECIFIC]
- Tone: [BRAND VOICE]
- Refuse: [OFF-TOPIC]
- Escalate: [HUMAN PATH]
Step 2 — Build RAG
# Embed docs
embeddings = client.embeddings.create(
model="text-embedding-3-small",
input=chunks
)
# Store in pgvector
Step 3 — System Prompt
You are [COMPANY] support assistant.
Rules:
- Only answer about [TOPICS]
- Cite source URLs when used
- If unsure, say so
- Escalate complex to human via [PATH]
Tone: friendly, professional.
Step 4 — UI
"use client"
import { useChat } from "ai/react"
export default function Chat() {
const { messages, input, handleInputChange, handleSubmit } = useChat()
return ...
}
Step 5 — Backend Route
import { streamText } from "ai"
import { anthropic } from "@ai-sdk/anthropic"
export async function POST(req: Request) {
const { messages } = await req.json()
// Retrieve context
const context = await retrieveFromVectorDB(...)
const result = await streamText({
model: anthropic("claude-sonnet-4-6"),
system: systemPrompt + context,
messages,
})
return result.toDataStreamResponse()
}
Step 6 — Deploy
- Vercel: push to GitHub
- Auto-deploy
- Set env vars (API keys)
Step 7 — Monitor
- LangSmith for AI traces
- PostHog for user behavior
- Sentry for errors
- Cost dashboard
Step 8 — Improve
- Log conversations
- Eval set + score
- A/B test prompts
- Iterate weekly
Security
- Rate limit
- Auth required for sensitive
- Input validation
- Output filter
Pricing
No measured cost benchmark is available for this outline. Cost depends on token volume, model, retrieval, hosting and actual requests. Check each provider's current terms and account usage; set explicit budgets and request caps before enabling recurring traffic.
Compliance
- KVKK / GDPR consent
- Privacy policy
- Data retention
- Right to delete
Next Step
Read how to use Claude API.