{"slug":"strategy/growth/ACCOUNT_SUCCESS_FLOW_TRACE","title":"Account Success Flow Trace","section":"strategy","sectionLabel":"Strategy","status":"unclassified","type":"document","path":"strategy/growth/ACCOUNT_SUCCESS_FLOW_TRACE.mdx","bytes":10164,"description":null,"updated":null,"source":"integratewise/Integratewise-docs-wiki","content":"\n> Step-by-step trace of a Salesforce account flowing through the entire IntegrateWise pipeline.\n\n---\n\n## Current Surface-Binding Doctrine\n\n- Operational Workbench = the primary work surface; left sidebar nav; Twin sidebar pops out when needed.\n- Twin Workbench = full AI ecosystem surface (skills, knowledge, agents, prompts, conversational library).\n- Governance is embedded at every layer — not a separate workbench.\n- OpenWebUI is not the customer-facing product shell.\n- Twin / OpenWebUI runtime surfaces use the canonical Forest + Paper system language.\n- Midnight Executive is investor-deck / fundraising language only.\n\nUse older L1/L2 / workspace / knowledge-UI language in this file through that boundary if any historical phrasing remains.\n\n---\n\n## Scenario\n\nA CSM connects their Salesforce instance. The account \"Acme Corporation\" flows through the system and surfaces an insight in the CSM Hub: \"Acme Corp usage dropped 40% — renewal in 45 days.\"\n\n---\n\n## Step 1: OAuth Connection\n\n```\nUser clicks \"Connect Salesforce\" → OAuth redirect → Salesforce login → Authorization grant\n→ Callback to /api/connectors/salesforce/callback\n→ Access token + refresh token encrypted and stored in connector_credentials table\n→ Connector status set to \"active\" for workspace_id = ws_abc123\n```\n\n| Detail   | Value                                                  |\n| -------- | ------------------------------------------------------ |\n| Worker   | `connector-auth`                                       |\n| Duration | ~3s (user interaction)                                 |\n| Output   | Encrypted tokens in Spine DB, connector record created |\n\n---\n\n## Step 2: Loader — Fetch from Salesforce\n\n```\nLoader Worker triggered by connector activation event\n→ Reads connector config: object = \"Account\", fields = [Name, Industry, AnnualRevenue, ...]\n→ Calls Salesforce REST API: GET /services/data/v59.0/query?q=SELECT+...+FROM+Account\n→ Receives 847 account records (paginated, 200 per page)\n→ Each record wrapped in envelope: { source: \"salesforce\", workspace_id: \"ws_abc123\", raw: {...} }\n→ Enqueued to normalizer-queue (Cloudflare Queue)\n```\n\n| Detail        | Value                                              |\n| ------------- | -------------------------------------------------- |\n| Worker        | `loader-salesforce`                                |\n| Duration      | ~4.2s for 847 records                              |\n| Output        | 847 messages on normalizer-queue                   |\n| Rate limiting | Respects Salesforce API daily limit (15,000 calls) |\n\n---\n\n## Step 3: Normalizer — Map to Canonical Schema\n\n```\nNormalizer Worker consumes message from normalizer-queue\n→ Reads field mapping config for Salesforce Account → IntegrateWise Account\n→ Maps: SF.Name → iw.name, SF.Industry → iw.industry, SF.AnnualRevenue → iw.arr\n→ Applies transformations: currency normalization, date format standardization\n→ Validates required fields present (name, external_id)\n→ Outputs canonical entity: { type: \"account\", name: \"Acme Corporation\", industry: \"Technology\", arr: 125000, external_ids: { salesforce: \"001ABC123\" } }\n→ Enqueued to resolver-queue\n```\n\n| Detail   | Value                              |\n| -------- | ---------------------------------- |\n| Worker   | `normalizer`                       |\n| Duration | ~12ms per record                   |\n| Output   | Canonical entity on resolver-queue |\n\n---\n\n## Step 4: Resolver — Identity Matching\n\n```\nResolver Worker consumes from resolver-queue\n→ Checks deterministic rules: external_id \"001ABC123\" → no existing match (first sync)\n→ Checks probabilistic: name \"Acme Corporation\" → no fuzzy match above threshold\n→ Decision: CREATE new entity\n→ Assigns entity_id: ent_acme_001\n→ Creates identity_link: { entity_id: \"ent_acme_001\", source: \"salesforce\", external_id: \"001ABC123\" }\n→ Enqueued to router-queue with action: \"create\"\n```\n\nOn subsequent syncs with Zendesk data:\n\n```\n→ Zendesk org \"Acme Corp\" has email domain acme.com\n→ Deterministic: domain match with Salesforce account (Website field = acme.com)\n→ Confidence: 0.96 → auto-merge\n→ identity_link added: { entity_id: \"ent_acme_001\", source: \"zendesk\", external_id: \"org_789\" }\n```\n\n| Detail   | Value                                                 |\n| -------- | ----------------------------------------------------- |\n| Worker   | `resolver`                                            |\n| Duration | ~45ms per record (includes DB lookup)                 |\n| Output   | Entity ID assignment + identity links on router-queue |\n\n---\n\n## Step 5: Router — Determine Entity Type and Destination\n\n```\nRouter Worker consumes from router-queue\n→ Reads entity type: \"account\"\n→ Routes to account-writer-queue (not contact-writer-queue or opportunity-writer-queue)\n→ Attaches routing metadata: { table: \"entities_account\", partition: \"ws_abc123\" }\n→ Enqueued to writer-queue\n```\n\n| Detail   | Value                          |\n| -------- | ------------------------------ |\n| Worker   | `router`                       |\n| Duration | ~3ms per record                |\n| Output   | Routed message on writer-queue |\n\n---\n\n## Step 6: Writer — Persist to Spine\n\n```\nWriter Worker consumes from writer-queue\n→ Upserts to entities_account table in Spine DB:\n  INSERT INTO entities_account (entity_id, workspace_id, name, industry, arr, ...)\n  VALUES ('ent_acme_001', 'ws_abc123', 'Acme Corporation', 'Technology', 125000, ...)\n  ON CONFLICT (entity_id) DO UPDATE SET ...\n→ Writes source_attribution record: { entity_id, field: \"arr\", source: \"salesforce\", confidence: 0.95, synced_at: now() }\n→ Emits entity_changed event to assembler-queue\n```\n\n| Detail   | Value                                                  |\n| -------- | ------------------------------------------------------ |\n| Worker   | `writer`                                               |\n| Duration | ~25ms per record (DB round-trip)                       |\n| Output   | Row in Spine + entity_changed event on assembler-queue |\n\n---\n\n## Step 7: Assembler — Build Entity 360\n\n```\nAssembler Worker consumes entity_changed event\n→ Reads all source data for ent_acme_001 from Spine tables\n→ Merges: Salesforce account data + Zendesk ticket history + Amplitude usage + Stripe billing\n→ Resolves field conflicts using trust rules (highest-confidence-wins for ARR)\n→ Computes health score: weighted formula across usage (40%), support (25%), engagement (20%), billing (15%)\n→ Health score = 48 (usage dropped, support tickets up)\n→ Builds Entity 360 response object and caches at edge (Cloudflare KV, 60s TTL)\n→ Emits entity_assembled event to trigger-queue\n```\n\n| Detail   | Value                                                       |\n| -------- | ----------------------------------------------------------- |\n| Worker   | `assembler`                                                 |\n| Duration | ~85ms (multi-table read + computation)                      |\n| Output   | Cached Entity 360 + entity_assembled event on trigger-queue |\n\n---\n\n## Step 8: Twin Trigger Engine — Evaluate and Generate Insight\n\n```\nTwin Worker consumes entity_assembled event\n→ Fetches Entity 360 snapshot for ent_acme_001\n→ Evaluates 14 trigger conditions:\n  ✗ usage_decline: usage dropped 42% over 30 days → FIRES (severity: high)\n  ✗ renewal_risk: renewal in 45 days + health 48 → FIRES (severity: critical)\n  ✓ support_spike: 2 tickets (below threshold of 3) → does not fire\n  ... (11 more evaluated, none fire)\n→ Creates 2 insights:\n  1. { trigger: \"usage_decline\", severity: \"high\", evidence: \"DAU dropped from 89 to 52 over 30 days\", action: \"Schedule usage review call\" }\n  2. { trigger: \"renewal_risk\", severity: \"critical\", evidence: \"Renewal in 45 days, health score 48, usage declining\", action: \"Escalate to manager, schedule executive sponsor call\" }\n→ Writes to twin_insights table (NOT to Spine entity tables)\n→ Emits insight_created events to notification-queue\n```\n\n| Detail   | Value                                                 |\n| -------- | ----------------------------------------------------- |\n| Worker   | `twin-trigger`                                        |\n| Duration | ~120ms (Entity 360 fetch + 14 evaluations + 2 writes) |\n| Output   | 2 insights in twin_insights + notification events     |\n\n---\n\n## Step 9: Insight Displayed in CSM Hub\n\n```\nNotification Worker routes insights to CSM Hub:\n→ Realtime subscription (Spine DB Realtime) pushes to connected CSM browser\n→ CSM Hub morning briefing updates:\n  \"🔴 Acme Corporation — Usage dropped 42%, renewal in 45 days\"\n  Recommended: \"Schedule usage review call, escalate to manager\"\n→ Account card updates: health badge changes from yellow to red\n→ Timeline entry added: \"Twin detected usage decline and renewal risk\"\n```\n\n| Detail   | Value                                                            |\n| -------- | ---------------------------------------------------------------- |\n| Delivery | Spine DB Realtime (WebSocket)                                    |\n| Latency  | < 200ms from insight write to UI update                          |\n| Output   | CSM sees actionable insight with evidence and recommended action |\n\n---\n\n## End-to-End Timing Summary\n\n| Stage        | Worker            | Latency    | Cumulative |\n| ------------ | ----------------- | ---------- | ---------- |\n| OAuth        | connector-auth    | ~3s (user) | 3s         |\n| Loader       | loader-salesforce | ~4.2s      | 7.2s       |\n| Normalizer   | normalizer        | ~12ms      | 7.2s       |\n| Resolver     | resolver          | ~45ms      | 7.3s       |\n| Router       | router            | ~3ms       | 7.3s       |\n| Writer       | writer            | ~25ms      | 7.3s       |\n| Assembler    | assembler         | ~85ms      | 7.4s       |\n| Twin         | twin-trigger      | ~120ms     | 7.5s       |\n| Notification | notifier          | ~200ms     | 7.7s       |\n\nFrom first Salesforce fetch to insight in CSM Hub: **~7.7 seconds** (excluding OAuth user interaction).\n"}