All insights

AI Engineering

Building a Permission-Aware AI Chatbot on Microsoft Foundry, SharePoint and PostgreSQL

Nov 21, 20267 min readBy Milos Vukovic
“The hard part of an internal chatbot is not the model. It is making sure every answer comes only from what the person asking is allowed to see.”
Cover graphic: SharePoint and PostgreSQL feed a Microsoft Foundry chatbot that returns only answers the user is allowed to see.
Two data sources, one chatbot, and the user's own permissions deciding what it can say.

Staff at most organizations ask the same questions every week. Where is the current travel policy? What does the HR handbook say about leave? Which records in our own system match this situation? The answers exist, but they are spread across SharePoint sites and the internal applications the organization runs on, and finding them means knowing where to look.

We recently built an internal AI chatbot for a national nonprofit to close that gap. It is a web application on Microsoft Foundry (formerly Azure AI Foundry) that answers questions from two kinds of source: SharePoint sites that hold policies, HR material and similar documents, and a large PostgreSQL database behind the organization's other internal apps. More than 100 staff use it, over a corpus of more than 1,000 documents. This article covers the decisions that mattered most and a checklist you can use for your own build.

Why a custom chatbot instead of Microsoft 365 Copilot

Microsoft 365 Copilot is a strong default when the content lives in Microsoft 365, and Copilot connectors can bring some outside data into it. This project needed more than that. A large share of the useful answers sat in a PostgreSQL database that powers the organization's own applications, and the organization wanted one place where staff could ask about policies and their operational data together, under rules the organization controls.

A custom build on Microsoft Foundry gave us that control: which sources the assistant uses, how it searches them, how it decides what each person may see, and what a good answer looks like. The tradeoff is that you own the application, so you also own its testing, monitoring and upkeep.

Permissions come first

The single most important rule in this build is that the chatbot never shows anyone something they could not already see. A policy document in a restricted HR site stays restricted. A database record a person cannot open in the source application does not appear in their answer either.

That rule shapes the whole design. The application knows who is asking, and permission checks happen before content reaches the model, not after. Filtering a model's answer after the fact is not good enough, because by then restricted content has already been part of the prompt. Instead, retrieval returns only what the person is allowed to see, and the model answers from that.

  • ✓SharePoint content follows the person's existing SharePoint permissions. If someone cannot open a document in SharePoint, the chatbot does not use it for them.
  • ✓PostgreSQL data follows the access rules of the applications the data comes from, so a person sees the records their role allows and nothing more.
  • ✓When nothing the person may see answers the question, the right answer is to say so. A confident guess from somewhere else is the failure you are trying to prevent.

Two kinds of data, two kinds of retrieval

Policy documents and database records answer different kinds of question, so they are retrieved differently.

Documents answer questions like "what is our policy on": the assistant needs to find the right passage in the right version of the right file. That is classic retrieval-augmented generation (RAG): break documents into passages, index them, and give the model the few passages that best match the question.

Database records answer questions like "which of our" or "how many". Those need structured queries against PostgreSQL, scoped to what the person may see, rather than text search. Treating a database like a pile of documents loses exactly the precision these questions need.

With more than 1,000 documents, content quality matters as much as the code. Old versions, duplicates and drafts sitting next to the current policy are the most common source of wrong answers, so knowing which document is authoritative is part of the work, not an afterthought.

A web app staff could just use

The chatbot is a web application. Staff open it, ask in plain language, and get an answer drawn from the sources they are allowed to use. Keeping it a focused tool, rather than one more feature inside a larger system, made it easy to explain and easy to roll out to more than 100 people.

Checklist: before you build an internal AI chatbot

Whether you build on Microsoft Foundry, configure Copilot, or buy a product, ask these questions first:

  • ✓Which questions should it answer? Collect real questions from staff before choosing technology. They tell you which sources matter.
  • ✓Where do the answers live? List every source: SharePoint sites, file shares, databases, line-of-business apps. Each one needs a plan for access and freshness.
  • ✓Are your permissions right today? An assistant that respects permissions exposes every overshared site. Fix oversharing in SharePoint before launch, not after.
  • ✓Which document is the source of truth? Retire or clearly mark old versions and drafts, or the assistant will find them.
  • ✓How will you test answers? Keep a set of real questions with known good answers, including questions the assistant should refuse, and rerun it whenever content or prompts change.
  • ✓What happens when it does not know? Decide how the assistant says "I could not find that" and where it points people next.
  • ✓Who owns it after launch? Someone needs to watch usage, review bad answers, and keep sources current.

An internal chatbot is worth building when the answers your staff need are spread across systems that Copilot alone does not reach, and when you are prepared to own permissions and testing as seriously as the interface. Get the permissions right first, and the rest of the project becomes much easier to trust.

Referenced resources

Want a tailored workshop on this topic?

We run 90-minute briefings for leadership teams covering strategy, architecture, and a roadmap for action.

A free 30-minute working session. We review your environment and send a prioritized action plan you keep, whether or not we work together.

More insights

Browse all