log_incoming_parcel
Logs incoming parcels from OCR text or Firebase photo URLs, matches them to listed units, prevents duplicate entries for 4 hours, and schedules resident email alerts.
Instructions
Accepts parsed text from Google Cloud Vision OCR label scans and/or a trusted Firebase Storage photoUrl, cross-references internal Firestore unit listings, enforces a 4-hour idempotent lock on (trackingNumber + unitId), and schedules automated email alerts via SendGrid.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| qty | No | Number of parcels in this delivery (integer between 1 and 99). | |
| notes | No | Optional staff or carrier notes (maximum 1,999 characters). | |
| unitId | No | Optional explicit Firestore unit document ID under businesses/{businessId}/units/{unitId}. | |
| photoUrl | No | Public HTTPS Firebase Cloud Storage URL of the package photo. | |
| businessId | Yes | Tenant business identifier (must match the authenticated property businessId, 1-128 alphanumeric/dash/underscore chars). | |
| occupantId | No | Optional explicit occupant ID within the matched unit. | |
| rawOcrText | No | Raw OCR text extracted from a shipping label or envelope (up to 10,000 characters). | |
| typeOfMail | No | Package category: "letter" | "envelope" | "small box" | "big box" | "furniture/appliances" | "other". | small box |
| dateReceived | No | Optional ISO date received in YYYY-MM-DD format (defaults to current UTC date). | |
| timeReceived | No | Optional time received string (e.g. "2:30 PM", defaults to current UTC time). | |
| pickupMessage | No | Optional custom pickup location instruction included in the resident notification email (maximum 100 characters). | |
| trackingNumber | No | Optional explicit carrier tracking number (UPS 1Z..., Amazon TBA..., USPS, or FedEx). | |
| idempotencyMode | No | Behavior when the same (trackingNumber + unitId) was already logged within the last 4 hours ("merge" | "reject"). | merge |