AI-Powered PDF Context Chatbot Using Flask & Power Platform
By Sudarshan Awasthi โข 2025
An intelligent chatbot that semantically reads PDFs and answers natural language questions using embeddings, Flask API, and Power Apps UI.

๐ Introduction
In today's information-heavy environments, finding specific content inside large collections of PDFs is frustrating. This project solves that problem by enabling a chatbot to semantically understand and answer user queries โ not just with keyword search, but true contextual understanding.
๐ฏ Problem Statement
Traditional search fails when the exact wording is unknown or information is scattered across documents. This solution enables:
- โธNatural language question input
- โธContextual understanding of PDF content using semantic embeddings
- โธAI-generated answers
- โธSeamless low-code UI with Power Platform
๐ ๏ธ Technologies Used
| Layer | Technology |
|---|---|
| UI | Power Apps (Canvas App) |
| Automation | Power Automate |
| Backend | Python Flask + Sentence Transformers |
| Embedding Model | all-mpnet-base-v2 |
| PDF Parsing | PyPDF2 |
| Hosting | Ngrok (Dev) |
| Memory Logs | psutil |
๐งญ Architecture Overview

The architecture consists of five interconnected components:
- โธPower Apps: Frontend chat UI where the user types a question.
- โธPower Automate: Middleware that sends the question to the backend and receives the final AI response.
- โธFlask API: Python server that extracts text from PDFs and uses semantic search to find relevant context.
- โธAI Builder: Uses the reduced context + question to generate a human-readable answer.
- โธPower Apps: Displays the AI-generated answer in a user-friendly interface.
This flow enables end-to-end semantic search over PDF documents using natural language โ without requiring the user to browse, scroll, or filter manually.
๐ฌ Power Apps Chat UI

๐ Power Automate โ Orchestrating the Flow
Power Automate plays a crucial role in connecting the user interface built in Power Apps with the backend AI system powered by Flask and Python. It acts as the middleware that sends and receives data, triggers the AI logic, and ensures that user queries are processed intelligently and efficiently.
๐ What Happens in Power Automate?
- Trigger: Captures the question from Power Apps via "When a Power Apps button is clicked".
- Step 1: Sends HTTP POST to the Flask API hosted on Ngrok.
- Step 2: Receives reduced context (top matching sentences) from PDFs.
- Step 3: Sends both context and question into the AI Builder "Run a prompt" action.
- Step 4: Returns the AI-generated answer back to Power Apps and updates the UI.
[User Question] โ [Power Automate] โ [Flask API] โ [Reduced Context] โ [AI Prompt] โ [Answer]
๐งช Sample Prompt Execution โ Power BI Example
Here's a real-world example that demonstrates how the chatbot processes a Power Platform question using embedded content from Power BI documentation:
๐งพ Question:
"How do I connect Power BI to SharePoint and refresh the data automatically?"
๐ง Final AI Answer:
To connect Power BI to SharePoint, use the SharePoint Online List connector and provide the site URL and list name. After shaping the data with Power Query, publish the report to Power BI Service. Then, configure automatic refresh under dataset settings โ no gateway is needed for SharePoint Online.
๐ Code Repository
Explore the backend Flask code and setup instructions here:
View on GitHubโ Conclusion
This chatbot showcases the power of combining AI, semantic search, and low-code platforms to solve real-world document analysis challenges. It's a production-ready, extensible solution for knowledge retrieval.