Skip to content

crcnum4/UP_Email_Processor

Repository files navigation

Meridian Email Processor

Dispatcher | UiPath REFramework | Unattended

The first stage in the Meridian Loan Processing pipeline. This automation monitors an email inbox for incoming loan applications, extracts structured data from each message, generates a unique application ID, persists both raw and structured records to MongoDB, and dispatches work items to the downstream Prescreen queue in UiPath Orchestrator.


Features

  • Email Intake via API -- Retrieves messages from Mailpit using its REST API with configurable batch size, basic auth, and retry logic
  • Atomic ID Generation -- Produces human-readable application IDs (APP-YYYY-NNNNNN) using MongoDB findAndModify with year-scoped counter documents -- no race conditions, automatic year rollover
  • Dual-Write Persistence -- Saves the raw email and the extracted application record as separate MongoDB documents for independent auditability
  • Queue Dispatch -- Adds each processed application to the PrescreenedApplications Orchestrator queue with the application ID as the business key
  • Inbox Cleanup -- Deletes processed messages from the mail server after successful extraction to prevent reprocessing
  • REFramework Foundation -- Full state-machine lifecycle: initialization, config loading, exception handling, retry logic, and structured logging

Process Flow

Start
  |
  v
[Initialize]
  |- Load Config.xlsx settings + Orchestrator Assets
  |- Set up Mailpit credentials (Global Variables)
  |
  v
[Get Transaction Data]
  |- First pass: GET /messages from Mailpit API (batch)
  |- Subsequent passes: Index into cached message list
  |- For each message: GET /message/{ID} for full content
  |- If no messages remain --> End Process
  |
  v
[Process Transaction]
  |- Deserialize email JSON response
  |- Parse email body into structured loan application fields
  |- Generate atomic Application ID (MongoDB findAndModify)
  |     Counter: applicationId_{YEAR} --> APP-YYYY-NNNNNN
  |- Assign AppId + Status ("PrescreenQueue") to application record
  |
  |- MongoDB Writes:
  |     |- Insert structured record --> "applications" collection
  |     |- Insert raw email --> "RawEmails" collection
  |
  |- DELETE /messages (processed email) from Mailpit
  |- Add Queue Item --> "PrescreenedApplications" (Orchestrator)
  |
  v
[Set Transaction Status]
  |- Success / Business Exception / System Exception
  |- Loop back to Get Transaction Data
  |
  v
End Process

Tools & Technologies

Component Technology
RPA Platform UiPath Studio 26.0 (Windows target)
Framework REFramework (Robotic Enterprise Framework)
Email Server Mailpit (local SMTP/API -- production: Microsoft Graph / Exchange Online)
Database MongoDB (via InternalLabs.MongoDB.Activities)
HTTP UiPath WebAPI Activities (REST calls with retry policies)
Queue UiPath Orchestrator Queue (PrescreenedApplications)
Config REFramework Config.xlsx + Orchestrator Assets

Key Workflows

File Purpose
Main.xaml REFramework state machine entry point
Framework/InitAllSettings.xaml Loads Config.xlsx and Orchestrator assets
Framework/GetTransactionData.xaml Fetches email list on first run, iterates per transaction
Framework/Process.xaml Invokes ExtractData for the current transaction
Framework/SetTransactionStatus.xaml Reports Success / Exception back to framework
Meridian/GetEmails.xaml HTTP GET to Mailpit API -- returns message list as List(JObject)
Meridian/GetEmail.xaml HTTP GET for a single email by ID -- returns full content
Meridian/ExtractData.xaml Parses email, generates ID, dual-writes to MongoDB, queues item
Meridian/GetApplicationId.xaml Atomic counter via MongoDB runCommand (findAndModify)

Queue Schema

The dispatcher adds items to PrescreenedApplications with the following payload:

Field Type Description
AppId string Unique application identifier (e.g., APP-2026-000042)
ProcessedDate string (date-time) Timestamp of processing

The AppId serves as the queue item Reference, enabling downstream correlation.


Configuration

Settings are managed through the standard REFramework Config.xlsx with key fields:

Setting Purpose
MailApiUrl Mailpit API base URL
EmailLimit Number of emails to fetch per batch
DBConnection MongoDB connection string
Database MongoDB database name
OrchestratorQueueName Target queue for dispatched items
OrchestratorQueueFolder Orchestrator folder path
RetryNumberGetTransactionItem Retry count for transaction retrieval

Mailpit credentials are stored as Global Variables (MpUser, MpPass) loaded during initialization.


Design Decisions

  • API over IMAP -- Mailpit's REST API provides structured JSON responses, making extraction reliable and testable. Production migration to Microsoft Graph is a connection-string change, not an architectural one.
  • MongoDB as system of record -- Queues are coordination primitives, not databases. The Orchestrator queue carries only the AppId and routing hints; MongoDB holds the durable truth.
  • Dual-write pattern -- The raw email is preserved separately from the extracted application record. This supports regulatory defensibility: the raw email is the source-of-truth artifact for what the applicant actually submitted.
  • Year-scoped counters -- The applicationId_{YEAR} counter document rolls over automatically on January 1st with no scheduled reset job or migration.

Pipeline Context

This is Stage 1 of the Meridian Loan Processing pipeline:

[Email Processor] --> [Loan Prescreen] --> [Loan Assigner] --> [Underwriter Dashboard]
     (this)            Triage/Route        HITL Assignment      Attended Workspace

The downstream Loan Prescreen performer picks up items from the PrescreenedApplications queue to evaluate and route applications.


Dependencies

InternalLabs.MongoDB.Activities  [1.0.1]
UiPath.Excel.Activities          [3.4.1]
UiPath.Mail.Activities           [2.8.10]
UiPath.System.Activities         [26.2.4]
UiPath.Testing.Activities        [25.10.2]
UiPath.UIAutomation.Activities   [25.10.30]
UiPath.WebAPI.Activities         [2.4.0]

About

No description, website, or topics provided.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors