← Blog

Building a document Q&A bot for your team — step by step

Every team eventually has the same question: “how do we get the answers from our PDFs without HR or the lead engineer becoming a search engine?” This guide is a real, follow-along walkthrough for building a document Q&A bot for a small team using DocuMind. You can complete it in an afternoon, it’s free for the basic flow, and the same pattern scales to a full company knowledge base.

What you’re building

A bot that answers questions about your team’s documents (not the open internet). When someone asks “how many days of personal leave do new hires get?”, the bot reads from the actual policy PDF and replies — with no risk of hallucinating policies that don’t exist.

Architecture, in one diagram

[Slack / Teams / your webapp]
        |
        |  user question (text)
        v
[Your tiny backend or webhook]
        |
        |  POST /api/v1/chat   Authorization: Bearer YOUR_API_KEY
        v
[DocuMind] -- retrieves chunks from your uploaded PDFs (RAG)
        |
        v
   reply text  →  back to Slack / Teams / webapp

The crucial piece: your API key controls which documents are visible. A “global” key sees all PDFs uploaded under your account; a “chat-scoped” key only sees PDFs in one specific chat.

Step 1 — Upload the team’s PDFs

  1. Go to documind.parshantyadav.com and sign in.
  2. Use Global Documents for org-wide PDFs (HR policy, holiday schedule, code of conduct).
  3. If you want the bot scoped to one conversation, create a chat first and upload PDFs inside that chat.

Step 2 — Create an API key

  1. Open the sidebar → API keys (global documents) for an org-wide bot.
  2. Or use Create API key inside a specific chat for chat-scoped retrieval.
  3. Copy the key the moment it’s shown — it’s never displayed again.

Step 3 — Verify with curl

curl -sS -X POST "https://documind.parshantyadav.com/api/v1/chat" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"message":"Summarize the leave policy in one paragraph.","history":[]}'

You should get back a JSON {"reply": "..."} sourced from your uploaded PDFs. If it answers anything outside the docs, recheck the key’s scope.

Step 4 — Wire it into Slack (10 lines of Node)

// /api/slack-webhook  (Vercel / Render / your server)
import express from "express";
const app = express();
app.use(express.urlencoded({ extended: true }));

app.post("/api/slack-webhook", async (req, res) => {
    const question = (req.body.text || "").trim();
    if (!question) return res.json({ text: "Ask me something about our docs." });
    const r = await fetch("https://documind.parshantyadav.com/api/v1/chat", {
        method: "POST",
        headers: {
            Authorization: "Bearer " + process.env.DOCUMIND_KEY,
            "Content-Type": "application/json",
        },
        body: JSON.stringify({ message: question, history: [] }),
    });
    const j = await r.json();
    res.json({ response_type: "in_channel", text: j.reply || "Sorry, no answer." });
});

app.listen(process.env.PORT || 3000);

In Slack, set this URL as a slash-command webhook (e.g. /docs). Now /docs how many leave days do interns get? answers from the actual handbook.

Step 5 — Streaming reply (better UX)

For a webapp, use /api/v1/chat/stream so the answer appears word by word. SSE deltas come as {"t":"d","c":"..."} followed by {"t":"done"}. Full code samples (cURL, JS, Python) live on the how it works page.

Step 6 — Optional: voice for support staff

If your team is on the move (warehouse, retail, kitchen), pair the API with the browser microphone. Set "voice": true in the body and use Web Speech for the mic. Details: Web Speech API + DocuMind.

Common questions

Can people ask things outside our PDFs?

The system prompt strictly refuses to answer non-document questions. It’ll still handle greetings (“hi”, “thanks”) and meta-questions (“who built you”).

Multiple PDFs — does it search all of them?

Yes; retrieval pulls relevant chunks across every PDF visible to the key’s scope.

Can we revoke a key?

Yes. The same UI shows revoke buttons. Once revoked, the key returns 401 immediately.

What about audit / who-asked-what?

API requests don’t persist conversations server-side (your app keeps the history if you want one). For built-in chat history, use the regular DocuMind app accounts.

Where to go next

Build it: documind.parshantyadav.com · More: voice PDF Q&A, all guides.