Score Customer Book (A/B/C/D)
customer_tieringScores a customer book of 500 transaction rows OR FEWER into A/B/C/D tiers. Send the rows directly; this server runs the survival model (BG/NBD), spend model (Gamma-Gamma), tier migration, money layer and decision cards, and returns the full result including a per-customer ledger with explanation traces. For books LARGER than 500 rows use customer_tiering_get_engine instead — sending thousands of rows as tool arguments is slow and risks truncated JSON. Optionally accepts rep_contacts, which lets the money layer learn contact uplift from data rather than assuming it. Customer identifiers are CLEANED HERE before scoring: capitalisation, spacing, punctuation, legal-suffix and word-order variants (ACME PVT LTD / Acme Pvt. Ltd. / Acme Private Limited) are merged into one account by rule, so send the values exactly as they appear in the source and do not pre-normalise them. Anything that needs context instead of rules — 'Acme & Co' vs 'Acme Pvt Ltd', a name under two codes — comes back in identity_cleaning.review_candidates, unmerged, for you to judge from the surrounding rows and re-send via identity_overrides. Pass customer_name alongside a coded customer_id to have accounts reported by name.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| as_of | No | Analysis date YYYY-MM-DD. Defaults to latest transaction date. | |
| currency | No | ISO currency code for money display (e.g. INR, USD, EUR). No FX conversion. | USD |
| rep_contacts | No | Optional rep-activity log [{customer_id, date}, ...]. Builds touched vs untouched Markov matrices and learns contact uplift per tier (≥ 10 touched transitions). Observational, not causal. | |
| transactions | Yes | Purchase rows. Each item needs customer_id, date, and amount (> 0, finite). Send customer_id exactly as the source has it: capitalisation, spacing, punctuation, legal-suffix and word-order variants are merged here by rule. Do not pre-normalise. Add customer_name when the source has a name as well as a code. | |
| horizon_months | No | CLV projection horizon in months. | |
| currency_symbol | No | Override display symbol (e.g. ₹, $, R$). | |
| identity_overrides | No | Your judgement calls on the review_candidates a previous call reported: {raw or reported customer value -> the account it belongs to}. Spelling variants are merged automatically and need no entry here; use this only for groups the rules deliberately left separate, and only after reading the surrounding rows or asking the user. | |
| risk_period_months | No | Window over which neglect churn risk is assessed. | |
| include_diagnostics | No | If true, include MLE params and multi-start fit diagnostics. | |
| rep_queue_max_items | No | Max length of the daily SAVE/GROW/VERIFY rep queue. | |
| annual_discount_rate | No | Annual discount rate for CLV (e.g. 0.10 = 10%). | |
| assumed_upgrade_prob | No | Fallback P(upgrade | contacted). Used only when learned data from rep_contacts is insufficient for that tier. | |
| contact_effectiveness | No | Fallback fraction of at-risk churn recovered by one contact. Used only when rep_contacts is missing or too sparse for that tier. | |
| min_customers_for_model | No | Below this count, BG/NBD refuses to fit. | |
| rep_queue_min_save_revenue | No | Ignore SAVE candidates with lifetime revenue below this. | |
| min_repeat_buyers_for_model | No | Below this repeat-buyer count, BG/NBD refuses to fit. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| alerts | No | List from the upstream customer tiering API. | |
| status | Yes | 1 = success, 0 = error | |
| message | No | ||
| metadata | No | Upstream customer tiering API payload. | |
| customers | Yes | List from the upstream customer tiering API. | |
| decisions | Yes | Ranked plain-language manager cards (CALL NOW / GROW / CHECK). Money, days, account names only — no P(alive) / CLV / RFM jargon. | |
| rep_queue | Yes | ||
| book_summary | No | Upstream customer tiering API payload. | |
| book_exposure | No | ||
| uplift_targets | No | List from the upstream customer tiering API. | |
| migration_model | No | ||
| identity_cleaning | Yes | What the server did to the customer identifiers before scoring: which spelling variants it merged by rule, which groups it deliberately left separate for YOU to rule on (review_candidates — read the rows and decide, then re-run with identity_overrides), how names were chosen for display, and the counts before and after. Always relay the merges and the open questions; the tiers depend on them. | |
| money_assumptions | No | ||
| data_quality_report | No | Upstream customer tiering API payload. |