Skip to main content

Infer user intent states from behavioral event streams

Project description

Istari

Istari is a Python library that infers user intent states from raw behavioral event streams and exposes them as a structured, machine-readable layer for CRO systems, personalization engines, and agentic AI workflows.

Instead of treating user behavior as isolated events or funnels, Istari models sessions as continuous intent trajectories over time.

What Problem Istari Solves

Modern products collect events like:

  • page views
  • scroll depth
  • clicks
  • add to cart
  • remove from cart
  • time gaps
  • navigation loops
  • rage clicks (Clarity)
  • dead clicks (Clarity)

But downstream systems still reason in crude terms like funnels and conversion rates.

Istari sits between raw analytics and decision-making systems and answers:

  • What is the user trying to do right now?
  • Are they exploring, comparing, hesitating, or ready to act?
  • What friction or uncertainty is blocking progress?
  • How intent is evolving over the session?

Core Abstraction

Istari introduces a first-class abstraction called an Intent State.

An intent state is:

  • time-aware: associated with timestamps
  • probabilistic: has confidence scores
  • explainable: includes attribution data
  • composable: can be combined across domains

Example intent states:

  • browsing
  • evaluating_options
  • price_sensitive
  • trust_seeking
  • purchase_ready
  • abandonment_risk

High-Level Flow

  1. Raw events are normalized into a canonical schema
  2. Temporal patterns and transitions are extracted
  3. Intent hypotheses are scored
  4. A state machine produces the most likely intent trajectory
  5. Outputs are exposed to CRO rules or agentic systems

Design Goals

  • Python-first, backend friendly
  • Deterministic core with optional ML layers
  • Explainability by default
  • Domain-adaptable without retraining
  • Open-core friendly architecture

Installation

pip install istari-core

For development:

git clone https://github.com/istari/istari.git
cd istari
pip install -e .

Quick Start

from datetime import datetime, timedelta, timezone
from istari.core.events import Event
from istari.core.session import Session
from istari.inference.rules import RuleBasedInference
from istari.inference.heuristics import BrowsingRule, PurchaseReadyRule

# Create a session
session = Session(
    session_id="session_123",
    user_id="user_456",
    started_at=datetime.now(timezone.utc),
)

# Add events
session.add_event(Event(
    event_type="page_view",
    timestamp=datetime.now(timezone.utc),
    user_id="user_456",
    session_id="session_123",
    properties={"page": "/products"},
))

# Infer intent state
inference = RuleBasedInference()
inference.add_rule(BrowsingRule())
inference.add_rule(PurchaseReadyRule())

intent_state = inference.infer(session)
print(f"Intent: {intent_state.state_type}")
print(f"Confidence: {intent_state.confidence:.2%}")

Microsoft Clarity Integration

Istari includes first-class support for Microsoft Clarity behavioral signals. Clarity events are converted into Istari's canonical format and mapped to intent signals:

from istari.sources.clarity import ClaritySource

# Initialize Clarity source
clarity_source = ClaritySource()

# Parse Clarity events/exports
clarity_events = [
    {
        "event": "rage_click",
        "timestamp": 1234567890000,
        "userId": "user_123",
        "sessionId": "session_456",
        "clickCount": 5,
    },
    # ... more events
]

# Parse and extract signals
events, signals = clarity_source.process(clarity_events)

# Signals are automatically mapped:
# - rage_click → friction.high
# - dead_click → intent.confusion
# - scroll → content_engagement
# - excessive_hover → hesitation

Clarity Signal Mappings

Clarity Signal Istari Signal Intent Impact
Rage clicks friction.high Contributes to abandonment_risk
Dead clicks intent.confusion Contributes to hesitating
Scroll depth content_engagement Contributes to browsing
Quick back nav dissatisfaction Contributes to abandonment_risk
Excessive hover hesitation Contributes to hesitating

Architecture

Core Modules

  • core/: Event normalization, session modeling, intent states, transitions, scoring
  • schemas/: Event schema normalization (base, ecommerce, web)
  • inference/: Rule-based inference, heuristics, state machine, confidence calculation
  • signals/: Signal extraction (dwell, navigation, comparison, friction, price)
  • explainability/: Attribution calculation, narrative generation, summaries
  • plugins/: Plugin system for extending inference capabilities
  • sources/: Event source integrations (Clarity, etc.)
  • integrations/: Analytics platform integrations (Mixpanel, Amplitude, Segment)

Event Sources vs Integrations

  • sources/: Behavioral signal sources (like Clarity) that provide frontend behavioral data
  • integrations/: Analytics platform integrations for event ingestion

Open-Source vs Proprietary

Open-source core:

  • Event normalization
  • Session modeling
  • Intent state definitions
  • Rule-based inference
  • Explainability primitives
  • Plugin interfaces
  • Clarity integration

Proprietary extensions (planned):

  • Learned intent models
  • Vertical-specific heuristics
  • Advanced uncertainty modeling
  • Real-time streaming inference
  • Deep analytics integrations

Examples

See the examples/ directory for:

  • basic_inference.py: Basic intent inference
  • ecommerce_session.py: Full e-commerce session analysis
  • explain_intent.py: Intent explanation and narratives
  • clarity_integration.py: Microsoft Clarity integration example

Documentation

License

MIT License - see LICENSE file for details.

Contributing

Contributions welcome! Please see our contributing guidelines (coming soon).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

istari_core-0.1.0.tar.gz (40.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

istari_core-0.1.0-py3-none-any.whl (57.1 kB view details)

Uploaded Python 3

File details

Details for the file istari_core-0.1.0.tar.gz.

File metadata

  • Download URL: istari_core-0.1.0.tar.gz
  • Upload date:
  • Size: 40.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for istari_core-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e881e0004a0109d72822d48a04aad9eb56392e11e64942ba6d252618ea0a2fac
MD5 7088b16a306f7ab473e1a0d8180363c1
BLAKE2b-256 f1bb78368b00804e9bee98e8beb1df4764f58ef863ccd985cd87484edda5ec52

See more details on using hashes here.

File details

Details for the file istari_core-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: istari_core-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 57.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for istari_core-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ded9adbf4a5aa4e976d69b527a5380eccad55b069ad57e17f836614adca371fa
MD5 9084809dc8b1fe09b6b7ddb16c5bd8bf
BLAKE2b-256 cc40ab3b2801c0c1e8b42a5ada92fa161f2a29c7b4dce493da9bd2b8575d3827

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page