Skip to content

oracular / IntentConfig

Interface: IntentConfig ​

Defined in: types.ts:82

One thing the user might be about to do, tracked as a Beta(α, β) distribution with α₀ = prior × priorStrength and β₀ = (1 − prior) × priorStrength.

Example ​

ts
const churn: IntentConfig = {
  prior: 0.08,
  priorStrength: 20,
  halfLife: 14 * 24 * 60 * 60 * 1000,
  signals: { 'session.short': 1, 'notifications.disabled': 3, 'feature.new.used': -2 },
  outcome: 'account.cancelled',
  reveal: { threshold: 0.5, z: 1.64 },
};

Properties ​

PropertyTypeDescriptionDefined in
attribution?numberHow long a closed episode's signals wait for the outcome before they take a miss, in the same unit as at. With it set, an episode that ends without the outcome is held instead of counted. When the outcome arrives inside the window, each held episode gets a share 2^(−age / halfLife) of a hit and the rest of a miss, with age measured from the episode's close: the sessions that built up to the outcome are credited by how much of their evidence still stands. When the window passes, the episode is a miss, recorded at the moment the window ended. Unset: an episode that ends without the outcome is a miss at once. A natural first value is the intent's halfLife, where the smallest share inside the window is one half.types.ts:116
halfLifenumberHalf-life of evidence, in the same unit as at. Evidence decays back toward the prior.types.ts:88
outcome?stringEvent name that confirms the intent happened, e.g. 'checkout.completed'.types.ts:92
priornumberPrior probability, strictly between 0 and 1.types.ts:84
priorStrengthnumberStrength of the prior as a pseudo-count, greater than 0 and at most 1e6.types.ts:86
resetOnOutcome?booleanReset α, β and contributions to the prior when the outcome arrives. Default true.types.ts:94
reveal?RevealOptionsReveal defaults for this intent.types.ts:118
saturate?booleanRepeats of a signal within one episode add less: the n-th occurrence adds w × log2(1 + 1/n), so ten occurrences add 3.46 weights, not ten. The count restarts when the episode ends or this intent's outcome arrives. Default: true when episodeTimeout is set, false otherwise, because without an idle timeout episodes end only when the app calls endEpisode, and if it never does the count would never restart. Set true to saturate anyway (your app ends every episode itself), or false for intents where the repetition itself is the evidence (a user stuck on the same step), so every occurrence adds its full weight.types.ts:105
signalsRecord<string, number>Event name → initial weight. Positive is evidence for the intent, negative against. Non-zero, between −1e6 and 1e6.types.ts:90

Released under the MIT License.