Skip to content

fix(examples): put order amount in metadata.amount so RFM monetary works - #18

Merged
rrader26 merged 1 commit into
mainfrom
fix/nbo-example-monetary-metadata
Jul 15, 2026
Merged

fix(examples): put order amount in metadata.amount so RFM monetary works#18
rrader26 merged 1 commit into
mainfrom
fix/nbo-example-monetary-metadata

Conversation

@rrader26

Copy link
Copy Markdown
Contributor

What

The next-best-offer.ts demo wrote each order's price only into the memory content string ("Order #1 — $42 pizza") and never set a structured amount field.

The RFM miner computes the Monetary score by summing a structured numeric field — metadata.value / metadata.total / metadata.amount, or a lineItems[] array — and deliberately does not parse prices out of free text (monetary_value). So every contact in the demo scored M=0 — the monetary axis of RFM was effectively dead in our own flagship example.

Why it matters

A customer reproducing our observe → mineMemories → getProfile flow copied this example faithfully and reported monetaryScore stuck at 0 for priced orders. The engine is behaving as designed; the example was teaching the wrong shape.

Change

  • Move each order's dollar amount into metadata: { amount: N } (a JSON number — the field the miner sums).
  • Drop the price from the display text so there's one source of truth.
  • Non-order events (site_visit, email_open) carry no amount, unchanged.

With this, the three demo contacts now produce non-zero, differentiated Monetary scores instead of a uniform M=0.

Related

Pairs with the engine fix for the Frequency axis (F was scored against the requested query window instead of the subject's active span, flooring realistic order cadences to F=1) — same customer repro.

🤖 Generated with Claude Code

The next-best-offer demo wrote each order's price only into the memory
`content` string ("Order — $42 pizza"). The RFM miner sums a structured
numeric field (metadata.value/total/amount, or a lineItems array) for the
Monetary score and does not parse prices out of free text, so every contact
in the demo scored M=0 — the monetary axis of RFM was dead in our own
flagship example, and customers copying it hit the same wall.

Move the dollar amount into `metadata.amount` (a JSON number) on each
order_placed event and drop it from the display text. Non-order events
(site_visit, email_open) carry no amount, as before.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@rrader26
rrader26 merged commit 040fa92 into main Jul 15, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants