Build a support agent that answers from your docs
Business Knowledge is in private beta. If Business Knowledge isn't in your PostHog sidebar, your project isn't in the beta yet. Send feedback in the app.
This tutorial builds a small support agent in Python. The agent answers customer questions from your public docs, names its source, and says so when it doesn't know. It reads only the library you choose, so your internal policies stay out of its answers.
The agent works with any model provider or agent framework that can call an MCP server. The examples show OpenAI and Anthropic. See connect your own agent for other clients and the REST API.
Before you start
You need:
- A project with Business Knowledge and AI data processing turned on
- Project admin access, to create a key
- Python 3.10 or later, and an API key for your model provider
- 1
Add your public docs
RequiredIn Business Knowledge, click Add source and add your docs site as a URL source. Choose Sitemap.xml or Same-origin crawl so PostHog indexes every page, and set auto-refresh to every day.
Wait until the source shows ready. See source status.
- 2
Put the docs in a library
RequiredOn the Libraries tab, create a library named
Public docsand add the source to it. Keep anything a customer must not see, such as internal runbooks, out of this library.See libraries.
- 3
Create a key for the library
RequiredOpen the
Public docslibrary. Under Connect an agent, name the keysupport-agentand click Create key.Copy the key and store it as an environment variable on the machine that runs the agent, next to the API key for your model provider:
- 4
Write the agent
RequiredInstall the SDK for your model provider:
Create
support_agent.py:Both examples give the model the six Business Knowledge tools through the MCP server. The model decides when to search, reads more of a document when one passage isn't enough, and writes the answer.
The provider connects to the MCP server for you and sends the key in the
Authorizationheader. In the Anthropic example, the loop resumes a turn that the API paused in the middle of a long run of searches.With another provider or framework, add the server with the JSON configuration, or call the REST API from a tool you define.
Ask a question your docs answer
CheckpointTerminalThe answer uses the facts on your docs page and names the page. If the agent says it doesn't know, ask the same question in the Playground to check that the source holds the fact.
- 5
Check what the agent can't read
RecommendedAsk a question that only an internal source answers, such as a detail from a runbook that isn't in the
Public docslibrary. The agent says it doesn't know, because the key reads only that library.
Make it production-ready
- Keep the key on your server. Call
answer()from your backend. Never ship the key to a browser or a mobile app. - Handle rate limits. A key can make 480 requests per minute. One answer can use several requests, because each search and each read is one request.
- Keep answers current. Set auto-refresh on your URL sources, so the agent reads new pages without a redeploy.
- Use one key for each agent. The key table then shows when each agent last read your knowledge, and you can delete one key without stopping the others.
Next steps
- How Business Knowledge works explains what search returns and why
- Learn from support adds your team's resolved answers as new sources





