Project 2 — Intermediate
Invoice Processing Bot (PDF se ERP tak)
AP team ko roz 200 invoices milte hain — PDF, email me. Har invoice ka data manually ERP me type karna. Is project me bot banayenge jo email se invoice nikaale, data extract kare, aur ERP entry ke liye ready kare.
Project kya karega?
WHAT
Bot Outlook inbox monitor karega — "invoice" subject wale mails se PDF attachments download karega, PDF text se invoice number, date, vendor, GST number aur total amount nikaalega, aur sab ek tracking Excel me likhega. Low-confidence invoices ek review queue me jayengi.
WHEN
Accounts Payable departments me — har company ko vendors ki invoices process karni hoti hai. Ye RPA ki sabse zyada demand wali use case hai. Document Understanding (DU) projects India me tez badh rahe hain.
WHERE
BPOs, KPOs, finance shared services — invoice processing outsourcing ki duniya me RPA ka king project. Isko portfolio me rakho to AP automation roles me direct shortlist.
Step-by-step build
Main.xaml (Sequence)
|
+-- Try Catch
| +-- Sequence: Fetch Invoices
| | +-- Get Outlook Mail Messages
| | | Filter: "[SubjectContains]='invoice' AND [Unread]=true"
| | | -> dtMails
| | +-- For Each mail in dtMails
| | +-- Sequence: Process One Mail
| | +-- Save Attachments mail to "C:\Invoices\"
| | +-- For Each File: "C:\Invoices\*.pdf" -> pdfFile
| | +-- Read PDF Text pdfFile -> strText
| | +-- Assign: invNo = Regex.Match(strText,"INV-\d{6}").Value
| | +-- Assign: invDate = Regex.Match(strText,"\d{2}-\d{2}-\d{4}").Value
| | +-- Assign: total = Regex.Match(strText,"Total[:\s]*[\d,\.]+").Value
| | +-- Assign: gst = Regex.Match(strText,"\d{2}[A-Z]{5}\d{4}[A-Z]\d[A-Z\d][A-Z\d]").Value
| | +-- If invNo <> "" AND total <> ""
| | +-- Write Row: [invNo, invDate, gst, total, "OK"]
| | +-- Else
| | +-- Write Row: [pdfFile.Name, "", "", "", "REVIEW"]
| | +-- Mark mail as read
| +-- Catch (Exception)
| +-- Log Message LogLevel.Error ex.ToString
Regex se data nikalna
Har field ka apna pattern. Config.xlsx me rakho — vendor ke hisaab se badalna padta hai:
# Config.xlsx - Regex Patterns
Field Pattern
InvoiceNo INV-\d{6}
Date \d{2}-\d{2}-\d{4}
GSTNo \d{2}[A-Z]{5}\d{4}[A-Z]\d[A-Z\d][A-Z\d]
Total Total[:\s]*[\d,\.]+
# UiPath me: Assign activity + Regex.Match(strText, pattern).Value
# Agar match fail = Value "" -> REVIEW row me daal do, row fail mat karo
Ye rule-based extraction hai. Agar har vendor ka template alag hai (fonts, layouts), to UiPath Document Understanding use hota hai — ML Extractor + Keyword Extractor + Form Extractor ka ensemble, jo confidence score deta hai. DU ka validation station me human approve karta hai low-confidence fields.
Error handling
- Scanned PDF (image): Read PDF Text khaali dega — OCR engine (IntelligentOCR) chahiye. DU me ye automatic hai.
- Wrong total: Regex ne "Total" ki jagah "Subtotal" pakad liya — pattern me word boundary lagao, aur total vs subtotal ka sanity check (total >= subtotal) lo.
- Duplicate invoice: Tracker Excel me invoice number pehle se hai? Check karke skip — vendor ko dobara pay karne ka risk.
# Duplicate check - Invoke Code (LINQ) ya simple loop:
If dtTracker.AsEnumerable.Any(Function(r) r("InvoiceNo").ToString = invNo)
+-- Log Message LogLevel.Warning "Duplicate: " + invNo
+-- Continue For Each
Enterprise tips
- Invoices ko Orchestrator Queue me daalo (Dispatcher pattern) — alag Performer bot process karega. Scale kar sakte ho 10 robots tak.
- Low-confidence invoices Action Center task me bhejo — human approve kare, bot phir process karega. Ye DU + Action Center ka standard flow hai.
- Processed PDFs ko archive folder me move karo with date subfolder — audit ke liye zaroori.
- GST number ka regex 15-char format validate karo — fake invoices ka pehla filter yahi hai.
Exercise
Question: dd-mm-yyyy format ki date nikalne wala regex pattern batao.
Question: Document Understanding me low-confidence field ko human review ke liye kya use hota hai? (2 words max)
Common mistakes
- Har mail ko process karna: Subject filter lagao — support@ ki sab mails me invoice nahi hota.
- Regex hardcode: Config.xlsx me rakho — vendor template badalta hai, bot redeploy nahi karna padega.
- Duplicate payment risk: Invoice number uniqueness check na karna = seedha paisa ka nuksaan.
- OCR pe blind trust: OCR 100% accurate nahi — total amount ka cross-check zaroori hai.
Project ban gaya? Ab next project pe chalte hain — Web Data Extraction Bot.