log_incoming_parcel
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). | |
| actor | No | Audit identity of the caller or AI agent triggering the mutation. | |
| notes | No | Optional staff or carrier notes (maximum 1,999 characters). | |
| unitId | No | Optional explicit Firestore unit document ID under businesses/{businessId}/units/{unitId}. If omitted, resolved deterministically from rawOcrText. | |
| photoUrl | No | Public HTTPS Firebase Cloud Storage URL of the package photo (must be hosted on firebasestorage.googleapis.com, storage.googleapis.com, or *.firebasestorage.app). Embedded in the resident notification email. | |
| 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. If omitted, resolved deterministically from rawOcrText. | |
| rawOcrText | No | Raw OCR text extracted from a shipping label or envelope (up to 10,000 characters). Used to extract tracking numbers and match unit/occupant. At least one of rawOcrText, photoUrl, or unitId is required. | |
| 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). Paired with unitId for 4-hour idempotent deduplication. | |
| idempotencyMode | No | Behavior when the same (trackingNumber + unitId) was already logged within the last 4 hours: "merge" increments qty on the existing pending parcel; "reject" returns REJECTED_DUPLICATE without modifying. | merge |