How to create a document search assistant in Microsoft Copilot
This tutorial shows how to create a document search assistant in Microsoft Copilot that searches internal files, answers questions in natural language, and returns citations and reference links — useful for teams that need quick, verifiable answers without manually searching through files.
Prerequisites
- Microsoft account with permissions for Microsoft Copilot and Copilot Studio
- Set of stored accessible documents (OneDrive, SharePoint, or supported source)
- Basic knowledge of prompt engineering and logical flow
- Modern browser and access to API keys or integrations, if needed
Step 1: Define the goal and scope of the document search
Before configuring, clearly describe what the assistant should answer: types of documents (policies, manuals, contracts), response format (summary + citations), and confidentiality limits. This prevents vague answers and helps create precise prompts.
Step 2: Prepare and index the documents
Organize the files in a supported location (e.g., SharePoint). If necessary, convert PDFs to text and ensure useful metadata (date, author, title). In Copilot Studio or in the integration you use, create a data source that indexes those files for semantic search.
Step 3: Create an agent in Copilot Studio
In Copilot Studio, create a new agent and connect the data source that contains the documents. Define the agent's capabilities: semantic search, citation extraction, and security constraints.
// Exemplo conceptual de ligação (pseudocódigo de configuração)
agentConfig = {
name: "AssistentePesquisaDocumental",
dataSources: ["SharePoint:DocsEquipe"],
features: ["semanticSearch", "sourceAttribution"],
maxContextTokens: 1500
}
createAgent(agentConfig)
Step 4: Write prompts and response templates
Create a main prompt that instructs the model to search, summarize, and cite sources. Include instructions for formatting the response: short summary, key points, and a list of references with titles and links.
System: "És um assistente de pesquisa documental. Procura nas fontes fornecidas e responde em 3 secções: 1) Resumo curto (2-3 linhas). 2) Pormenores relevantes (bullet points). 3) Referências (título, autor, ano, ligação). Se não encontrares informação, indica isso e sugere termos de pesquisa alternativos."
User (template): "Pergunta: {user_question}\nLimite de fontes: 3\nFormato: resumo + bullets + referências"
Step 5: Configure citation extraction and source verification
Enable the source attribution feature on the agent so that each important claim includes a reference. Set a confidence threshold: if the answer is generated without sufficient evidence, the agent should indicate uncertainty.
Step 6: Test with real examples and refine prompts
Test the agent with typical questions and analyze the answers: accuracy, usefulness of citations, and conciseness. Adjust the prompt to reduce hallucinations and to force inclusion of quoted excerpts when necessary.
// Exemplos de teste
Pergunta: "Quais os passos para solicitar licença parental segundo a política interna?"
Pergunta: "Onde está o procedimento de escalonamento para incidentes de segurança?"
Step 7: Integrate the assistant into the workflow
Decide how users access the assistant: chat in Teams, widget in SharePoint, or web interface. Configure permissions to ensure only authorized users see sensitive documents.
Verify the outcome
Ask validation questions and confirm that the answers include: a correct summary, bullets with relevant facts, and references with titles and links. Check samples where the answer should state "no evidence" — this indicates the verification mechanism is working.
Conclusion
After validating, roll out the assistant to a pilot group and collect feedback to improve prompts, search relevance, and security. Next step: automate the document index update and add version controls. Tip: start with simple source attribution rules and only then add more complex logic to reconcile conflicting answers.