Transform document processing in Dynamics 365 with AI-powered automation
A powerful Power Apps Component Framework (PCF) control that uses Azure OpenAI Vision to instantly extract data from business documents - invoices, receipts, forms, and more.
Upload a document image, and AI instantly extracts all important fields:
- β Invoices β Invoice #, date, vendor, amount, tax
- β Receipts β Merchant, date, total, items
- β Business Cards β Name, company, phone, email
- β Forms β All labeled fields automatically detected
- β ID Documents β Names, numbers, dates, addresses
No templates. No training. Just works. π
| Feature | Description |
|---|---|
| πΌοΈ Drag & Drop | Beautiful upload interface - drag or click to select |
| β‘ Real-time Processing | Live progress bar with processing status |
| π€ AI Extraction | Azure OpenAI Vision automatically finds all fields |
| π Confidence Scores | Each field shows how confident AI is (0-100%) |
| βοΈ Manual Override | Edit any field - changes marked as "Edited" |
| πΌοΈ Image Support | PNG, JPG, GIF, BMP, WebP formats supported |
-
Color-Coded Confidence:
- π’ Green (80-100%): High confidence, likely accurate
- π Orange (60-79%): Medium confidence, review recommended
- π΄ Red (<60%): Low confidence, verify carefully
-
Smart Status Tracking:
- βΈοΈ Ready: Waiting for document
- β³ Processing: AI is analyzing...
- β Completed: Data extracted successfully
- β Error: Problem occurred (with helpful message)
-
Beautiful UI: Modern design with smooth animations and responsive layout
- β No hardcoded credentials - all configuration via ControlManifest
- β Environment variable support for multi-environment deployments
- β Retry logic with exponential backoff (handles rate limits gracefully)
- β Comprehensive error handling with user-friendly messages
- β Follows Azure security and PCF best practices
- β Dynamics 365 or Power Apps environment
- β Azure OpenAI resource with GPT-4o or GPT-4o-mini deployed
- β PowerApps CLI (Install PAC CLI)
- β Node.js v14+ (Download)
- MSBuild (Visual Studio Build Tools)
- Admin access to D365 environment
git clone https://github.com/aindike/SmartDocumentProcessor.git
cd SmartDocumentProcessor
npm installnpm run buildExpected output: β
"Build succeeded" with bundle.js created
See detailed instructions in DEPLOYMENT_GUIDE.md π
Quick version:
# Create solution
mkdir Solutions && cd Solutions
pac solution init --publisher-name YourCompany --publisher-prefix new
pac solution add-reference --path ..\SmartDocumentProcessor
msbuild /t:build /restore
# Deploy
pac auth create --url https://yourorg.crm.dynamics.com
pac solution import --path bin\Debug\Solution.zip- Open form designer in D365
- Add a text field (e.g., "Document Data")
- Add Smart Document Processor component to the field
- Configure required properties:
- Azure OpenAI Endpoint:
https://YOUR-RESOURCE.openai.azure.com/openai/deployments/YOUR-DEPLOYMENT/chat/completions?api-version=2024-08-01-preview - Azure OpenAI API Key: Your API key from Azure Portal
- Azure OpenAI Endpoint:
- Save and publish
- Open a record with the control
- Drag & drop a document image (invoice, receipt, etc.)
- Watch AI extract the data in seconds! π
- PNG - Recommended for best quality
- JPG/JPEG - Good for photos
- GIF - Animated images (first frame used)
- BMP - Windows bitmap
- WebP - Modern web format
- PDF - Take a screenshot first
- Word (DOC/DOCX) - Convert to image or screenshot
- Excel - Screenshot the data
- Text files - Not image-based
π‘ Tip: For PDFs, open them and take a screenshot (Windows: Win+Shift+S), then upload the screenshot image.
Configure endpoint and API key directly in PCF control properties on the form.
β
Pros: Quick, easy
β Cons: Keys visible in form config (not for production)
Create environment variables in your solution:
- Go to make.powerapps.com β Solutions β New β Environment variable
- Create Azure OpenAI Endpoint variable (type: Text)
- Create Azure OpenAI API Key variable (type: Text, mark as Secret β )
- Bind control properties to these variables
- Update values per environment (dev/test/prod) without code changes
β
Pros: Secure, easy to manage, multi-environment
β Cons: Requires initial setup
| Model | Cost per Document* | Best For |
|---|---|---|
| GPT-4o | $0.009 | High accuracy, complex docs |
| GPT-4o-mini | $0.0005 | Budget-friendly, simple docs |
*Based on ~3,000 tokens per document image
| Usage | Documents/Month | Model | Monthly Cost |
|---|---|---|---|
| Small team | 500 | GPT-4o-mini | $0.25 |
| Medium team | 5,000 | GPT-4o | $45 |
| Large team | 50,000 | GPT-4o | $450 |
π‘ Save money: Start with GPT-4o-mini, upgrade to GPT-4o if you need better accuracy
Problem: Control shows config warning instead of upload area
Fix: Ensure both Azure Endpoint and API Key properties are configured in the control settings
Problem: Authentication failed
Fix:
- Verify API key is correct (copy fresh from Azure Portal)
- Ensure endpoint URL matches your deployment
- Check Azure OpenAI resource is active
Problem: "Too many requests" error
What This Means: You've exceeded your Azure OpenAI quota (Tokens Per Minute limit)
Immediate Fix:
- Wait 60 seconds and try again (control has automatic retry with delays)
Short-term Fix (Increase TPM in Azure):
- Go to Azure OpenAI Studio
- Select your deployment (GPT-4o or GPT-4o-mini)
- Click Edit deployment
- Increase Tokens per Minute (TPM) to 30K-60K
- Click Save and close
Long-term Fix (Request Quota Increase):
- Go to Azure Portal β Azure OpenAI resource
- Click Quotas in left menu
- Find your model and click Request quota increase
- Fill out form with business justification
- Wait for approval (usually 1-2 business days)
Prevention: Monitor usage in Azure Monitor, set up alerts for high usage
Problem: Upload fails with "invalid image URL" or "bad request" error
Root Cause: Azure OpenAI Vision API only accepts image formats (not PDFs or Word docs)
Fix:
- β Upload image files: PNG, JPG, GIF, BMP, WebP
- β Not supported: PDF, Word (DOC/DOCX), Excel, text files
Workaround for PDFs:
- Open PDF in your PDF viewer
- Take a screenshot (Windows:
Win + Shift + S, Mac:Cmd + Shift + 4) - Save screenshot as PNG or JPG
- Upload the screenshot image
Workaround for Word Docs:
- Open Word document
- Take screenshot of the page
- Upload screenshot image
Problem: Form shows field but not the custom control
Fix:
- Verify solution was imported successfully
- Check form was published (not just saved)
- Clear browser cache (Ctrl+F5)
- Verify PCF controls are enabled in environment settings
For detailed deployment instructions, see:
| Document | Purpose |
|---|---|
| DEPLOYMENT_GUIDE.md | Complete step-by-step deployment to D365 with checklists |
Problem: Manual invoice data entry is slow and error-prone
Solution: Upload invoice images, AI extracts invoice #, date, vendor, amount, line items
Benefit: Save hours per day, reduce data entry errors by 95%
Problem: Employees submit receipt photos that must be manually reviewed
Solution: Receipts auto-extracted to expense records with merchant, date, amount
Benefit: Faster reimbursement, better compliance tracking
Problem: Business cards from events must be manually typed into CRM
Solution: Snap photo of card, AI extracts name, company, phone, email to Contact
Benefit: No more lost leads, instant contact creation
Problem: Customer application forms require manual data entry
Solution: Upload filled form image, AI detects all labeled fields
Benefit: 10x faster processing, scale without adding staff
Problem: Patient intake forms need to be digitized
Solution: Scan forms, AI extracts patient info, insurance, symptoms
Benefit: More time with patients, less time on paperwork
# Install dependencies
npm install
# Build for production
npm run build
# Run linter
npm run lint
# Fix linting issues
npm run lint:fix
# Clean build artifacts
npm run clean
### Project Structure
SmartDocumentProcessor/ βββ ControlManifest.Input.xml # PCF manifest βββ index.ts # Control entry point βββ components/ β βββ SmartDocumentProcessorComponent.tsx # React UI βββ services/ β βββ AzureDocumentProcessor.ts # Azure OpenAI integration βββ types/ β βββ DocumentTypes.ts # TypeScript interfaces βββ css/ β βββ SmartDocumentProcessor.css # Styling βββ package.json # Dependencies
### Tech Stack
- **PCF Framework**: v1.x
- **React**: 18.x with TypeScript 5.8.3
- **Azure OpenAI**: GPT-4o Vision API
- **Axios**: 1.7.9 (HTTP client with retry logic)
- **Webpack**: 5.102.1
- **ESLint**: 9.x
---
## π Output Format
The control stores extracted data as JSON in the bound field:
```json
{
"documentType": "Invoice",
"fields": [
{
"name": "Invoice Number",
"value": "INV-2025-001",
"confidence": 98,
"isEdited": false
},
{
"name": "Invoice Date",
"value": "2025-01-15",
"confidence": 95,
"isEdited": false
},
{
"name": "Total Amount",
"value": "$1,234.56",
"confidence": 92,
"isEdited": true
}
],
"overallConfidence": 96,
"processingTime": 3500
}
The extracted data is saved to the text field you bound the control to in D365. When you click Save on the form:
- Control calls
getOutputs()method - Returns the JSON data shown above
- D365 saves it to the bound field (e.g., "Document Data")
- Data persists with the record
- You can access it via:
- Form scripts:
formContext.getAttribute("fieldname").getValue() - Workflows/Power Automate: Parse JSON from field
- Reports: Query the field like any other text field
- Form scripts:
| Document Type | Avg Processing Time | Typical Accuracy |
|---|---|---|
| Invoices | 3-5 seconds | 95-98% |
| Receipts | 2-4 seconds | 92-96% |
| Business Cards | 2-3 seconds | 90-95% |
| Forms | 5-8 seconds | 88-94% |
| Complex Docs | 8-15 seconds | 85-92% |
Based on GPT-4o with clear, well-lit images
β Do:
- Use PNG format for best quality
- Ensure good lighting
- Keep image resolution high (300 DPI recommended)
- Capture full document in frame
- Keep files under 10MB
β Don't:
- Use blurry photos
- Crop out important parts
- Use very compressed JPEGs
- Submit documents with glare
- Upload files over 10MB
- Never hardcode credentials - Use environment variables
- Rotate API keys regularly - Change every 90 days
- Monitor Azure costs - Set up budget alerts
- Use RBAC - Limit who can modify control settings
- Enable audit logging - Track all processing activities
- Consider data residency - Choose Azure region for compliance
- Optimize images before upload (compress if >5MB)
- Increase TPM quota in Azure (30K-60K recommended)
- Use GPT-4o-mini for simple documents (10x cheaper)
- Batch process during off-peak hours if possible
- Monitor retry rates to identify issues early
Before production deployment, test:
- Upload various document types (invoice, receipt, form)
- Test with different image formats (PNG, JPG, GIF)
- Verify confidence scores display correctly
- Edit fields and confirm "Edited" marker appears
- Save record and reload to verify data persists
- Test error handling with invalid files
- Test rate limit retry logic (429 errors)
- Verify environment variables work correctly
- Test on different screen sizes
- Check with users who have different security roles
- DEPLOYMENT_GUIDE.md - Complete step-by-step deployment instructions
- Power Apps PCF Documentation
- Azure OpenAI Documentation
- Power Platform Admin Center
- Azure Portal
- Power Apps Maker Portal
- Issues: Report bugs or request features on GitHub
- Questions: Contact your Power Platform administrator
- Updates: Watch this repository for new releases
- Image formats only - PDFs require screenshot conversion
- Single page only - Multi-page documents need separate uploads
- 10MB file limit - Technical constraint of PCF controls
- No batch processing - One document at a time
- Rate limits - Depends on Azure OpenAI quota (TPM)
Built with:
- β€οΈ Azure OpenAI - Powering the AI extraction
- β‘ Power Apps PCF - Control framework
- βοΈ React - UI framework
- π¦ TypeScript - Type safety
Special thanks to the Microsoft Power Platform and Azure OpenAI teams for their excellent tools and documentation.
β Star this repo if you find it helpful! β
Built with β€οΈ using Azure OpenAI and Power Platform
Made with π for the D365 Community