Here’s a detailed step-by-step plan for implementing your solution using Azure
Cognitive Services, Power Automate, Dataverse, and Power BI, tailored to
your requirements.
Phase 1: Setup and Configuration
Step 1: Set Up SharePoint Document Library
1. Create a SharePoint Site:
o Go to SharePoint and create a site or use an existing one.
o Add a Document Library named Contracts (or any relevant name).
2. Enable Metadata:
o Add custom metadata columns to the library (optional):
Upload Date (default: today's date).
Processed Status (to track processing state).
3. Upload Sample Contracts:
o Upload a few contracts to validate the setup and workflow.
Step 2: Set Up Azure Cognitive Services
1. Provision Azure Cognitive Services:
o Go to the Azure Portal.
o Create a Cognitive Services Resource:
Select Form Recognizer for document processing.
Select Text Analytics for key phrase and entity extraction.
o Choose a pricing tier (start with free/trial tier for testing).
2. Configure Form Recognizer:
o Use the prebuilt Document Model for unstructured contracts.
o Test with sample documents to verify key fields like tables, text, and
values are extracted.
3. Configure Text Analytics:
o Enable Key Phrase Extraction and Named Entity Recognition
(NER).
o Test extraction of entities like dates, monetary values, and products.
4. Obtain API Keys:
o Copy the API endpoint and keys for Form Recognizer and Text
Analytics.
Step 3: Set Up Dataverse
1. Access Dataverse via Power Platform:
o Go to Power Platform Admin Center.
o Create or use an existing environment for your Dataverse instance.
2. Create a Dataverse Table:
o Table Name: ContractsData.
o Columns:
DocumentID (Unique identifier from SharePoint).
FullText (Full document content).
DateExtracted (Date entity).
KeyPhrases (Extracted terms like products or clauses).
Amount (Monetary values).
AgreementType (e.g., service agreement, sales agreement).
Phase 2: Automate Workflow
Step 4: Set Up Power Automate Workflow
1. Trigger:
o Use a When a file is created or modified in a SharePoint Library
trigger.
o Point it to the Contracts library.
2. Process with Cognitive Services:
o Form Recognizer:
Add an HTTP Action in Power Automate.
Configure it to send the document to the Form Recognizer API
endpoint.
o Text Analytics:
Add another HTTP Action for Text Analytics.
Send extracted text from Form Recognizer to Text Analytics for
key phrases and entities.
3. Save Results:
o Dataverse:
Use the Dataverse connector in Power Automate.
Save extracted data (e.g., key phrases, amounts, dates) to the
ContractsData table.
o SharePoint Metadata:
Update metadata fields (e.g., Processed Status = "Completed").
4. Notify User:
o Add an action to send an email or Teams notification when processing
is complete.
Phase 3: Query and Visualization
Step 5: Create Power BI Dashboard
1. Connect Power BI to Dataverse:
o Open Power BI Desktop.
o Use the Dataverse Connector to connect to your environment.
o Load data from the ContractsData table.
2. Build Visualizations:
o Bar Chart:
X-axis: Product Names (from Key Phrases).
Y-axis: Frequency.
o Date Filter:
Use a slicer to filter by DateExtracted.
o Top Products by Revenue:
Use a table or matrix visualization to show Product, Amount, and
AgreementType.
3. Enable Dynamic Filters:
o Add slicers for:
AgreementType (e.g., Service Agreement).
DateExtracted.
Key Phrases.
4. Highlight Results:
o Use Power BI's conditional formatting to highlight contracts with high
amounts or specific clauses.
5. Publish the Dashboard:
o Publish to Power BI Service.
o Share the dashboard with stakeholders for real-time insights.
Step 6: Create Power Apps Query Interface (Optional)
1. Connect Power Apps to Dataverse:
o Use the ContractsData table as the data source.
2. Add Search Capabilities:
o Provide a search bar for free-text queries.
o Display filtered results in a gallery or list format.
3. Enable Dynamic Filters:
o Add dropdowns or sliders for parameters like:
DateExtracted.
AgreementType.
4. Launch the App:
o Publish the app and share it with your team.
Example Use Case: Query Insights
Query:
"Which product was most frequently sold in service agreements last quarter?"
Workflow:
1. Upload Contracts:
o Contracts are uploaded to SharePoint.
o Power Automate triggers processing through Cognitive Services.
o Extracted data is saved in Dataverse.
2. Query in Power BI:
o Filter by:
AgreementType = "Service Agreement."
DateExtracted = Last Quarter.
o Visualize:
Most frequent products in a bar chart.
3. Result:
o Power BI shows that Product X appeared in 50% of service agreements.
Summary of Tools
1. SharePoint: Document storage and metadata.
2. Azure Cognitive Services: Full-text and metadata extraction.
3. Dataverse: Advanced storage and querying.
4. Power Automate: Workflow orchestration.
5. Power BI: Insights and visualization.
6. Power Apps (optional): Dynamic search and filtering.
Here’s a detailed configuration guide to implement the solution step-by-step,
including Power Automate, Azure Cognitive Services, and Power BI.
Detailed Implementation Guide
1. Configure SharePoint Document Library
1. Create Document Library:
o Navigate to your SharePoint site.
o Create a new document library named Contracts.
2. Add Metadata Columns:
o Go to Library Settings → Create Column:
Processed Status: Choice (e.g., Pending, Completed).
Date Processed: Date/Time.
Other fields as needed for quick reference.
3. Upload Sample Documents:
o Upload a few contracts for testing purposes.
2. Set Up Azure Cognitive Services
Step 1: Provision Cognitive Services
1. Log in to the Azure Portal.
2. Create a Form Recognizer resource:
o Resource Group: Select or create one.
o Pricing Tier: Free or Standard (depending on scale).
o Region: Choose the closest available region.
3. Create a Text Analytics resource:
o Similar to the Form Recognizer setup.
Step 2: Collect API Keys
1. Navigate to the newly created resources.
2. Copy the Endpoint URL and API Key from the "Keys and Endpoint" section
for both Form Recognizer and Text Analytics.
3. Build Power Automate Workflow
Step 1: Start a Flow
1. Go to Power Automate → Create → Automated Cloud Flow.
2. Name the flow: Process Contracts.
3. Trigger: Select When a file is created in a folder (SharePoint).
4. Configure the trigger:
o Site Address: Select your SharePoint site.
o Folder: Point to the Contracts library.
Step 2: Extract Text Using Cognitive Services
1. Add Form Recognizer (HTTP):
o Action: HTTP.
o Method: POST.
o URL:
https://<your-form-recognizer-endpoint>/formrecognizer/documentMod
els/prebuilt-document:analyze?api-version=2022-08-31.
o Headers:
Ocp-Apim-Subscription-Key: Your Form Recognizer API key.
o Body:
o {
o "urlSource": "@{triggerOutputs()?['body']['{Link}']}"
o }
2. Parse JSON Results:
o Add Parse JSON action to handle the Form Recognizer response.
o Use the JSON schema provided by the Form Recognizer API.
Step 3: Extract Metadata Using Text Analytics
1. Add Text Analytics (HTTP):
o Action: HTTP.
o Method: POST.
o URL:
https://<your-text-analytics-endpoint>/text/analytics/v3.1/keyPhrases.
o Headers:
Ocp-Apim-Subscription-Key: Your Text Analytics API key.
o Body:
o {
o "documents": [
o {
o "id": "1",
o "text": "@{outputs('Parse_JSON')?['document']['content']}"
o }
o ]
o }
2. Parse JSON Results:
o Add another Parse JSON action to handle the Text Analytics response.
Step 4: Save Results to Dataverse
1. Add Dataverse Action:
o Action: Add a new row.
o Table Name: ContractsData.
o Map fields:
DocumentID: triggerOutputs()?['body']['ID'].
FullText: Output from Form Recognizer.
KeyPhrases: Output from Text Analytics.
DateProcessed: utcNow().
2. Update SharePoint Metadata:
o Add Update File Properties action.
o Set:
Processed Status: Completed.
Date Processed: utcNow().
Step 5: Notify Users
1. Add an email action:
o Subject: Contract Processing Completed.
o Body: Include file details and a link to Dataverse.
4. Configure Dataverse Table
1. Create a table named ContractsData:
o Fields:
DocumentID (Text).
FullText (Multiline Text).
KeyPhrases (Multiline Text).
Amount (Currency, optional).
DateProcessed (Date/Time).
2. Load data using the Power Automate flow.
5. Build Power BI Dashboard
Step 1: Connect to Dataverse
1. Open Power BI Desktop.
2. Go to Get Data → Dataverse.
3. Log in with your Microsoft account and select the ContractsData table.
Step 2: Create Visualizations
1. Bar Chart:
o X-axis: KeyPhrases (Products/Clauses).
o Y-axis: Count of DocumentID.
2. Date Filter:
o Add a slicer for DateProcessed.
3. Contracts by Type:
o Use a pie chart to visualize agreement types (if available).
4. Dynamic Filtering:
o Add slicers for:
KeyPhrases.
DateProcessed.
Step 3: Publish to Power BI Service
1. Save and publish your report to Power BI Service.
2. Share the dashboard with stakeholders.
6. Test the Solution
1. Upload a sample contract to SharePoint.
2. Verify:
o Power Automate triggers processing.
o Extracted data is saved in Dataverse.
o SharePoint metadata is updated.
o Power BI reflects processed data.
Let me know if you’d like a sample JSON schema, Power BI visualization
templates, or further details on any specific step!
Here’s a detailed supplement with JSON schema examples, Power BI
visualization templates, and specific details for the steps provided earlier.
1. JSON Schema for Parsing Cognitive Services Outputs
Form Recognizer (Prebuilt Model):
The response from Form Recognizer includes document structure, key-value pairs,
and tables. Below is a simplified JSON schema you can use in Power Automate:
{
"type": "object",
"properties": {
"status": { "type": "string" },
"analyzeResult": {
"type": "object",
"properties": {
"content": { "type": "string" },
"keyValuePairs": {
"type": "array",
"items": {
"type": "object",
"properties": {
"key": { "type": "string" },
"value": { "type": "string" }
}
}
},
"tables": {
"type": "array",
"items": {
"type": "object",
"properties": {
"rows": { "type": "array", "items": { "type": "string" } }
}
}
}
}
}
}
}
Text Analytics (Key Phrases):
Use the following schema for parsing the output of Key Phrase Extraction:
{
"type": "object",
"properties": {
"documents": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": { "type": "string" },
"keyPhrases": {
"type": "array",
"items": { "type": "string" }
}
}
}
}
}
}
2. Sample Data Output
Dataverse Table: ContractsData
After processing, the extracted data will look like this in Dataverse:
Document DateProcesse Amou
FullText KeyPhrases
ID d nt
"The agreement covers ["Product A", 2025-01-01
101 15000
Product A and B..." "Product B"] 15:00:00
"The contract includes ["termination 2025-01-01
102 20000
termination clause" clause"] 15:00:00
3. Power BI Visualization Templates
Bar Chart: Most Frequent Key Phrases
X-Axis: KeyPhrases.
Y-Axis: Count of DocumentID.
Filter: Add a slicer for DateProcessed to filter phrases by time.
Contracts by Type
Visualization Type: Pie Chart.
Field: Agreement Type (e.g., Service Agreement vs. Sales Agreement).
Time-Series Analysis
Visualization Type: Line Chart.
X-Axis: DateProcessed.
Y-Axis: Total Amount.
Filter: Key Phrases (optional).
Interactive Filters
Add slicers for:
o KeyPhrases (e.g., "Product A").
o Agreement Type.
o DateProcessed.
4. Power Automate Flow: Detailed Actions
HTTP Request to Form Recognizer
1. Action: HTTP (Premium).
2. Endpoint:
o Replace <your-form-recognizer-endpoint> with the actual URL.
3. https://<your-form-recognizer-endpoint>/formrecognizer/documentModels/
prebuilt-document:analyze?api-version=2022-08-31
4. Headers:
o Key: Ocp-Apim-Subscription-Key
o Value: <Your API Key>
5. Body:
6. {
7. "urlSource": "@{triggerOutputs()?['body']['{Link}']}"
8. }
HTTP Request to Text Analytics
1. Action: HTTP (Premium).
2. Endpoint:
3. https://<your-text-analytics-endpoint>/text/analytics/v3.1/keyPhrases
4. Body:
5. {
6. "documents": [
7. {
8. "id": "1",
9. "text": "@{outputs('Parse_JSON')?['analyzeResult']['content']}"
10. }
11. ]
12.}
Parse JSON Action
Content:
o Use outputs from the HTTP request.
Schema:
o Use the provided JSON schemas above for Form Recognizer or Text
Analytics.
Dataverse Update
Add a row with:
o DocumentID: @{triggerOutputs()?['body']['ID']}
o FullText: @{outputs('Parse_JSON')?['analyzeResult']['content']}
o KeyPhrases: @{outputs('Parse_JSON_2')?['documents'][0]
['keyPhrases']}
5. Publish Power BI Dashboard
Steps:
1. Connect to Dataverse:
o Open Power BI → Get Data → Select Dataverse.
o Authenticate with your Microsoft 365 credentials.
o Select the ContractsData table.
2. Create Visualizations:
o Add a Bar Chart for Key Phrases.
o Add Slicers for Agreement Type and Date Processed.
o Use Table Visualization for document details.
3. Publish:
o Click Publish → Select your Power BI Workspace.
o Share the dashboard link with stakeholders.
Testing Workflow
1. Upload Test Contracts:
o Upload contracts to SharePoint with different types and content.
2. Run the Flow:
o Verify that the workflow extracts full text, key phrases, and metadata.
o Check Dataverse for the saved data.
3. Visualize in Power BI:
o Verify that all fields appear in Power BI and the visualizations update
dynamically.
Optional Enhancements
1. Semantic Search:
o Use Azure Cognitive Search to enable natural language queries.
2. Custom Power Apps:
o Build an app for interactive querying and results validation.
3. Alerts:
o Add Power Automate notifications for specific phrases (e.g.,
"termination clause").
Let me know which part you'd like additional clarification or examples for!