Repository navigation
feat(keywords): add manychat-style match conditions for contact keywords - #1617
Merged
Merged
Conversation
Contact (inbound) keywords can now combine message conditions (AND) with several values each (OR): is, similar to, contains, contains whole word, begins/ends with, doesn't contain, regex (RE2), phone, email, link, image, video and thumbs up. Matching ignores case and Vietnamese accents. - AutomatedResponse.conditions jsonb; migration turns existing inbound rules into one "contains" condition. Page (outbound) rules keep exact keywords. - Image/video-only messages reach Keywords and are only queued when a rule matches, so the AI never answers a bare photo. - Public API create/update accept `conditions`; CLI/MCP docs updated. - Fix: creating a text-reply keyword sent flowId "" and failed as bigint.
1 task done
hello-jackytruong
referenced
this pull request
in hello-jackytruong/ChatWorkAI
Nov 22, 2026
…rds (#1617) Contact (inbound) keywords can now combine message conditions (AND) with several values each (OR): is, similar to, contains, contains whole word, begins/ends with, doesn't contain, regex (RE2), phone, email, link, image, video and thumbs up. Matching ignores case and Vietnamese accents. - AutomatedResponse.conditions jsonb; migration turns existing inbound rules into one "contains" condition. Page (outbound) rules keep exact keywords. - Image/video-only messages reach Keywords and are only queued when a rule matches, so the AI never answers a bare photo. - Public API create/update accept `conditions`; CLI/MCP docs updated. - Fix: creating a text-reply keyword sent flowId "" and failed as bigint. Co-authored-by: Deathgiver <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
conditionsonkeywords.create/keywords.update), per AGENTS.md invariant 23.Changes
AutomatedResponse.conditionsjsonb (nullable, no default). Migration20261102052103_keyword_conditionsadds the column (IF NOT EXISTS) and turns every existing inbound rule into onecontainscondition. The flatkeywordscolumn keeps the trigger words for search,findByInboundKeywordand older clients. Excluded words and regex patterns are not copied into it.packages/automated-response/src/keyword-match.ts): one function per match type. Regex usesre2js, which runs in linear time, so a pattern like(a+)+$cannot stall the worker. "Similar to" allows one edit per five characters. Phone/email reuseextractContactInfo; link detection and Levenshtein moved topackages/utilsand are now shared with comment hiding and flow-config.re2js(~260 KB) lives in@chatbotx.io/database/partials/keyword-condition-schema, so client components importing thepartialsbarrel do not ship it.resolveIncomingTextRouting+enqueueMessage. They are queued only when an inbound rule matches, so the AI agent / Global Router never answer a bare photo.findManyByIdsnow returns each message's attachment file types.automatedResponseService): resolveskeywords/conditionsin one place for the UI, public API and template install. It rejects both at once, rejects conditions on outbound rules, and applies the same limits to plain keywords. Unchanged saves write no audit entry. Templates export/install conditions.inbound|commenttype list); new MCP eval case.flowId: "", which failed as an invalid bigint.Notes for reviewers
select max(cardinality(keywords)) from "AutomatedResponse" where type='inbound'on production. A rule with more than 50 keywords cannot be re-saved from the form until the limit is raised.Test plan
pnpm lint(includes i18n check and schema drift check)check-types: database, utils, flow-config, automated-response, business, worker, builderPOST /v1/keywordswithconditions, thenGETreturns them🤖 Generated with Claude Code