Implementing Delivery Tracking Bot in Mobile Application
Package stuck on customs for third day — user doesn't know because tracker site shows last update "2 days ago" with no notifications. Delivery tracking bot turns passive waiting into active information.
Sources for Delivery Status Data
Each logistics company is separate API or scraping. Major players provide official APIs:
-
CDEK: REST API (
api.cdek.ru), OAuth 2.0, real-time statuses -
DHL: Tracking API (
api.dhl.com/track/shipments), API key -
FedEx: Track API v1 (
apis.fedex.com/track/v1/trackingnumbers) -
Russian Post: tracking via
tracking.russianpost.ru/rtm34(SOAP, unpleasant but works) - Boxberry, OZON Rocket — REST API with docs
For companies without official API or closed access use scraping via Puppeteer/Playwright on server — less reliable, breaks on site redesign, but works for MVP.
Polling System Architecture
Bot can't receive pushes from courier — must poll their API. Polling strategy:
- New tracking number: first 24 hours — poll every 30 minutes
- "In transit" status: every 2 hours
- "On sorting" or "On customs" status: every 4 hours
- "Delivered" status: stop tracking
Implement via scheduler (Bull Queue with delayed jobs). On each poll compare new status with last saved — if changed, send Telegram notification and FCM push to app.
Mobile App: Tracking UX
Main screen — list of active shipments with last status and update time. Tap shipment — detailed timeline with status history.
On Flutter build list via ListView.builder with Hive for local cache. Each item — card with color-coded status: green (delivered), orange (in transit), red (problem/delay).
Push notification on status change leads via deep link directly to specific shipment screen. On iOS via Universal Links, on Android via App Links with Intent and tracking_id parameter.
Handling Courier API Errors
Courier APIs aren't stable. CDEK periodically returns 500 for hours, Russian Post SOAP endpoint down for days.
Strategy: retry with exponential backoff (3 attempts at 5/15/60 min intervals). If three attempts fail — notify user: "Couldn't update status [Courier Name]. Will try later". Don't leave silent.
Integrating bot with 2–3 couriers and mobile client — 2–3 weeks. Supporting 10+ couriers with unified parser — 5–7 weeks.







