Repository navigation
fix(instagram-facebook): send private reply via page node, not igId - #875
Merged
Merged
Conversation
sendPrivateReply posted to `${igId}/messages`, but Meta's Messenger
Platform private-reply endpoint for Page-token connections is
`/<PAGE_ID>/messages`. This left IG-via-Facebook-Login private replies
silently broken while public comment replies (a different endpoint)
kept working.
viethung0o0
pushed a commit
that referenced
this pull request
Sep 7, 2026
…875) sendPrivateReply posted to `${igId}/messages`, but Meta's Messenger Platform private-reply endpoint for Page-token connections is `/<PAGE_ID>/messages`. This left IG-via-Facebook-Login private replies silently broken while public comment replies (a different endpoint) kept working. Co-authored-by: Deathgiver <[email protected]>
9 of 11 tasks
sung17
added a commit
that referenced
this pull request
Sep 9, 2026
…#1122) sendPrivateReplyMessage posted to `{igId}/messages`, which Meta rejects with `(#3) Application does not have the capability to make this API call.` even when the app holds instagram_manage_messages, pages_messaging and Human Agent at Advanced Access. For Instagram via Facebook Login the `messages` edge only exists on the Page node, so every private reply on that channel failed: the automation's `text` and `AIAgent` replies, the first message of a `flow` reply, and the agent's manual private reply from the inbox. This is the second time the fix has been needed. #875 moved the endpoint to `pageId`, then #945 moved it back to green a stale test whose fixture carried no `pageId` at all — so the endpoint silently became `/undefined/messages` and the assertion on the IG node kept passing. The test is now the guard instead of the cause: the fixture carries a `pageId` distinct from `igId`, and a new case asserts the IG node is never called. Also guards a missing `pageId` explicitly rather than building `/undefined/messages`, which is the silent failure mode that hid the regression. Two adjacent error-mapping bugs surfaced while tracing this: - Code 3 was in neither Instagram mapper, so it fell through to the `type === "OAuthException"` fallback and was reported as AUTH_FAILED — pointing operators at a reconnect that could never help. It is a capability problem, so it now maps to PERMISSION_DENIED (permanent), as messenger already does. - instagram-facebook's isRevokedTokenError matched *any* OAuthException, including code 3, making the disconnect flow skip its remote teardown for unrelated errors. Narrowed to code 190 plus a revoked subcode, matching the Instagram Login variant, which excludes a bare 190 as ambiguous to avoid false-positive disconnects. Unrelated, found in the same log: the getProfile failure in received-message.ts logged under `error`, so pino dropped the stack trace. Keyed to `err`. Co-authored-by: Deathgiver <[email protected]>
hello-jackytruong
referenced
this pull request
in hello-jackytruong/ChatWorkAI
Nov 22, 2026
… (#1122)
sendPrivateReplyMessage posted to `{igId}/messages`, which Meta rejects with
`(#3) Application does not have the capability to make this API call.` even when
the app holds instagram_manage_messages, pages_messaging and Human Agent at
Advanced Access. For Instagram via Facebook Login the `messages` edge only
exists on the Page node, so every private reply on that channel failed: the
automation's `text` and `AIAgent` replies, the first message of a `flow` reply,
and the agent's manual private reply from the inbox.
This is the second time the fix has been needed. #875 moved the endpoint to
`pageId`, then #945 moved it back to green a stale test whose fixture carried no
`pageId` at all — so the endpoint silently became `/undefined/messages` and the
assertion on the IG node kept passing. The test is now the guard instead of the
cause: the fixture carries a `pageId` distinct from `igId`, and a new case
asserts the IG node is never called.
Also guards a missing `pageId` explicitly rather than building
`/undefined/messages`, which is the silent failure mode that hid the regression.
Two adjacent error-mapping bugs surfaced while tracing this:
- Code 3 was in neither Instagram mapper, so it fell through to the
`type === "OAuthException"` fallback and was reported as AUTH_FAILED —
pointing operators at a reconnect that could never help. It is a capability
problem, so it now maps to PERMISSION_DENIED (permanent), as messenger
already does.
- instagram-facebook's isRevokedTokenError matched *any* OAuthException,
including code 3, making the disconnect flow skip its remote teardown for
unrelated errors. Narrowed to code 190 plus a revoked subcode, matching the
Instagram Login variant, which excludes a bare 190 as ambiguous to avoid
false-positive disconnects.
Unrelated, found in the same log: the getProfile failure in received-message.ts
logged under `error`, so pino dropped the stack trace. Keyed to `err`.
Co-authored-by: Deathgiver <[email protected]>
This branch was previously deployed
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
sendPrivateReplywas posting to${igId}/messages, which is the endpoint for the separate Instagram-Login package. For Page-token connections (Facebook Login), Meta's Messenger Platform requiresPOST /<PAGE_ID>/messagesfor private replies.Changes
integrations/instagram-facebook/src/apis/comment.ts:sendPrivateReplynow posts to${version}/${auth.metadata.pageId}/messagesinstead of${version}/${auth.metadata.igId}/messages, matching Meta's documented private-reply endpoint for Page-token connections. Updated the misleading comment above the function (it previously and incorrectly justified theigIdendpoint).Test plan
pnpm --filter @chatbotx.io/integration-instagram-facebook check-typespnpm lint