AI agent that monitors cancelled orders, analyzes reasons (price, stock, fraud), and suggests recovery actions (re-engagement vouchers, follow-up, alternative products).
import requests, json, pandas as pd
API_ORDERS = "https://api.ecommerce.com/v2/orders/cancelled"
def fetch_cancelled_orders():
resp = requests.get(API_ORDERS, params={"status": "cancelled"})
return resp.json().get("orders", [])
def analyze_cancellations(orders):
reasons = {"price": 0, "stock": 0, "fraud": 0, "other": 0}
for o in orders:
r = o.get("cancel_reason", "other")
if r in reasons: reasons[r] += 1
top_reason = max(reasons, key=reasons.get)
recovered = [o for o in orders if o.get("recovered")]
recovery_rate = len(recovered) / len(orders) * 100 if orders else 0
return {
"top_reason": top_reason,
"recovery_rate": round(recovery_rate, 1),
"reasons": reasons,
"recovered": len(recovered)
}
report = analyze_cancellations(fetch_cancelled_orders())
print(json.dumps(report))
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