Skip to content

Comment-originated contacts cannot be messaged via API even after the contact replies (silent failure) #879

Closed

Description

@auroradream04

Summary

Contacts that originate from a Facebook comment cannot be messaged through the public API — even after the contact replies to the private reply and a standard 24-hour messaging window is open. The send returns 204, a message row is created, and nothing is delivered. sourceId is never populated on the row, which is the only way to tell from outside that it failed.

Sends to non-comment-origin contacts on the same inbox work reliably (22/22 in our sample), so this is specific to comment-originated contacts.

Cloud (app.chatbotx.io), Messenger channel, workspace API key.

Reproduction

Contact A (11630996004388864), inbox 11627001976487936. Times UTC, same thread:

time messageType senderType delivered? note
10:47:30 outgoing user yes (sourceId set) sent from Meta Business Suite, echoed in
10:47:50 incoming contact yes contact replies — 24h window opens
10:47:59 outgoing api no (sourceId null) POST /v1/contacts/id:.../messages → 204

Contact B (11630484688945152) is identical: contact sends "Is this free?" at 01:48:02, our API reply at 01:48:11 never delivers.

Sending manually from the ChatbotX inbox UI on the message thread also fails to deliver, so this is not specific to the public API.

Both contacts have a normal 17-digit contactInbox.sourceId, the same shape as contacts we message successfully. Their conversation.sourceId is <pageId>_<postId>.

Expected

Per Meta's Private Replies docs:

Only when a person responds to the private message can you continue the conversation within the 24-hour messaging window.

The contact responded, so a normal send should succeed.

Suspected cause

apps/worker/src/integration/handlers/received-message.ts — receiveComment keys the conversation to the post:

const incomingContact: IncomingContact = {
  sourceId: commentData.fromId,
  sourceConversationId: commentData.postId,
}

apps/worker/src/chat/handlers/send-message.ts then forwards that to the channel handler:

contact: { ...contactInbox, sourceConversationId: conversation.sourceId }

So a send resolving the comment conversation hands the channel a post id where a working contact supplies a message thread id. (The messenger channel implementation isn't in this repo, so I couldn't verify past this point.)

Possibly compounded by the assumption on the line above it:

// `from.id` is the commenter's ID (PSID for Messenger, ...)

Meta treats IDs across surfaces as not interchangeable — hence the ID Matching API. If a comment's from.id is not the messaging PSID for that Page, storing it as contactInbox.sourceId would produce exactly this: a well-formed id the Send API rejects.

Secondary issue: the failure is invisible to API consumers

send-message.ts emits message:failed internally, but nothing is persisted on the message row and the public API exposes no delivery status. From outside, a dead message is indistinguishable from a delivered one except by inferring from sourceId: null. This is the same silent-failure shape described in #831.

Surfacing a delivery status on the message resource would let integrators detect this without guesswork.

Third issue: lastIncomingMessageAt ignores comments and attachment-only messages

received-message.ts:

if (incomingMessage.messageType !== "outgoing" &&
    (incomingMessage.type ?? "message") === "message") {
  tracking.lastIncomingMessageAt = message.createdAt

Comments never update it, and attachment-only messages appear not to either. Since the unreplied and lastInteractionMinutesAgo contact filters are built on that column, any integrator polling for "who is waiting on a reply" is blind to both. In our workspace 48/50 comment-origin contacts have lastIncomingMessageAt: null.

Impact

Comment-to-DM is our main lead source. Every one of those leads who engages gets a reply that is recorded, billed, and shown as sent — and never arrives. It is silent on every surface except the Facebook thread itself.

Happy to test any fix against a live workspace.

Activity

  1. auroradream04 commented on Jul 31, 2026

    @auroradream04
    Author

    Correction: this is not limited to comment-originated contacts

    I scoped this to comment-origin contacts. That was wrong — it happens to contacts who messaged the Page directly too.

    Contact 11630857076490240, contactInbox.source = inboundMessage, conversation.sourceId = null (no post anchor anywhere):

    07:59:39  incoming  message  contact  sourceId set    "Online po?"
    07:59:49  outgoing  message  api      sourceId NULL   "Yes, the CPD webinars are delivered online…"
    

    She messaged the Page directly, we replied 10 seconds later, and it was never delivered.

    Measured failure rate

    Unbiased sample — every thread with an API-sent message in the last 24 hours, no filter on what happened afterwards:

    • 25 threads
    • 84 outgoing messages with senderType: api
    • 11 with sourceId never populated → 13.1%

    My earlier "22/22 succeed" figure in the issue was measured on threads where the contact replied afterwards, which self-selects for delivered messages. Please disregard it.

    What this means

    Roughly one in eight API sends is silently dropped, across both comment-origin and direct-message contacts. Because message:failed is emitted internally but never persisted on the row or exposed on the API, integrators have no way to detect it other than polling sourceId and inferring — which is what we now do.

    That makes the second point in the original issue (surface a delivery status on the message resource) considerably more urgent than the first: even if the root cause is environment-specific, an integrator currently cannot tell a delivered message from a dropped one.

    Happy to run any diagnostic against this workspace.

  2. added
    bug
    on Aug 12, 2026
  3. sung17 commented on Sep 23, 2026

    @sung17
    Collaborator

    Thank you for this report — and particularly for the follow-up correction.
    Retracting the "22/22 succeed" figure because it was measured on a
    self-selecting sample, and replacing it with an unbiased 24-hour one, is more
    rigour than a bug report usually gets. It changed how we prioritised this.

    Your second point already shipped

    The silent-failure problem — a dropped message being indistinguishable from a
    delivered one — was addressed in #946 (merged 13 Aug). It adds a sendError
    column to the message row, written by the worker when a channel send throws and
    cleared again if a retry later succeeds. It is returned on the message resource,
    so contacts.listMessages and contacts.getMessage should now carry it.

    Could you confirm it is present on your instance? If it is, each of those 11
    dead rows should carry the actual Graph API error — by far the most useful
    thing for closing the rest of this.

    Your suspected cause is not it

    You read the code correctly: receiveComment does key the comment conversation
    to the post, and the chat handler does forward that as sourceConversationId.
    But the Messenger handler never reads that field. It builds the Send API payload
    as recipient: { id: contact.sourceId } — the PSID from ContactInbox. A post
    id arriving there is simply ignored, so it cannot be what breaks the send.

    Your ID Matching hypothesis is the stronger one and we have not ruled it out.

    On lastIncomingMessageAt

    Half right. Comments genuinely do not update it. Attachment-only messages do —
    the inbound check looks at message type, not at content.

    The comment exclusion is deliberate, and for a reason worth knowing: that column
    also feeds the Messenger messaging-window policy, not only the unreplied and
    lastInteractionMinutesAgo filters. If comments refreshed it, we would start
    treating the 24-hour window as open when Meta does not — turning a silent
    failure into a louder one. For "who is waiting on a reply, counting commenters",
    the value you want is lastCommentMessageAt, maintained separately on the
    contact-inbox row. If that is not reachable from where you need it, say so and
    we will treat that as its own gap.

    What we have changed so far

    #1248 makes the public contacts API resolve a contact's conversation and
    ContactInbox deterministically. Both were previously picked without an
    ordering, so a send could land on a comment thread or address the wrong channel,
    and it failed asynchronously after the handler had already returned 204 — the
    same shape you describe.

    We are deliberately not claiming that as the fix for this issue. It is a real
    bug on its own merits, but whether it accounts for your 13% is unconfirmed,
    which is why #1248 references this issue rather than closing it.

    What would help most

    1. sendError for the rows where sourceId stayed null. One sample is enough.
    2. For each failing contact: how many ContactInbox rows they have (how many
      channels/pages), how many Conversation rows, and which conversationId the
      dead message landed in — the DM conversation, or a comment thread.
    3. contactInbox.lastIncomingMessageAt for those contacts at the time of the
      send.

    (2) tells us whether #1248 was the cause. (3) tests a separate hypothesis: API
    sends currently run through the same messaging-window policy as inbox sends,
    which refuses outright past 7 days since the last inbound message. We would
    rather see your data than loosen that on a guess.

    Keeping this open until the numbers say otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions