# Build a chatbot over your own documents

> A practical guide to shipping an AI chatbot that answers only from your own documents, with sources: upload, one authenticated endpoint, and cited answers with highlighted PDF pages using @uthereal-sdk/cortex.

- Canonical page: https://uthereal.ai/developers/chatbot-over-documents
- Last updated: 2026-09-18
- Product: Uthereal Cortex (sovereign enterprise AI, Swiss/EU data residency)
- npm package: `@uthereal-sdk/cortex` (https://www.npmjs.com/package/@uthereal-sdk/cortex)
- Repository: https://github.com/Uthereal-Labs/Uthereal-Cortex-SDK

## Short answer

Short answer: upload your documents to a Cortex agent, install @uthereal-sdk/cortex, expose one authenticated endpoint with createCortexHandler, and render answers with CitedAnswer. Every claim shows its source and PDF citations open the exact page, highlighted. No vector database or embedding pipeline required.

The demo is easy. The product is hard, and the gap is entirely about whether a reader can check the answer. Here is the shortest route to a document chatbot people will actually rely on.

## Four steps

- Create an agent at agent.uthereal.ai and upload your documents
- npm install @uthereal-sdk/cortex
- Mount createCortexHandler on one authenticated server endpoint, with the API key in server secrets
- Call it from the browser and render CitedAnswer with PDF evidence

## The server endpoint

```
import { createCortexHandler } from "@uthereal-sdk/cortex/server";

export const handler = createCortexHandler({
  config: {
    baseUrl: process.env.CORTEX_API_BASE_URL!,
    assistantId: process.env.CORTEX_ASSISTANT_ID!,
    apiKey: process.env.CORTEX_SHARED_API_KEY!, // server secret only
  },
  allowedOrigin: "https://your-app.example",
  authenticate: async (request) => {
    const user = await verifyYourApplicationSession(request);
    return user ? { id: user.id, externalUserId: user.cortexIdentity } : null;
  },
  store: yourStoreAdapter,
});
```
_One authenticated endpoint_

## What makes it trustworthy

- Claim-level citations rather than a list of consulted documents
- PDF citations that open the exact page with the passage highlighted
- Refusal when no passage supports the question
- Your own auth, history and quotas, through the CortexStore adapter
- EU or Swiss processing, zero retention, no training on your content

## Let your coding tool build it

Lovable, Codex, Claude Code, Cursor, Windsurf and GitHub Copilot each have a ready-made instruction file for this SDK. Drop it in and describe the feature.

```
Add an assistant that answers only from our uploaded documents. Every claim
must cite its source, and PDF citations must open the exact page with the
passage highlighted. Use the Uthereal Cortex SDK and keep the API key in
server secrets.
```
_Prompt for your coding tool_

## Frequently asked questions

### How do I build a chatbot over my own PDFs?

Create an agent and upload the documents, mount one authenticated endpoint with createCortexHandler from @uthereal-sdk/cortex/server, and render answers with CitedAnswer. Retrieval, ranking and citation mapping are handled by the service.

### How do I stop it inventing answers?

Ground it and let it refuse. The agent answers only from retrieved passages; when nothing supports the question it says so instead of generating. Claim-level citations make any remaining error visible immediately.

### How long does this take to build?

A working cited chatbot is an afternoon with the SDK. Building the same provenance quality yourself, with parsing, chunking, reranking, evaluation and a PDF citation UI, is typically several months.

### What file types work?

PDFs, manuals, policies, books, research papers and other long-form documents. Layout-aware parsing keeps headings, tables and footnotes intact so citations land on the right region.

### Where does my content live?

Processing is EU or Swiss resident with zero retention, and nothing you upload trains anyone's model. Documents remain yours and can be removed at any time.

## Related pages

- [PDF page citations](https://uthereal.ai/developers/pdf-citations): How the evidence renders.
- [Supabase RAG](https://uthereal.ai/developers/supabase-rag): Cited answers without pgvector.
- [Next.js RAG](https://uthereal.ai/developers/nextjs-rag): App Router setup.
- [npm package](https://uthereal.ai/developers/npm): Install, exports and runtimes.

## Next steps

- Create an agent and a scoped server key: https://agent.uthereal.ai
- Full SDK guide (HTML): https://uthereal.ai/developers/sdk
- Full SDK guide (Markdown): https://uthereal.ai/developers/sdk.md
- AI index for this site: https://uthereal.ai/llms.txt and https://uthereal.ai/llms-full.txt
- Help: sdk@uthereal.ai
