Skip to main content

Overview

Feature stores numeric metrics for ML/MAB consumption. A single item per LeadOrganization.
Feature
├── lead_organization_id  UUID, PK
├── features              MAP — all features as key-value pairs
└── computed_at           TIMESTAMPTZ
A single GetItem returns the entire feature vector. All values are numeric.

Feature Categories

RFM (Recency, Frequency, Monetary)

FeatureDescription
recency_daysDays since last interaction
frequency_conversations_30dConversations in the last 30 days
frequency_purchases_90dPurchases in the last 90 days
monetary_totalTotal amount spent (lifetime)
monetary_avg_ticketAverage purchase amount

Engagement

FeatureDescription
avg_response_time_secondsLead’s average response time
avg_messages_per_conversationAverage messages per conversation
sentiment_avg_30dAverage sentiment score (0-1) in the last 30 days

Behavior

FeatureDescription
discount_request_rateRate of conversations where lead asked for a discount
conversion_rateRate of conversations that resulted in a purchase
support_ticket_rate_30dSupport tickets in the last 30 days
days_since_last_purchaseDays since last purchase
has_purchased1 if lead has any purchase, 0 otherwise
engagement_scoreComposite engagement score (0-1)

Temporal Patterns

FeatureDescription
preferred_hour_of_dayHour the lead most frequently interacts
preferred_day_of_weekDay of week the lead most frequently interacts
channel_diversityNumber of different channels used

Campaign

FeatureDescription
campaign_open_rateRate of opened campaigns
campaign_click_rateRate of clicked campaigns
campaigns_received_30dCampaigns received in the last 30 days

Future: ML and MAB

The Lead Domain is designed to support Machine Learning and Multi-Armed Bandit (MAB):
MAB ConceptIn the ADP
ArmsDifferent agents + different approaches
Context (features)Lead feature vector served by the Lead Domain
RewardConversion, revenue, engagement (measured by the AI Agents domain)
The Lead Domain provides the context. Decision-making and reward measurement belong to the AI Agents domain.

Computation

Features are updated by two triggers:

SQS: feature-processing (near-realtime)

Triggered when a new event arrives via the lead-events SNS fan-out. Recalculates only the features affected by that specific event. Example: a purchase_completed event arrives → recalculates monetary_total, frequency_purchases_90d, days_since_last_purchase, has_purchased. Other features (like sentiment_avg_30d) are not touched.

EventBridge Scheduler (periodic batch)

Some features change over time even without new events:
FeatureWhy it changes without events
recency_daysYesterday it was 5, today it is 6. No event happened.
days_since_last_purchaseSame — increments daily.
campaign_ignoredLead received a campaign 7 days ago and never engaged.
sentiment_avg_30dOld sentiment events fall out of the 30-day window.
The EventBridge Scheduler runs on a cron (e.g., daily at 06:00 UTC), triggers the same Feature Computer Lambda, and recalculates time-dependent features for all leads with recent activity.