Skip to content

fix(variables): resolve user_id system field to the contact id - #1071

Merged
viethung0o0 merged 1 commit into
mainfrom
feat/user-source-id-system-field
Aug 31, 2026
Merged

viethung0o0 merged 1 commit into
mainfrom
feat/user-source-id-system-field

Conversation

@viethung0o0

Copy link
Copy Markdown
Contributor

Summary

  • {{user_id}} now resolves to the internal contact id instead of the channel-specific inbox id, so it stays stable for a contact across channels and is available even when no contact inbox is attached.
  • The channel-specific id remains available through the existing {{user_external_id}} system field, so no new field was introduced.

Changes

  • packages/variables/src/utils.ts — user_id returns contact.id
  • packages/variables/__tests__/system-fields.test.ts — dedicated user_id test; user_id removed from the contact-inbox passthrough set

Test plan

  • pnpm --filter @chatbotx.io/variables test — 174/174 passing
  • pnpm lint (ultracite) and pnpm turbo check-types — clean via pre-commit hooks
  • Manual check: a flow message using {{user_id}} renders the contact id; {{user_external_id}} still renders the PSID / channel id

@github-actions github-actions Bot added the bug Something isn't working as expected label Aug 31, 2026
@viethung0o0
viethung0o0 marked this pull request as ready for review August 31, 2026 07:46
@viethung0o0
viethung0o0 merged commit 18416f1 into main Aug 31, 2026
5 checks passed
sung17 added a commit that referenced this pull request Nov 30, 2026
Flows fill a dynamic image link's {{user_id}} with the contact's own id
(Contact.id) since #1071, but the /dynamic-images route still looked it up
as the channel-side ContactInbox.sourceId. No contact ever matched, so every
send fell back to the static background and showed only the leading static
layers (usually just the template picture).

The route now resolves the contact through
dynamicImageService.resolveContactInbox: by Contact.id first, then by
sourceId for links sent before the change.

Co-authored-by: Deathgiver <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants