Skip to content

ShdowX/KN-LicenseAdvisory

Repository files navigation

Power Platform License Advisor

An open-source Power Apps code app + Power Automate flow that answers Microsoft Power Platform, Dynamics 365 and Microsoft 365 licensing questions using an AI advisor grounded in a Dataverse knowledge base you control.

Ask a plain-language scenario ("25 planners need a code app on Dataverse; they have Microsoft 365 E3"), tell it which licenses you already own, and get a structured verdict: what's covered, what to buy, quantities, costs, assumptions and watch-outs — reasoned strictly over licensing rules stored in Dataverse.

License Advisor — Advisor tab


Why this design

The licensing knowledge base lives in Dataverse, not hard-coded in the prompt. When Microsoft ships a new licensing guide, you update rows — no redeploy of the app or flow. The AI call runs server-side in a Power Automate flow, so the prompt, the knowledge base and the credit consumption all stay inside the Power Platform governance boundary (DLP-controlled, environment-scoped, auditable, no API keys in the client).

See docs/DOCUMENTATION.md for a full walkthrough of the app and the flow.

Features

  • Advisor — natural-language scenario + owned-license picker (grouped, with quantities) → AI verdict with per-license result cards, assumptions, watch-outs and a monthly estimate.
  • Reference — the full licensing knowledge base, grouped by family (Power Platform / Dynamics 365 / Microsoft 365) with a product filter. Single source of truth shared with the AI.
  • History — every analysis logged to Dataverse; click a run for full detail, or export all runs to Excel for test/validation.
  • Grounded & governed — AI runs in a cloud flow; rules are Dataverse rows; results are audited in kn_advisorrun.

Architecture

┌─────────────────────────────────────────────┐
│  Power Apps Code App (React + Vite + SDK)   │
│  Advisor · Reference · History              │
└───────────────┬─────────────────┬───────────┘
    create row  │                 │ read
                ▼                 ▼
        kn_advisorrun        kn_licenserule        (Dataverse)
                ▲                 ▲
   write result │                 │ list active rules
┌───────────────┴─────────────────┴───────────┐
│  Power Automate flow: NewQuestionGetAIAnswer │
│  trigger on new run → gather rules →         │
│  run AI prompt → write kn_responsejson       │
└──────────────────────────────────────────────┘
  • kn_licenserule — the knowledge base (one row per rule; product, rule text, pricing, source, active flag, sort order).
  • kn_advisorrun — audit log (scenario, owned licenses, verdict, response JSON, status, duration).
  • The app creates an kn_advisorrun row with just the scenario; the flow fills kn_responsejson; the app polls for it (3-minute timeout).

Repository structure

app/                     Power Apps code app (React + Vite + TypeScript)
  src/                   components, services, hooks, styles
scripts/                 Python import/utility scripts (run in .venv)
  import_license_rules_pp.py     Power Platform rules  → kn_licenserule
  import_license_rules_d365.py   Dynamics 365 rules    → kn_licenserule
  import_license_rules_m365.py   Microsoft 365 rules   → kn_licenserule
  seed_advisorrun_tests.py       50 sample test scenarios (optional)
  create_solution.py / create_tables.py / widen_verdict.py   schema provisioning
solution/                Exported Dataverse solution (managed + unmanaged)
  PowerPlatformLicenseAdvisor.zip           unmanaged
  PowerPlatformLicenseAdvisor_managed.zip   managed
docs/                    Documentation + screenshots

Prerequisites

  • A Power Platform environment with Dataverse (a Managed Environment is recommended).
  • Power Platform CLI (pac) 1.44+ — for solution import and code-app deploy.
  • Node.js 22+ — to build/run the code app from source.
  • Python 3.10+ — to run the license-rule import scripts.
  • Copilot Studio / AI prompt capacity (Copilot Credits) for the AI flow, and a Dataverse connection for the flow.
  • End users of the app need Power Apps Premium (it is a code app).

Install

1. Import the solution

Import solution/PowerPlatformLicenseAdvisor_managed.zip for a normal deployment, or the unmanaged zip if you want to customize it.

pac auth create --environment https://YOUR-ORG.crm.dynamics.com
pac solution import --path solution/PowerPlatformLicenseAdvisor_managed.zip --activate-plugins

This brings the tables, the choices, the code app, and the NewQuestionGetAIAnswer cloud flow.

2. Configure connections, environment variables and turn on the flow

After import, in the target environment:

  • Connection reference — bind the flow's Dataverse connection reference to a connection in your environment.
  • Environment variables — set kn_SharePointSite and kn_LicenseDocumentLibrary (the flow's knowledge-source location) if you use the SharePoint grounding option.
  • AI prompt — ensure the flow's "Run a prompt" / Copilot Studio prompt is available and has Copilot Credit capacity.
  • Turn on the NewQuestionGetAIAnswer flow.

3. Seed the license rules (the knowledge base)

The solution ships the schema empty. Load the rules with the three import scripts (see Implementing the license rules below). Without rules, the Advisor has nothing to reason over and the Reference tab is empty.

4. (Optional) Load sample test scenarios

.venv\Scripts\python scripts\seed_advisorrun_tests.py

Adds 50 sample licensing questions (with owned licenses) to kn_advisorrun for testing/validation.

5. Run / redeploy the code app (only if building from source)

The app is included in the solution, but to develop or redeploy it from source:

cd app
npm install
npx power-apps init -n "License Advisor" -e <environment-id>   # first time only
npm run build
npx power-apps push

Implementing the license rules

The knowledge base is data — plain rows in kn_licenserule. Three idempotent import scripts (one per license family) are the source of truth; each ensures the product-choice options exist, then upserts every rule by name.

# from the repo root, with the Python virtual environment set up (see below)
.venv\Scripts\python scripts\import_license_rules_pp.py     # Power Platform
.venv\Scripts\python scripts\import_license_rules_d365.py   # Dynamics 365
.venv\Scripts\python scripts\import_license_rules_m365.py   # Microsoft 365

Each rule row has: product (choice), rule text (the dense paragraph injected into the AI prompt), pricing, source version, active flag, and sort order.

To update rules (e.g. a new licensing guide is published):

  1. Edit the RULES list in the relevant scripts/import_license_rules_*.py file, or edit rows directly in the Reference-backing table / Power Apps.
  2. Re-run that import script — it upserts by rule name, so edits are applied and new rules added.
  3. Both the Reference tab and the AI flow read the rules live, so changes take effect immediately (no redeploy).

Python environment for the scripts

python -m venv .venv
.venv\Scripts\python -m pip install requests azure-identity
# copy the config template and fill in your environment
copy customer.config.example.json customer.config.json
# set your Dataverse URL + tenant in .env (see .env.example)

The scripts authenticate with a browser sign-in (or a service principal via CLIENT_ID/CLIENT_SECRET in .env) and read envUrl / tenantId from customer.config.json.


Roadmap / notes

  • The AI flow (NewQuestionGetAIAnswer) is included; its prompt and grounding are yours to tune. The app is decoupled from it via the kn_responsejson contract, so you can swap the flow implementation freely.
  • Managed-solution promotion (DEV → TEST → PROD) with parameterized connection references and environment variables is the recommended ALM path.

Disclaimer

This tool provides indicative guidance only. It does not supersede your Microsoft volume licensing agreement or the Microsoft Product Terms. Always validate against the current licensing guide and Product Terms before purchasing. Licensing rules and pricing change frequently — keep kn_licenserule up to date.

Contributing

Issues and pull requests are welcome — especially updates to the licensing rules as new guides are published. Please keep rule text concise, cite the source guide in kn_sourceversion, and run the relevant import script to validate.

License

Released under the MIT License.

About

Power Platform License Advisory app that will give an answer on all your license questions

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages