Skip to content

Comments on boosted posts never match the organic post's rule #34

Description

@CharanMN7

The bug

When you boost a post, comments left on the ad carry the ad's media id, not the original post's. A rule scoped to the organic post silently stops matching for exactly the traffic you paid to acquire.

The rule looks correct, the comment arrives, and nothing sends.

Why it happens

src/process.ts reads the media id from the webhook and hands it to findMatchingRule, which compares against rules.media_id:

const mediaId = asId(value.media?.id) ?? asId(value.media_id);

For an ad comment, that value is the ad's media id. The rule's is the organic post's. They never match.

The fix

Meta includes original_media_id on ad comments. Capture it and match against either id.

const mediaId = asId(value.media?.id) ?? asId(value.media_id);
const originalMediaId = asId(value.media?.original_media_id);

findMatchingRule should accept both and treat a rule as post-scoped-matching if it matches either. Prefer the original id when both are present, since that is the one a user would have selected in the picker.

Acceptance criteria

  • original_media_id parsed from the comment payload
  • A rule scoped to the organic post matches a comment left on an ad derived from it
  • Account-wide rules are unaffected
  • Media-scoped precedence over account-wide rules still holds
  • Tests with a realistic ad-comment payload

Where to look

  • src/process.ts — the CommentValue type and processComment
  • src/match.tsfindMatchingRule
  • scripts/test-unit.ts

Hard to test without a live boosted post, so a well-constructed fixture payload is the deliverable. Note it in the PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: automationTriggers, keywords, DM content, delivery behaviourarea: instagram-apiMeta Graph API surface, webhooks, OAuthbugSomething isn't workingeffort: smallA focused change, roughly an eveningroadmapA planned feature from the README roadmap

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions