Skip to content

fix(bitrix24): skip native-group mention gate for Open Channel sessions#1296

Merged
clark-cant merged 1 commit into
nextlevelbuilder:devfrom
tech-synity:b24-mention-gate-skip-openline-group
Jun 28, 2026
Merged

fix(bitrix24): skip native-group mention gate for Open Channel sessions#1296
clark-cant merged 1 commit into
nextlevelbuilder:devfrom
tech-synity:b24-mention-gate-skip-openline-group

Conversation

@tech-synity

Copy link
Copy Markdown
Contributor

Problem

Follow-up to #1295. After scoping the Open Channel mention gate by connector, customer messages on 1-to-1 connectors (Facebook Messenger, Zalo OA, …) are still being silently dropped — by the second mention-gate stanza further down in handleMessage, which checks the channel-level c.RequireMention() flag without distinguishing Open Channel traffic from native group chats (CRM deal/task chats).

For a channel like nguyen-dao-openline configured with RequireMention=true, the flow was:

  1. isOpenChannel block → shouldRequireMentionForOpenline("facebook|…") returns false (facebook isn't in the whitelist) → no drop.
  2. isGroup block (isOpenChannel implies isGroup) → c.RequireMention()=true AND mentioned=falseDROP.

Net effect: the gate-by-connector decision from #1295 was overridden one stanza later, and every Facebook customer turn disappeared. Reproduced live: customer sends "alo" from the Facebook Open Channel, payload arrives at goclaw (mime=audio/mpeg not relevant; same for plain text), and the bot stays silent.

Fix

Scope the drop check inside the isGroup block to native-group chats only (!isOpenChannel). Open Channel sessions already own their mention policy in the earlier isOpenChannel block; re-applying the channel-level RequireMention flag here second-guesses that decision.

if isGroup {
    mentioned := c.isMentionedParams(&evt.Params)
    if !isOpenChannel && c.RequireMention() && !mentioned {  // ← was: if c.RequireMention() && !mentioned
        // drop
        return
    }
    // text processing (MessageOriginal, stripMention, bxConvertUserMentionsToReadable)
    // stays unconditional so Openline staff turns with [USER=<botID>] BBCode still get cleaned up.
}

Importantly, the text-processing that follows the drop check (MessageOriginal fallback, stripMention, bxConvertUserMentionsToReadable) stays unconditional, so an Open Channel staff turn that does come in with [USER=<botID>]Bot[/USER] BBCode still gets cleaned up the same way it always did. The only thing the new guard suppresses is the drop itself.

Verification

go build ./... && go build -tags sqliteonly ./...
go vet ./internal/channels/bitrix24/...
go test ./internal/channels/bitrix24/...   → ok

Live-tested against tamgiac.bitrix24.com after deploying a local image build:

  • Facebook Messenger customer turn (IS_CONNECTOR=Y, CHAT_ENTITY_ID=facebook|34|…) now reaches the agent loop. Bot replies, matching the intent from feat(bitrix24): scope Open Channel mention gate to group-style connectors only #1295.
  • Zalo personal customer turn (whitelisted connector) without @mention still drops at the earlier gate — no regression.
  • Native group chats (CRM deal chats) without @mention still drop here when channel RequireMention=true — no regression.

Surface parity

Backend-only. No API contract / web UI / CLI change.

[B24:2794]

…ns [B24:2794]

Follow-up to nextlevelbuilder#1295. After scoping the Open Channel mention gate by
connector, customer messages on 1-to-1 connectors (Facebook Messenger,
Zalo OA, …) were STILL being silently dropped — by the second
mention-gate stanza further down in handleMessage, which checks the
channel-level c.RequireMention() flag without distinguishing Open
Channel traffic from native group chats (CRM deal/task chats).

For a channel like nguyen-dao-openline configured with RequireMention=true,
the flow was:

  1. isOpenChannel block → shouldRequireMentionForOpenline("facebook|...")
     returns false (facebook isn't in the whitelist) → no drop.
  2. isGroup block (isOpenChannel implies isGroup) → c.RequireMention()=true
     AND mentioned=false → DROP.

Net effect: the gate-by-connector decision was overridden one stanza
later, and every Facebook customer turn disappeared.

Fix: scope the drop check inside the isGroup block to native-group chats
only (!isOpenChannel). Open Channel sessions already own their mention
policy in the earlier isOpenChannel block; re-applying the channel-level
RequireMention flag here second-guesses that decision.

Importantly, the text-processing that follows the drop check
(MessageOriginal fallback, stripMention, bxConvertUserMentionsToReadable)
stays unconditional, so an Open Channel STAFF turn that does come in with
"[USER=<botID>]Bot[/USER]" BBCode still gets cleaned up the same way it
always did. The only thing the new guard suppresses is the drop itself.

Verified live: Facebook Messenger customer turn (IS_CONNECTOR=Y,
CHAT_ENTITY_ID=facebook|34|…) now reaches the agent loop and the bot
replies, matching the intent from nextlevelbuilder#1295.

Surface parity: backend-only. No API contract / web UI / CLI change.

@clark-cant clark-cant left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Clean follow-up to #1295 — the second mention-gate stanza was overriding the connector-scoped decision from the upstream gate, silently dropping customer turns on 1-to-1 connectors (Facebook, Zalo OA, etc.) via Open Channel.

The fix is minimal (+11/-1), well-documented, and correctly scopes the drop check to native group chats only while keeping text processing unconditional. CI green, live-verified.

Risk: Low. Backend-only, no API/contract change.

@clark-cant clark-cant merged commit 4675aa3 into nextlevelbuilder:dev Jun 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants