Repository navigation
feat(variables): add lead ad campaign fields, reel input type and picker entries - #1700
Merged
Merged
Conversation
sung17
force-pushed
the
feat/system-fields-lead-ads
branch
from
November 12, 2026 04:00
26f57f0 to
3f62a1c
Compare
…ker entries
- Add {{last_ad_name}}, {{last_adset_id}}, {{last_adset_name}},
{{last_campaign_id}} and {{last_campaign_name}}, read from the contact's
latest Facebook lead. The worker reads them from the Graph lead object in
a separate best-effort call, so missing ad-account access never fails a lead.
- {{last_ad}} falls back to the latest lead's ad when there is no referral.
- Add {{last_user_input_type}} as an alias of {{last_input_type}}; both return
"reel" for a reel shared on Instagram.
- Fix {{chat_history_details}} sender labels: the contact was labelled "Admin".
- Offer the system fields that already resolved but were missing from the
variable picker.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… entries Drop the other system fields this branch added to the variable picker and the labels only they used. The fields still resolve when typed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
sung17
force-pushed
the
feat/system-fields-lead-ads
branch
from
November 12, 2026 04:21
3f62a1c to
ce1a9fa
Compare
hello-jackytruong
referenced
this pull request
in hello-jackytruong/ChatWorkAI
Nov 22, 2026
…ker entries (#1700)
* feat(variables): add lead ad campaign fields, reel input type and picker entries
- Add {{last_ad_name}}, {{last_adset_id}}, {{last_adset_name}},
{{last_campaign_id}} and {{last_campaign_name}}, read from the contact's
latest Facebook lead. The worker reads them from the Graph lead object in
a separate best-effort call, so missing ad-account access never fails a lead.
- {{last_ad}} falls back to the latest lead's ad when there is no referral.
- Add {{last_user_input_type}} as an alias of {{last_input_type}}; both return
"reel" for a reel shared on Instagram.
- Fix {{chat_history_details}} sender labels: the contact was labelled "Admin".
- Offer the system fields that already resolved but were missing from the
variable picker.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* refactor(custom-fields): offer only total_tagged among the new picker entries
Drop the other system fields this branch added to the variable picker and
the labels only they used. The fields still resolve when typed.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---------
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
Completes the system field list for message and AI prompt variables. Most keys already resolved; this adds the missing ones, fixes one label bug and puts the rest in the variable picker.
{{last_ad_name}},{{last_adset_id}},{{last_adset_name}},{{last_campaign_id}},{{last_campaign_name}}, from the contact's latest lead.FacebookLeadAdsLead(adId,adName,adsetId,adsetName,campaignId,campaignName).processLeadgenreads them with a separate Graph call,getLeadAdAttribution. It is best-effort: names need ad-account access the page token may lack, so a failed read only leaves these fields empty and never fails the lead.adIdfalls back to the webhook'sadgroup_id.{{last_ad}}falls back to the latest lead's ad when the contact inbox has no referral.{{last_user_input_type}}is an alias of{{last_input_type}}, likelast_btt_title/last_btn_title.reelinput type: an Instagram message with anig_reel/reelattachment is markedcontentAttributes.type = "reel_share", the same way story mentions are.ContactInbox.lastUserInputTypeand{{last_input_type}}then returnreelinstead ofvideo. The contact filter gets a "Reel" option (21 locales).{{chat_history_details}}: lines were labelledsenderType === "user" ? "User" : "Admin", but inbound messages are saved ascontact, so the contact showed as "Admin" and agents as "User". Nowcontact→ User,user→ Admin,bot/api/system→ Bot.total_tagged(Messenger only). The other fields in this PR still resolve when typed but are not offered in the picker.Migrations
20261111070112_facebook_lead_ad_attribution:ADD COLUMN×6, all nullable.20261111072812_last_user_input_type_reel:ALTER TYPE "lastUserInputType" ADD VALUE 'reel'.Notes
video. There is no backfill.{{last_ad_body}}is still WhatsApp-only: Messenger/Instagram referrals carry no ad body.Testing
packages/variables: lead fields,last_adfallback, alias, reel input type, newchat-history.test.tsfor sender labelspackages/business: reel inlast-user-input.test.ts; lead service columnsapps/worker:lead-ads.test.tsstores attribution and survives a failed Graph read; full worker suite passes (5063).lead-ads.chain.test.tswas extended but not run (needsE2E_THROWAWAY_DATABASE).integrations/instagram,instagram-facebook: reel share markingapps/builder:reserved-custom-fields.test.ts;i18n:checkclean🤖 Generated with Claude Code