Skip to main content

Automations (v1 triggers, stop rules, templates)

Audience: Support · QA · Engineering · Where in app: Build → Automations (/automations, tabs Automations / Campaigns / Logs — /automations/logs) · Plan availability: every account (Agent K-only triggers/steps need ai_agent_k.enabled) · Gate: route settings.ai + client settings.ai_agents

The rule engine — automation_rules, agentKGraph workflows, AgentKRuleService / AgentKAutomationService / AgentKActionRunner, budgets, approvals, bulk runs, the test bench — is documented in Agent K › Automations. This page covers what changed in the 2026-10-21 → 2026-11-16 window. Campaigns run on the same engine: see Campaigns.

v1 triggers (3ff7c0f6f, frontend 8ac68e0b)​

TriggerSource
form_abandonedms-sessions, after analysing a recording, posts the last abandoned form (page_url, field, last_activity_at) to POST /internal/knox/form-abandoned (NoxActionController.formAbandoned, api-key, fire-and-forget — ms-sessions 4af11cd). Not fired when the session has a booking or the person submitted a form since 5 min before the last activity.
chat_endedChatTranscriptEmailJob when a chat goes quiet with visitor messages and no booking; an AI email step gets what they asked.
crm_stage_changed { pipeline_id?, stage }lib/crmStageEvent + GHL Opportunity webhooks (GhlNativeEventHelper). Editor pickers load pipelines/stages from the CRM.
tag_added { tag }GHL ContactTagUpdate (new tags only — previous set kept in Redis) and lead tags newly added via TagService.apply (see Lead Tags).
inbox_matchA visit starts and the connected mailbox (IMAP) has an email from them in the last year — MailboxService, one IMAP search per address per day. Pairs with the email step's reply_thread mode. Smoke: scripts/smoke-automation-inbox-match.js (GreenMail).
no_reply { days, channel: any|email|sms|call }NoReplyJob (schedular, hourly, every account — 205ec92ab): reads Leads rows; fires when the row's last touch is our outbound message days old, its outcome isn't replied/booked, nothing came back since, the lead isn't booked/won and nothing is queued. Lookback days + 1 day (switching a rule on doesn't reach back), one claim per message (CLAIM_MS 400 days), ≤500 leads per rule per run.
sequence_finished { emails, days }AgentKSequenceFinishedJob (hourly, 9827ea81a, Agent K only): the last email of the sequence went out (Agent K or LC Email via a CRM workflow, counted from when the rule was switched on) and no reply/booking in days.
re_engage_sent { days, outcome: no_reply|opened|clicked|any }AgentKReEngageSentJob (hourly, 76b4d9154, Agent K only): days after a re-engage email (lib/reEngage sources), picked up within a 2-day window; one run per email (CLAIM_MS 120 days). See Re-engage.

Trigger options added: visited.days_away (0–365; fire only after that long away), page_view.returning (not on the first visit). The frontend hides the Agent K triggers (email_click, lead_found, email_no_visit, sequence_finished, re_engage_sent) when Agent K is off unless already used. Labels: RULE_TRIGGERS in common/helpers/agentK.js and TRIGGER_WORDS / STEP_WORDS in backend lib/noxAutomations.js (Nox's vocabulary — every new trigger needs an entry there, 19cc3f51a).

Steps and conditions​

  • assign_owner { owner_id, owner_name } — new CRM capability owners (GHL + HubSpot adapters); GET /knox/agent-k/owners lists the team, degrading to a reason instead of a 500.
  • email.mode: 'reply_thread' — a draft on their last email thread, sent from the mailbox.
  • tag — { tags, mode: add|remove, where: { lead, crm } } (847865285); see Lead Tags.
  • wait.until_hour (0–23, business timezone — next occurrence) beside minutes.
  • A form submitter not yet in the CRM is created before an email step.
  • conditions.business_hours '' | inside | outside (company working hours); conditions.customers '' | include | only ('' follows nox_funnel.customers.mode — stop_selling skips funnel customers via lib/customers.skipCustomer, fail-open); conditions.sources gains import.
  • attribution_category on the rule — the Triggered by label for its touches (lib/touchAttribution.categoryForRule; '' = automatic). See Leads — Overview (Touches and Triggered by).

Stop rules (e32dffe01, 3ff7c0f6f; frontend a48829b5)​

A reply, booking, stop tag, a person taking over, or a manual stop ends every automation for that lead. Config companies.ai_agent_k.automation.stop_rules (declared in the schema, kept by normalizeAutomation):

replied true · booked true · human true · tags ['unqualified'] · hold_days 30

AgentKAutomationService.stopContact({ company_id, contact_id|lead_id, reason, note, by }) writes a stop marker (stop:<company>:<contact> on automation_claims, held hold_days after a reply; a booking holds while booked), ends parked runs and refunds their reserve, cancels rule/bulk/campaign calls and texts (dependents blocked), dismisses drafts and stops LinkedIn sequences. Person-scheduled tasks are left alone. Honoured by rule evaluation, runGraph before each action, ScheduledNoxActionJob and AgentKSequenceJob.

Hooks: handleInboundReply (any inbound message), the booking signal and funnel moves into/out of booked/won (FunnelStageService), GHL ContactTagUpdate stop tags (added or removed), a person's own approved send and a GHL OutboundMessage with a user (human), HubSpot hs_lead_status = UNQUALIFIED, a mailbox-only visitor's stop marks their automation contact too. Manual: GET/POST/DELETE /knox/agent-k/leads/:id/stop (UI AgentKAutomationStop.vue in the Agent K lead panel). Log reasons stopped:<reason> / contact_stopped:<reason> (STOP_REASONS).

Review fixes that shipped with it: a workflow costing more than the whole daily budget skips (budget_below_cost) instead of pausing and re-notifying; tag step and in_crm treat mbx_ ids as not in a CRM; visitor automation contacts key on a verified person only; switching a rule off no longer needs a working agent or cold consent; the wait job takes due runs oldest first.

GET /knox/agent-k/templates returns the playbooks from lib/noxAutomations.js grouped by TEMPLATE_GROUPS — website, agent_k, intermediate, warm, reactivation, customers — each with in_use (rules already made from it, with status) and missing (agent_k, mailbox, crm, call_agent, sms_agent). POST /knox/agent-k/templates/:key { mode: live|test, call_agent_key?, sms_agent_key? } creates the rule(s) as dry-run, then publishes when mode: live. UI views/automations/TemplateGallery.vue (Turn on / Add in Test and edit, agent pickers when there are several; ?templates=<group> opens a group — the Re-engage page links reactivation). Nox's automation tools use the same playbooks.

Frontend​

views/automations/ — Automations.vue (tiles, gallery, rule cards), AutomationTabs.vue (Automations / Campaigns when campaigns_enabled / Logs), AutomationLogs.vue, SendingLimitsDialog.vue (quiet hours, frequency cap, spacing, stop rules), WorkflowEditor.vue, workflow/ (workflow.js LIBRARY, StepSettings.vue, stepForm.js, WorkflowTriggers.vue). Menu: Build → Automations (after Agents), Build → Re-engage below it.

Specs: automation-stop-rules, automation-v1-triggers, agent-k-sequence-finished, re-engage, customers; smoke scripts/smoke-automations.js (sections 9–10 cover v1).

Gotcha: the agentKAllowed middleware refuses every /knox/agent-k/* path for AppSumo accounts (AppSumoService.blocksAgentK) — that includes rules, templates, owners and automation-events, while the sidebar's canViewAutomations doesn't check agentKAvailable, so those accounts see an Automations screen whose API refuses them.

Deploy: backend, then restart the schedular (NoReplyJob, AgentKSequenceFinishedJob, AgentKReEngageSentJob, CampaignJob run there).