Browse Source

fix: skip flow engine for dealers with erpContactCid so ERP lookup runs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tony T 6 days ago
parent
commit
15d58d9a0d
1 changed files with 4 additions and 2 deletions
  1. 4 2
      server/routers.ts

+ 4 - 2
server/routers.ts

@@ -301,10 +301,12 @@ export const appRouter = router({
         }
 
         // ── Workflow Flow Engine ──────────────────────────────────────────────
-        // Check if user message triggers a live Support Flow
+        // Check if user message triggers a live Support Flow.
+        // Skip for authenticated dealers with erpContactCid — ERP lookup will handle it.
+        const skipFlow = !!(ctx.user?.erpContactCid);
         let flowResult: { content: string; shouldEscalate?: boolean; flowId: string } | null = null;
         try {
-          const matchedFlowId = detectFlowIntent(input.content);
+          const matchedFlowId = skipFlow ? null : detectFlowIntent(input.content);
           if (matchedFlowId) {
             flowResult = await executeFlow(matchedFlowId, input.content);
           }