AI Can Do Everything, But Not Everything Should Be AI
Billy Peralta
June 12, 2026
AI can read documents, extract values, summarize emails, and understand images. But in enterprise automation, the better question is not always “Can AI do this?”
The better question is:
Should AI be used for this, or is there a simpler, cheaper, and more predictable way?
I ran into this type of scenario with a department that received PDF attachments through a shared mailbox. The business process was simple: extract an order number from the PDF and write it into the right system.
Could AI read the PDF and find the order number? Yes.
But that did not automatically make AI the best solution.
TL;DR
For predictable document-processing tasks, AI is not always the most efficient option.
If the job is simply to extract an order number from a known PDF or image layout, a small Azure Function API using image recognition, OCR, and validation rules can be cheaper, faster, and easier to troubleshoot than sending every file to an AI model.
The key idea:
AI cost scales with tokens. A focused API scales mostly with execution time.
Table of Contents
- The Business Problem
- Why AI Was Not the First Choice
- The Hidden Cost of Sending Files to AI
- A Better Pattern: Azure Function API with OCR
- Example Architecture
- Rough Cost Comparison
- When AI Still Makes Sense
- Final Thoughts
The Business Problem
A department receives PDF attachments through a shared mailbox. Each PDF contains an order number that needs to be captured and saved into another system.
The process sounds simple, but doing it manually creates problems:
- Users need to open each email.
- Users need to download or preview the PDF.
- Users need to find the order number.
- Users need to copy and paste it into another system.
- Mistakes can happen when volume increases.
This is a good automation candidate because the task is repetitive, rules-based, and high-volume.
Why AI Was Not the First Choice
AI could read the document and return the order number. But this task does not require reasoning, summarization, or natural language understanding.
The requirement is more specific:
Find the order number, validate it, and return a structured result.
For this type of workflow, a deterministic API can be a better fit.
Instead of asking an AI model to interpret every PDF, we can build a small API that does one job very well:
- Receive the PDF or image attachment.
- Convert the PDF page to an image if needed.
- Run image recognition or OCR.
- Extract text from the expected area.
- Use regex or business rules to find the order number.
- Return a JSON response.
- Log the result for monitoring and troubleshooting.
This is not about being anti-AI. It is about choosing the right tool for the job.
The Hidden Cost of Sending Files to AI
One thing teams sometimes forget is that AI cost is not only based on the text prompt.
When a file, scanned PDF page, screenshot, or image is sent to an AI model, that content is processed as input. Larger images, higher-resolution scans, multi-page PDFs, and repeated retries can increase usage quickly.
For a one-off document, that may not matter. But if a department processes thousands of shared mailbox attachments every month, the cost can add up.
A simple prompt like this may look cheap:
Extract the order number from this PDF and return JSON.
But the actual cost can include:
- Image or file input
- Text prompt tokens
- Output tokens
- Retry attempts
- Validation prompts
- Multi-page PDF processing
- Failed extraction fallback logic
This is why AI cost can be harder to estimate for high-volume document workflows.
A Better Pattern: Azure Function API with OCR
A better pattern for this scenario is to create a lightweight API using Azure Functions.
The Azure Function can expose an endpoint like this:
POST /api/extract-order-number
The function receives the file, performs OCR or image recognition, validates the result, and returns a clean response:
{
"orderNumber": "ORD-104928",
"confidence": 0.96,
"method": "azure-function-ocr-regex",
"status": "success"
}
This keeps the solution focused, predictable, and easier to integrate with Microsoft 365.
Example free or open-source libraries that can help:
| Runtime | Example Libraries |
|---|---|
| Node.js | Tesseract.js, sharp, pdf-lib, pdf-poppler |
| .NET | Tesseract OCR wrappers, ImageSharp, PdfPig, Ghostscript.NET |
| OCR Engine | Tesseract OCR |
Tesseract.js can run in the browser or on a server with Node.js and supports OCR for more than 100 languages. Tesseract OCR is also a widely used open-source OCR engine.
Example Architecture
Shared Mailbox
↓
Power Automate or Microsoft Graph listener
↓
PDF attachment is retrieved
↓
Azure Function API is called
↓
PDF is converted to image if required
↓
OCR / image recognition extracts text
↓
Regex finds the order number
↓
Business rules validate the result
↓
JSON response is returned
↓
Order number is saved to SharePoint, Dataverse, SQL, or another system
↓
Application Insights logs success/failure
This approach gives the organization more control over the workflow.
You can log:
- File name
- Processing time
- Extracted value
- Confidence score
- Validation result
- Failure reason
- Retry count
That matters in real enterprise environments because supportability is just as important as automation.
Rough Cost Comparison
Assume the department processes 10,000 documents per month.
Option 1: AI-Based Extraction
If each document uses around 1,000 tokens after image input, prompt, and response, the monthly usage could look like this:
10,000 documents x 1,000 tokens = 10,000,000 tokens/month
The actual cost depends on the model, image size, detail level, number of pages, and output length.
The point is not that AI is always expensive. The point is that the cost scales with the amount of content being sent to the model.
AI cost can increase based on:
- File size
- Image resolution
- Number of pages
- Prompt length
- Output length
- Retries
- Validation calls
Option 2: Azure Function API with OCR
Azure Functions consumption pricing is based on executions and resource consumption, such as memory and execution time.
Example estimate:
Memory: 1 GB
Runtime: 5 seconds
Usage: 5 GB-seconds per document
10,000 documents x 5 GB-seconds = 50,000 GB-seconds/month
With a lightweight OCR-based API, the cost is usually driven more by execution time than by token volume. For predictable layouts and simple extraction rules, this can be much easier to estimate and control.
This does not mean the API is free. You may still have costs for Azure Functions, storage, logging, monitoring, and any supporting services. But for a focused workflow, it can be significantly cheaper and more predictable than using a general AI model for every document.
When AI Still Makes Sense
AI is still the right choice when the document requires reasoning or flexible understanding.
For example, AI may be better when:
- The document layout changes often.
- The content is unstructured.
- The system needs to summarize the document.
- The workflow needs to understand intent.
- The data cannot be extracted reliably with OCR and rules.
- The process needs classification, explanation, or decision support.
But if the requirement is simply:
Extract this one value from a predictable document layout.
Then a smaller API may be the better engineering decision.
Final Thoughts
AI is powerful, but not every automation problem needs AI.
In this shared mailbox example, the goal was not to understand the whole document. The goal was to extract an order number, validate it, and move the process forward.
A focused Azure Function API using OCR, image recognition, and business rules can be:
- Cheaper
- Faster
- Easier to monitor
- Easier to troubleshoot
- Easier to secure
- More predictable
That is the real lesson:
Use AI when the problem needs AI. Use automation when the problem needs automation.
For Microsoft 365 and SharePoint solutions, the best architecture is not always the most advanced one. It is the one that solves the business problem reliably, securely, and at the right cost.
References
Need help applying this in a real Microsoft 365 environment?
I help organizations turn technical fixes into maintainable SharePoint, SPFx, and Power Platform solutions that internal teams can support.
Billy Peralta
SharePoint & Microsoft 365 Specialist • 16+ Years Experience
If you have questions about your SharePoint environment, feel free to reach out.
Need help applying this in a real Microsoft 365 environment?
I help organizations turn technical fixes into maintainable SharePoint, SPFx, and Power Platform solutions that internal teams can support.