DocsGuides
Context inputs
View as MarkdownInputs are the context you attach to a decision, such as country, device or traffic source, so Zigbongo can learn which option works best for whom.
What inputs are
Inputs are a flat set of keys and values sent with a decision: strings, numbers, booleans or null. There's no schema to declare. Zigbongo types them itself and, at decision points that use them, learns which option works best for which context: a contextual bandit rather than one answer for everyone.
const s = zb.session("paywall", user.id);
const plan = await s.decide("plan", ["monthly", "annual", "lifetime"], "monthly", {
inputs: { country: user.country, platform: "ios", source: "newsletter", visitsLast30d: 12 },
});
$plan = $s->decide('plan', ['monthly', 'annual', 'lifetime'], 'monthly',
inputs: ['country' => $user->country, 'platform' => 'ios', 'source' => 'newsletter', 'visitsLast30d' => 12]);
- They add up over a session. Send inputs with any call; a later value for the same key replaces the earlier one. The first decision of a session sees only what you send with it, so send what you know about the person (country, platform, campaign) from the first call.
nullmeans unknown. It's left out, never guessed.- Flat only. A nested object or an array is refused with
400 invalid_input, and the SDK shows your default for that call. Input names can be any non-empty string except.and... - A decision point decides once whether it uses inputs. If the first decision Zigbongo learns from at a point carries inputs, the point learns per context; if it carries none, the point learns one answer for everyone, for good.
- Context costs traffic. Learning for each group of customers needs more sessions than learning one answer. In simulation, flows that chose by context learned about 10 times slower than flow-level choices.
Types are fixed by the first observations
Each input's type is its JSON type: number, boolean or text. A string that looks like a number is text, so "34" and 34 are different values.
- An observation is a decision that carries the input. At its 1,000th observation in a flow, an input's type is fixed, for good, to its most common type so far. A 10-step flow gets there within about its first 100 sessions.
- After that, a value of another type is ignored, when learning and when choosing, as if the input were missing. It's still stored, and the flow page's Inputs section flags it, with a notice near the top of the page.
- To change an input's type, send it under a new name: it starts afresh.
Raw or bucketed
Both are fully supported; choose per input.
- Raw numbers (
age: 34,basketValue: 72.5): Zigbongo learns ten bins from the first 500 values. Until then the input counts as unknown. - Bucketed values (
ageBand: "25-34"): text, learned as categories.
Send a bucket when you'd rather not send the exact value, such as an age band instead of a birth date, or when your own bands are the ones that matter to your business.
Outliers in numbers
Numbers are learned only as bins. The outer bins are open-ended, so an extreme value falls in with the highest (or lowest) values seen, and nothing is scaled, so there's nothing to clip. The bin edges come from the first 500 values, and a few outliers barely move them. Rules on the dashboard show the outer bins as open ranges.
Text inputs with many values
- A text value gets a weight of its own from its 30th observation. Until then it shares one "other" group with the input's other rare values, and so does a value Zigbongo has never seen.
- At its 51st distinct value, an input switches to hashing for good: its values are spread over 256 shared features, aren't combined with other inputs and never appear in the dashboard's rules.
So inputs work best with a modest number of values: plan, country, platform, campaign. An id, an e-mail address or a free-text field ends up hashed and adds nothing you can read.
Switching an input off
You can stop Zigbongo using an input in a flow without changing your code:
- On the dashboard: the flow page's Inputs section, "Switch off" (click twice to confirm), and "Switch on" to bring it back.
- Through the API:
PATCH /v1/flows/{flowKey}/inputs/{key}with{"use": false}, or{"use": true}to switch it back on. Any name can be switched off, even one not sent yet. The SDKs have no call for it.
curl -X PATCH https://zigbongo.com/v1/flows/paywall/inputs/age \
-H "Authorization: Bearer $ZIGBONGO_KEY" \
-H "Content-Type: application/json" \
-d '{"use": false}'
- It takes effect on every server within a few seconds, usually about one. Each decision records the inputs it left out.
- What was learned from the input stays in the model, unused, and fades over time. Switching it back on carries on from there.
- A switched-off input is still received, stored for the flow's retention period and counted towards its type. To stop storing it, stop sending it.
- A registered flow's default rules still read it: they're your rules for the default, not learning.
What not to send
- Anything that identifies a person. Names, e-mail addresses, phone numbers, user or device ids. They don't help (they end up hashed) and they're personal data. An identifying value can also end up in Zigbongo's statistics about inputs, which erasing a customer doesn't search.
- Sensitive details you don't need. Inputs such as health details can be special-category data under the GDPR. What you send is your decision: send a band rather than the exact value, or leave it out.
The inputs you do send aren't kept for ever:
- Inputs and step results (such as quiz answers) are forgotten after each flow's retention period: 90 days unless you set another, from 1 to 36,500 days. Set it on the flow page ("Keep inputs and answers (days)") or with
retentionDaysonPATCH /v1/flows/{flowKey}. Keep it no longer than you need. - The clock starts when each value was sent; a session's inputs count from its last call. What was learned from them stays.
The dashboard's "What Zigbongo learned for each group of customers" shows what each input does to the choice, so you can check that nothing is chosen for a reason you wouldn't accept. Values that change the best option have a row each; an input's other values share one row, with the best option over everyone.
For AI assistants and agents: every docs page is plain Markdown at its address with .md (this one is /docs/inputs.md), and llms.txt lists them all.