Your cart is currently empty!
How a Company in São Paulo Solved 22+ Hours/Week Document Classification Using OpenAI Agents
How a Company in São Paulo Solved a Problem Where a Company Spent More Than 22 Hours Per Week Classifying Incoming Documents Manually Using OpenAI Agents
In today’s fast-paced business environment, handling large volumes of incoming documents efficiently is crucial. 📄 A mid-sized financial services company in São Paulo was struggling with a tedious manual document classification process that consumed over 22 hours every week. This bottleneck led to operational delays, high error rates, and frustration among their operations team.
This case study explores how RestFlow helped this São Paulo-based company automate their document classification process using OpenAI Agents integrated within a workflow orchestrated by n8n. You will learn the technical approach, step-by-step workflow details, and how leveraging Automation-as-a-Service transformed the client’s operations.
Whether you’re a startup CTO, automation engineer, or operations specialist, this detailed analysis offers practical insights on building robust automation workflows that combine machine learning AI models with practical business tools like Gmail, Slack, and Google Sheets.
Case Context & Problem
The client is a mid-sized financial services company headquartered in São Paulo, Brazil. Their operations department was responsible for processing incoming documents – mainly client forms, contracts, invoices, and regulatory paperwork sent via email and uploaded to a cloud storage system.
Before automation, the classification process was entirely manual. The team spent more than 22 hours per week sorting documents into categories, tagging them with metadata, and entering relevant information into internal systems. The manual approach led to numerous challenges:
- High labor costs due to repetitive manual work
- Errors and misclassification that impacted compliance and client satisfaction
- Delayed turnaround times that affected SLAs
- Lack of real-time visibility into processing status
The operational team struggled to keep up, and this inefficiency was a barrier to scaling the business further in a competitive market.
Quantitatively, the team was spending roughly 90 hours per month on classification alone, with an error rate estimated at around 8% that required rework. This situation impacted revenue indirectly by delaying onboarding and invoice processing.
RestFlow was engaged to tackle this persistent issue with an intelligent, scalable automation solution.
Our Approach (The Proposal)
We started with a comprehensive discovery phase, collaborating closely with operations managers and IT teams to map out the entire document handling process. This involved:
- Identifying all sources of incoming documents (Gmail, cloud storage)
- Reviewing existing manual classifications and error patterns
- Analyzing the downstream integration points (CRM, ERP, Google Sheets for reporting)
Given the unstructured nature of documents and the need for intelligent classification, we proposed an automation architecture combining:
- n8n as the central orchestration platform allowing modular, scalable workflow design
- OpenAI Agents to perform natural language processing and categorization tasks
- Integration with Gmail for incoming emails and Google Drive for uploaded files
- Slack for real-time alerts and updates to the operations team
- Google Sheets for audit logs and reporting
We chose n8n due to its open-source flexibility and ease of integrating with APIs and services, allowing sophisticated conditional logic and branching.
Using OpenAI Agents provided a powerful AI-driven classification engine capable of parsing diverse document formats and extracting relevant data, drastically reducing manual intervention.
Explore the Automation Template Marketplace to find similar intelligent workflow templates you can adapt for your business.
The Solution: Architecture & Workflow
Global Architecture Overview
- Triggers: New incoming emails matching document criteria or file uploads to Google Drive folder
- Orchestration: n8n implementation managing workflow logic, API calls, and conditional processing
- AI processing: OpenAI Agents used to analyze document text, classify type, and extract metadata
- Integrations: Gmail, Google Drive, Google Sheets, Slack for notifications, internal CRM
- Outputs: Categorized documents stored in appropriate cloud folders, classification logs in Sheets, Slack alerts for exceptions or errors
End-To-End Workflow Walkthrough
The workflow starts when a new email arrives to the shared Gmail inbox or when a file is uploaded to a monitored Google Drive folder. n8n listens to these triggers and pulls the document content.
Next, the document content is sent to OpenAI Agents via secure API calls. The AI model classifies the document type (e.g., contract, invoice, form), extracts relevant fields, and returns structured JSON data.
Based on classification results, n8n routes documents to appropriate Google Drive folders and updates a Google Sheet record to maintain an audit trail.
Slack notifications alert the operations team if document confidence scores fall below a threshold, enabling quick manual review.
Finally, classified data is fed into the client’s CRM system to update client records and initiate any follow-up workflows.
Step-by-Step Node Breakdown 🚀
1. Gmail / Google Drive Trigger
This node listens for:
- New emails with specific labels or arriving in the shared inbox
- New files uploaded to a predetermined Google Drive folder
It pulls attachments or email body content as input for classification.
2. Document Extraction & Validation
The content of the document is extracted using PDF/Text parsing nodes inside n8n. Validation logic checks for:
- File format compatibility
- Document completeness
- Basic sanity checks on content length
3. OpenAI Agent Classification 🧠
This critical node sends the extracted text to an OpenAI Agent via API call. Key configurations include:
- Endpoint set to OpenAI’s classification model (e.g., GPT-4 with classification fine-tuning)
- Headers containing authorization tokens stored securely in n8n credentials
- Prompt templates tailored to extract document type, key metadata fields like date, client ID, contract numbers
- Response mapped back as JSON with fields: document_type, extracted_fields, confidence_score
4. Conditional Routing & Storage 📁
Depending on document_type and confidence_score:
- If score > 80%, move file to approved Google Drive folder (e.g., “Contracts”, “Invoices”)
- If score < 80%, send Slack alert for manual review
5. Google Sheets Logging
Append a new row to a Google Sheet tracking processed documents including metadata:
- Document ID
- Type
- Processing timestamp
- Confidence score
- Status (classified, manual review)
6. CRM Update
Create or update client records with new document data in the CRM via API calls. Use filters such as Find contact by email to avoid duplicates.
7. Slack Notifications 📢
Send messages to operations channel with results or flags. Includes error handling messages if API calls fail.
Error Handling, Robustness & Security
Error Handling & Retries
The workflow includes robust try-catch nodes in n8n ensuring retries up to three times with exponential backoff. Failures are logged centrally and trigger Slack alerts for immediate investigation.
Logging & Observability
All transactions are logged into Google Sheets and n8n’s native workflows with detailed timestamps and statuses. RestFlow’s hosted monitoring dashboard tracks workflow health and generates alerts.
Idempotency & Deduplication
Unique IDs for documents prevent duplicate processing. The system checks the audit log before processing new inputs.
Security & Data Protection
- API keys and tokens stored securely in n8n credentials vault with least privilege scopes
- All PII data masked or encrypted at rest following client policies
- Access restricted to authorized RestFlow engineers and client admins
- Audit trails maintained for compliance
Performance, Scaling & Extensibility
The system design supports horizontal scaling using webhooks that trigger in near real-time rather than polling, reducing latency and resource consumption.
Batch processing capabilities were built in for high-volume days, with concurrency limits to avoid rate limiting from third-party APIs such as OpenAI.
The workflow is modular, making it easy to:
- Add new document categories or fields
- Integrate additional tools like ERP or billing software
- Deploy separate instances for new teams or regions
Comparison Tables
| Option | Cost | Pros | Cons |
|---|---|---|---|
| n8n | Free (self-hosted) / Paid cloud | Open source, customizable, strong API integrations, supports complex logic | Requires some technical setup, less polished UI than SaaS |
| Make | Starts free, paid tiers based on operations | Great visual builder, many app connectors, powerful scenarios | Pricing can be high at scale, slightly less flexible for custom code |
| Zapier | Starts free, pricing increases with tasks | Easy to use, large app ecosystem, quick setup | Limited branching, expensive at volume, less suited for complex logic |
| Integration Method | Latency | Resource Usage | Reliability |
|---|---|---|---|
| Webhooks | Millisecond-level real-time | Low, event-driven | High, immediate trigger |
| Polling | Minutes to hours | Higher, periodic checks | Medium, risk of missed events |
| Storage | Cost | Ease of Access | Best Use Case |
|---|---|---|---|
| Google Sheets | Low to mid | Easy, accessible via API | Small to medium datasets, audit logs |
| Database (SQL/NoSQL) | Medium to high | Requires more setup | Large datasets, complex queries, transactional integrity |
Results & Business Impact
Deploying the automated document classification workflow produced remarkable outcomes:
- Time savings: Reduced manual classification time from 22+ hours to under 2 hours per week
- Error rate: Dropped from approximately 8% to less than 1%, improving data accuracy and compliance
- Turnaround: SLA adherence improved by 65%, accelerating client onboarding and invoice processing
- Visibility: Real-time dashboards and Slack alerts empowered operations managers to proactively manage exceptions
Operations staff shifted from monotonous sorting to exception handling and process improvement, increasing job satisfaction and productivity.
These key performance improvements validated the RestFlow approach of combining AI-powered categorization with a flexible orchestration platform.
Pilot Phase & Maintenance Disclaimer
It is important to highlight that the automation rollout included a carefully managed pilot phase lasting four weeks. During this phase:
- The workflow ran with real yet controlled document volumes
- Minor bugs, edge case logic, and API integration tweaks were addressed based on operational feedback
- Training was delivered to users for review and validation of classified documents
Following the successful pilot, RestFlow took over the hosting, monitoring, regular updates, and ongoing maintenance of the automation workflow. This ensures continuous reliability, performance tuning, and seamless adaptation to changing client needs.
This approach underscores that while automation dramatically reduces manual workload, human involvement and continuous improvements remain integral to long-term success.
Frequently Asked Questions
How did the company in São Paulo solve the problem of spending more than 22 hours per week manually classifying incoming documents using OpenAI Agents?
The company implemented an automation workflow using n8n to orchestrate document intake, which sent document content to OpenAI Agents for intelligent classification. The AI classified documents, extracted metadata, and integrated results with Google Drive, Sheets, Slack, and CRM systems. This saved many manual hours and reduced errors substantially.
Which tools were integrated in the automation to solve document classification?
The workflow integrated Gmail for email retrieval, Google Drive for storage, OpenAI Agents for AI classification, Slack for notifications, Google Sheets for logging, and the client’s CRM to update client data. n8n served as the orchestration platform connecting these services.
What are the key benefits for operations teams using this automated classification system?
Operations teams benefit from dramatically reduced manual workload, fewer classification errors, faster processing times, and real-time visibility into document status. They can focus on handling exceptions and improving overall process efficiency.
How does RestFlow ensure security and data protection in this automation?
RestFlow uses secure credential storage, applies least-privilege API scopes, encrypts sensitive information, restricts access to authorized personnel, and maintains audit logs to comply with data protection policies.
Is there a pilot phase involved before full implementation of this workflow?
Yes, a pilot phase running the automation with real but controlled volumes was conducted. During this phase, RestFlow fine-tuned the workflow, fixed edge cases, and trained users before moving to full production and managed maintenance.
Conclusion
This case study demonstrated how a São Paulo-based financial services company overcame a significant operational bottleneck, where more than 22 hours per week were spent on manual document classification. Leveraging powerful OpenAI Agents combined with the flexible and scalable n8n workflow orchestrator, the client achieved radical reductions in processing time and error rates.
The RestFlow team’s holistic approach — from process discovery, intelligent architecture design, seamless integration with existing business tools, to ongoing managed hosting and monitoring — was key to this success.
If you are facing similar challenges with document overload or manual processing, know that comprehensive automation solutions exist that can transform operations efficiently.
Ready to streamline your workflows with intelligent automation? Explore the Automation Template Marketplace to find pre-built workflows or Create Your Free RestFlow Account to start automating today.