Skip to main content
This guide walks through building a real chatbot from scratch β€” a support bot that answers questions from your documents.

Step 1 β€” Install and configure

Install LangChat and create your .env file:
.env

Step 2 β€” Index your documents

Before the chatbot can answer questions, it needs to read your content. Put your documents (PDFs, text files, CSVs) in a folder and index them:
Run this once (or whenever your documents change):
LangChat automatically detects duplicate chunks using a content hash, so re-running index() on the same files is safe.

Step 3 β€” Build the chatbot

Step 4 β€” Handle multiple users

Each user_id gets its own conversation history. Use platform to separate different applications sharing the same backend:

Step 5 β€” Add a custom persona

Make the bot speak in your brand voice by customizing the prompt:
The three template variables {context}, {chat_history}, and {question} are filled in automatically.

Step 6 β€” Deploy as an API

Turn your chatbot into a production REST API in one step:
Your API exposes:

What’s next

Configuration

Switch LLM providers, configure Pinecone namespaces, tune history length

Custom Prompts

Full guide to prompt templating and standalone question customization

Document Indexing

Supported file formats, chunking strategy, namespace organization

API Server

Production server setup, CORS, Docker, environment configuration