Outbound triggers, scheduler and web-chat dispatch

FeatureAIService
Shipped
July 19, 2026 at 2:00 AM UTC
Author
Kamo
Commit
6226b4f

Makes the outreach spine actually fire. The gate, contact state, consent and audit already existed; nothing caused a touch to be evaluated. - NATS enabled for AIService via its own k8s/configmap.yaml (each Java service carries its own k8s dir; KlusterServices holds only cluster infra). JetStream is deliberately left OFF: NatsConfig asserts its own replication-factor against centrally-provisioned streams at startup, and AIService only subscribes to core NATS and publishes nothing, so enabling it would gain nothing and risk a second service asserting replica counts. - AgentOutboundConsumer subscribes security.leads.rt.> and consumes ONLY LEAD_CREATED/LEAD_UPDATED. The publisher also emits lock and stats events - reaching out to a person because a colleague took an edit lock on their record is not defensible. Ids arrive as strings from the publisher, so they are parsed as text rather than asLong(). - AgentOutboundScheduler evaluates schedule triggers under four bounds: org set derived from agents that actually have outreach on (capped), a thin sliding time slice so cost tracks new-lead rate rather than total leads, a per-tick row cap, and a re-evaluation damper so a lead crossing during quiet hours is retried once rather than every tick for a day. - Composition seeds textComplete with the PUBLISHED version's compiled prompt, never the draft, plus the trigger intent. Composition failure records FAILED; there is no canned fallback message. - WEB_CHAT dispatch continues an existing thread only. Outreach may resume a conversation the visitor opened; it may not conjure a chat window at someone who never opened one. - SMS/EMAIL/SOCIAL_DM route to a recorded FAILED naming the missing compliance plumbing, so an org pointing a trigger at SMS sees why in the outreach log immediately instead of nothing happening. 23 new tests; suite is 68 and green.

All changes

Like what you see shipping?

Every one of these updates lands in your workspace automatically. Start free and watch it grow week after week.

Start Free ForeverView Pricing