Repository navigation
fix(flow): re-check instagram profile fields live in condition steps - #1579
Merged
Merged
Conversation
The Condition step matched "follows business on Instagram" (and the other Instagram profile filters) against the snapshot captured once at contact creation, so a contact who followed after their first comment never reached the "following" branch and looped back to the follow prompt. When a condition reads one of those fields, fetch the profile live first and write it through to the contact inbox before matching. A failed fetch keeps the stored value, so routing never breaks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
hello-jackytruong
referenced
this pull request
in hello-jackytruong/ChatWorkAI
Nov 22, 2026
…(#1579) The Condition step matched "follows business on Instagram" (and the other Instagram profile filters) against the snapshot captured once at contact creation, so a contact who followed after their first comment never reached the "following" branch and looped back to the follow prompt. When a condition reads one of those fields, fetch the profile live first and write it through to the contact inbox before matching. A failed fetch keeps the stored value, so routing never breaks. Co-authored-by: Deathgiver <[email protected]> Co-authored-by: Claude Opus 5.5 <[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
A customer's Instagram comment-to-DM flow got stuck in a loop. The flow checks "Follows business on Instagram". If the contact isn't following yet, it asks them to follow and offers an "I'm Following" button that goes back to the same Condition. Even after the contact followed, the Condition kept taking the "not following" branch.
Cause: the Condition step matches against
ContactInbox.followsBusiness, which is captured once when the contact is created. The background snapshot job also only fills empty columns. Only rendering the{{ig_follow_business}}variable re-fetched the value, and that result was cached for 5 minutes.Fix: when a Condition reads an Instagram profile field (
followsBusinessOnInstagram,businessFollowsUserOnInstagram,verifiedAccountOnInstagram,followerCountOnInstagram), it fetches the profile live and writes it to the contact inbox before matching.packages/variables: newrefreshContactProfileSnapshot. It drops the cached snapshot and reuses the existingresolveLiveProfileSnapshot, which fetches the profile and persists it throughcontactInboxService.refreshProfileSnapshot.apps/workerhandleCondition: calls it once per Condition run, only when a case uses one of those fields.Behavior
false(existingCOALESCEbehavior).MAX_NODE_EXECUTIONS.Not changed: if a contact has several Instagram inboxes, the filter still matches when any inbox row matches. Only the current conversation's inbox is refreshed.
No schema change, no migration, no new public API operation (this is internal step behavior).
Test plan
condition-handler.test.ts: refresh runs once before matching when a case uses an Instagram profile field, and is skipped otherwiserefresh-profile-snapshot.test.ts: invalidates the cache before fetching and persists the result; skips unsupported channels; never throws on fetch or inbox-lookup failure; still fetches when cache invalidation fails@chatbotx.io/variablessuite (288 tests) passpnpm lint; typecheck passed in the pre-commit hook (64 packages)followsBusinessbecomestrue🤖 Generated with Claude Code