AI agent that tracks parcels across couriers, provides real-time status updates, and flags delivery exceptions.
import requests, json, datetime
COURIER_APIS = {
"J&T": "https://api.jtexpress.my/v2/tracking",
"PosLaju": "https://api.pos.com.my/v1/parcels",
"DHL": "https://api.dhl.com.my/v1/shipments",
"GDEX": "https://api.gdexpress.com/v2/track"
}
STATUS_MAP = {
"PU": "Picked Up", "IT": "In Transit",
"OD": "Out for Delivery", "DL": "Delivered",
"EX": "Exception", "DE": "Delayed"
}
def track_parcel(tracking_id, courier):
api = COURIER_APIS.get(courier)
resp = requests.get(f"{api}/{tracking_id}")
data = resp.json()
raw_status = data.get("status", "UNKNOWN")
normalized = STATUS_MAP.get(raw_status, "Unknown")
eta = data.get("estimated_delivery")
is_delayed = eta and datetime.date.fromisoformat(eta) < datetime.date.today()
return {
"id": tracking_id,
"status": normalized,
"location": data.get("location", "N/A"),
"est": eta,
"delayed": is_delayed,
"courier": courier
}
parcels = ["SHIP-1001", "SHIP-1002", "SHIP-1003", "SHIP-1004"]
results = [track_parcel(p, c) for p, c in zip(parcels, ["J&T","PosLaju","DHL","GDEX"])]
print(json.dumps(results, indent=2))
Basic Package
Special SME traction programme by AINNA.
Limited starter website offer. AI usage, hosting, maintenance and custom integrations depend on the confirmed scope.
View SME Offer โ
Ask about AINNA pages, services and articles.
AINNA sources only ยท up to 5 lines ยท 20 questions/hour
No section data available yet.
Sites with documented sections will appear here.
We value your privacy
We use browser storage to remember your choice. Optional analytics runs only after you allow it; your choice is recorded with an anonymous ID. Privacy Policy