Skip to main content
Post

#PowerPlatformTip 182: 'Ground AI Builder Prompts Directly on Dataverse - No More Text-Dump Flows'

#PowerPlatformTip 182: 'Ground AI Builder Prompts Directly on Dataverse - No More Text-Dump Flows'

TL;DR: In Prompt Builder (AI Builder), attach a Knowledge source pointing at a Dataverse table instead of pre-fetching rows in a flow and stuffing them into the prompt text. The prompt becomes a grounded prompt: it retrieves the relevant records itself (RAG) based on the input you pass in.

💡 Challenge

The old pattern for giving a model business context was clumsy: a Power Automate flow runs List rows, you concatenate the results into one huge text block, and you inject that block into the prompt. It’s brittle, it blows past token limits, it re-runs on every call, and every schema change means rebuilding the string. You’re doing retrieval by hand.

✅ Solution

Prompt Builder lets you add Knowledge - a data source connection such as Microsoft Dataverse - directly to a custom prompt. The prompt then generates answers grounded in your business data, pulling only the records it needs at runtime. No flow-side text rendering, no manual concatenation. This is Retrieval-Augmented Generation (RAG) on your own Dataverse, configured with clicks.

🔧 How It’s Done

1. Open Prompt Builder

🔸 In Power Apps or Power Automate: AI hub > Prompts > Build your own prompt.

🔸 In Copilot Studio: Tools > Add a tool > New tool > Prompt, or open an agent > Tools > Add a tool > Prompt (or add a prompt via Add node inside a topic).

2. Add your input

🔸 Type / or select Add content > Text to define an input variable - for example the record or question you’ll pass in at runtime.

3. Attach Dataverse as Knowledge

🔸 In the Knowledge section, add a data source and select your Dataverse table. A Knowledge object represents data retrieved through that connection, so the model can ground its answer in those records.

🔸 Reference the columns you care about in your instructions. Example prompt: “Create a summary of the account named Name using only these columns: Account.Name, Account.Description, Account.Orders (Order).Name, Account.Orders (Order).Amount.” Here Name is the prompt input, and the other values are knowledge references you insert via / or Add content. A name is not unique: if two accounts share it, the summary can mix them up or pick one at random. Pass a unique value (for example the account ID, or the account number if you enforce it as unique) as input and filter on it, and resolve ambiguous names before the prompt runs.

4. Set filters and record limits

🔸 Narrow the retrieval with Filter attributes. Only these column types can be used as filters: text, number, date and time, choice, currency, and unique identifier.

🔸 By default the prompt retrieves 30 records. You can raise this to up to 1,000 in the settings when a scenario needs more context. The retrieval is meant for focused context, so keep your filters tight rather than raising the limit by default.

5. Test, then consume it anywhere

🔸 Use Test with a realistic sample input to confirm the grounding works, then reuse the same prompt in a canvas app, a cloud flow, or a Copilot Studio agent. The test shows that the data connection works, not which records a later user is allowed to see: for every place you call the prompt from, find out whose Dataverse identity retrieves the data, and test with a restricted account and check that records this account must not see appear neither in the context nor in the answer.

Licensing: Prompt Builder prompts consume AI Builder / Copilot credits depending on your licence, and prompts are only available in some regions.

🎉 Result

Your prompt reads straight from Dataverse and grounds every answer in live business data - summaries, classifications, drafted replies - without a single hand-built text dump. One prompt, reusable across apps, flows and agents, with retrieval handled for you.

🌟 Key Advantages

🔸 Built-in RAG - the grounded prompt retrieves relevant Dataverse records itself; you stop rendering context by hand.

🔸 Leaner context - only the filtered records enter the context, instead of a giant token-heavy block on every run. A filter with a record limit doesn’t guarantee that all needed (or only relevant) records are retrieved, and it isn’t automatically cheaper than an equally narrow flow query: check relevance and completeness with known matches, non-matches and result sets above the limit, and compare costs only on comparable, measured runs.

🔸 Reusable component - the same prompt can be used from Power Apps, Power Automate and Copilot Studio.

🔸 Maintainable - schema tweaks mean adjusting a Knowledge source and filters, not rebuilding string concatenations.

⚠️ Watch out: Know the current limits before you design around this. Virtual tables are not yet supported as a Knowledge source. Only one-to-many / many-to-one Dataverse relationships work, up to two levels deep. Connector-based sources (Salesforce, Oracle, SAP, ZenDesk) only work for prompts in Power Automate - Dataverse is the one that works everywhere. And remember the 30-record default (raise to 1,000 in settings) so the model isn’t silently missing rows.

🎥 Video Tutorial

🛠️ FAQ

1. Do I still need a Power Automate flow to fetch the data? No. That’s the point - the grounded prompt retrieves the Dataverse records itself through the Knowledge source. You only pass the input (e.g. the record or question) at runtime.

2. Is this the same as RAG? Yes, conceptually. The prompt performs Retrieval-Augmented Generation over your Dataverse data: it pulls the relevant records and grounds the model’s answer in them, rather than relying on the model’s general knowledge.

3. Can I use it in Copilot Studio, Power Apps and Power Automate? Yes. A prompt built in Prompt Builder can be reused from all three. Connector-based knowledge sources are the exception: they only work in Power Automate.

4. Why can’t I select my virtual table or a lookup two hops away? Current limits: virtual tables aren’t supported yet as a Knowledge source, and Dataverse relationships are limited to one-to-many / many-to-one, up to two levels deep. Design your table and filters around that.

5. It seems to ignore some records - why? The default retrieval is 30 records. Increase the limit (up to 1,000) in the prompt settings if your scenario needs more context.

🔸 #PowerPlatformTip 180: ‘Preload Config & User Context at Conversation Start in Copilot Studio’ - complementary way to give an agent context up front.

🔸 #PowerPlatformTip 143: ‘Reduce AI Costs with Thumbnail-First Document Processing’ - keep AI Builder consumption under control.

🔸 #PowerPlatformTip 116: ‘AI Automated Solution Design’ - more AI-assisted building in the Power Platform.

This tip is by Marcel Lehmann, Microsoft MVP (Business Applications) and founder of the Power Platform Academy, which runs free live workshops (in German). See the next free workshop dates (in German). For companies that want this implemented for them, see KMUpower: Power Platform consulting & automation for SMEs (DACH).

This post is licensed under CC BY 4.0 by the author.

Microsoft and the Power Platform product names (for example Power Apps, Power Automate, Copilot Studio) are trademarks of the Microsoft group of companies. This is an independent website. It is not operated, sponsored or endorsed by Microsoft.