From 2b8588bec0ad8a7786368de4b058117f376f5d39 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Thu, 5 Mar 2026 08:00:16 -0500 Subject: [PATCH] Auto-reply: avoid routing external replies from internal webchat turns --- src/auto-reply/reply/dispatch-from-config.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/auto-reply/reply/dispatch-from-config.ts b/src/auto-reply/reply/dispatch-from-config.ts index 1a968581cf6..f60d357ee3d 100644 --- a/src/auto-reply/reply/dispatch-from-config.ts +++ b/src/auto-reply/reply/dispatch-from-config.ts @@ -215,8 +215,14 @@ export async function dispatchReplyFromConfig(params: { const surfaceChannel = normalizeMessageChannel(ctx.Surface); // Prefer provider channel because surface may carry origin metadata in relayed flows. const currentSurface = providerChannel ?? surfaceChannel; + const isInternalWebchatTurn = + currentSurface === INTERNAL_MESSAGE_CHANNEL && + (surfaceChannel === INTERNAL_MESSAGE_CHANNEL || !surfaceChannel); const shouldRouteToOriginating = Boolean( - isRoutableChannel(originatingChannel) && originatingTo && originatingChannel !== currentSurface, + !isInternalWebchatTurn && + isRoutableChannel(originatingChannel) && + originatingTo && + originatingChannel !== currentSurface, ); const shouldSuppressTyping = shouldRouteToOriginating || originatingChannel === INTERNAL_MESSAGE_CHANNEL;