Skip to content

fix(comment-automation): send private reply flows on instagram channels - #1018

Merged
sung17 merged 1 commit into
mainfrom
sung17/fix-instagram-comment-flow
Aug 22, 2026
Merged

sung17 merged 1 commit into
mainfrom
sung17/fix-instagram-comment-flow

Conversation

@sung17

@sung17 sung17 commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Flow-type private replies on instagram / instagramFacebook comment automations were enqueued without a commentAnchor, so the flow went out as a normal DM gated by the 24-hour messaging window and failed for commenters outside it (text replies already used the comment_id-anchored API and worked).
  • Mirrors the existing Messenger fix: the first flow message is delivered through Meta's recipient: { comment_id } Send API (7-day comment window, exempt from the 24h rule); subsequent messages use the normal path.
  • Bonus fix: IG private replies (flow and text) now stamp metadata: SENT_FROM_CHATBOTX, so coexist message_echo webhooks dedup them instead of re-ingesting our own reply as an incoming message.

Changes

  • apps/worker/src/integration/handlers/comment-automation/private-reply.ts — always attach the private commentAnchor to sendFlow jobs (was messenger-only).
  • apps/worker/src/chat/handlers/send-flow-step.ts — defensive channel gate now also allows instagram; stale "no Instagram private_replies equivalent" comment corrected.
  • integrations/instagram + integrations/instagram-facebook — new sendPrivateReplyMessage API (full message payload, metadata stamp, retry: 0); sendPrivateReply delegates to it; sendFlowStep consumes the anchor for the first yielded message.
  • integrations/instagram — resolveInstagramMessagingPolicy is now resolved lazily (memoized) in sendFlowStep so the up-front instagram_response_window_expired throw no longer kills the exempt anchored send; non-anchored sends keep the exact same enforcement.
  • packages/sdk — CommentAnchor JSDoc updated to reflect Messenger + Instagram support.
  • Tests: new send-flow-step-comment-anchor.test.ts for both IG integrations (incl. the >24h regression case both ways); worker tests flipped from asserting the old messenger-only behavior; API tests updated for the metadata stamp.

Test plan

  • vitest — instagram 58/58, instagram-facebook 32/32, messenger 209/209, worker 1596/1596
  • turbo check-types — 56/56 packages (pre-commit hook)
  • ultracite/biome clean (pre-commit hook)
  • Manual: on an IG channel, trigger a comment automation with a flow private reply for a contact whose last incoming message is >24h old; first flow message arrives as DM, no instagram_response_window_expired in worker logs, no duplicate incoming message (echo dedup)

Flow-type private replies on instagram/instagramFacebook were enqueued
without a commentAnchor, so the flow went out as a normal DM gated by the
24-hour messaging window and failed for commenters outside it. Mirror the
messenger fix: deliver the first flow message through Meta's
comment_id-anchored Send API (7-day comment window), resolving the
Instagram messaging policy lazily so the up-front window check no longer
kills the exempt anchored send. Also stamps metadata on IG private replies
so coexist echo webhooks dedup them.
@github-actions github-actions Bot added the bug Something isn't working as expected label Aug 22, 2026
@sung17
sung17 merged commit 1e53fee into main Aug 22, 2026
5 checks passed
realcodesiman pushed a commit that referenced this pull request Aug 23, 2026
Both `docs/fb-comment-automation.md` and the `fb-comment-automation` skill still
claimed Instagram comment automation was unimplemented ("the builder always stores
`type = "messenger"`", "IG private-DM text is out of scope"), which has been wrong
since #874 shipped the `ig-comments` builder feature and the `instagram` /
`instagramFacebook` channel types. #831 and #1018 then moved flow-based private
replies onto Meta's comment_id-anchored Send API. None of those PRs touched the
docs, so the guidance actively told readers (and AI agents) not to work on IG.

Rewrite the scope banner, the `type` option row, the reply-type table, the known-gap
bullet and skill trap 6 to describe the three `CommentAutomationChannelType` values,
and record the real per-channel limits: comment liking is messenger +
instagramFacebook only, and the hide image/video attachment lookup is messenger only.


Claude-Session: https://claude.ai/code/session_01Jr3BRqH3woCzbcePEBPira

Co-authored-by: Claude Opus 5 <[email protected]>
viethung0o0 pushed a commit that referenced this pull request Sep 7, 2026
…ls (#1018)

Flow-type private replies on instagram/instagramFacebook were enqueued
without a commentAnchor, so the flow went out as a normal DM gated by the
24-hour messaging window and failed for commenters outside it. Mirror the
messenger fix: deliver the first flow message through Meta's
comment_id-anchored Send API (7-day comment window), resolving the
Instagram messaging policy lazily so the up-front window check no longer
kills the exempt anchored send. Also stamps metadata on IG private replies
so coexist echo webhooks dedup them.

Co-authored-by: Deathgiver <[email protected]>
viethung0o0 pushed a commit that referenced this pull request Sep 7, 2026
Both `docs/fb-comment-automation.md` and the `fb-comment-automation` skill still
claimed Instagram comment automation was unimplemented ("the builder always stores
`type = "messenger"`", "IG private-DM text is out of scope"), which has been wrong
since #874 shipped the `ig-comments` builder feature and the `instagram` /
`instagramFacebook` channel types. #831 and #1018 then moved flow-based private
replies onto Meta's comment_id-anchored Send API. None of those PRs touched the
docs, so the guidance actively told readers (and AI agents) not to work on IG.

Rewrite the scope banner, the `type` option row, the reply-type table, the known-gap
bullet and skill trap 6 to describe the three `CommentAutomationChannelType` values,
and record the real per-channel limits: comment liking is messenger +
instagramFacebook only, and the hide image/video attachment lookup is messenger only.


Claude-Session: https://claude.ai/code/session_01Jr3BRqH3woCzbcePEBPira

Co-authored-by: Claude Opus 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.

1 participant