Skip to content

fix(instagram-facebook): accept read receipts without watermark - #1696

Merged
realcodesiman merged 1 commit into
ChatbotXIO:mainfrom
rqms40:fix/instagram-facebook-read-watermark-1687
Nov 11, 2026
Merged

realcodesiman merged 1 commit into
ChatbotXIO:mainfrom
rqms40:fix/instagram-facebook-read-watermark-1687

Conversation

@rqms40

@rqms40 rqms40 commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Closes #1687

What changed

instagramReadSchema in the Instagram via Facebook Login integration now has watermark: z.number().optional(), the same as the Instagram Login integration (integrations/instagram/src/schema.ts).

Why

Instagram's messaging_seen webhook sends read: { mid } and no watermark. The schema required watermark, so Zod rejected the whole webhook body (invalid_type at entry.0.messaging.0.read.watermark) and the handler skipped it. contactLastReadAt was never set for Instagram contacts, and a message that arrived in the same batch as a read receipt was dropped with it.

Nothing downstream reads watermark. The webhook handler queues contactMarkAsRead for any parsed read object, and the worker's parseReadTimestamp takes the time from the messaging event's timestamp, so no handler change is needed.

Validation

  • New test in integrations/instagram-facebook/__tests__/webhook-integration-type.test.ts: a batch with a read receipt that has only mid, followed by a text message. It checks that the payload parses and that both contactMarkAsRead and incomingMessage are queued. Without the schema change it fails with the invalid_type issue at entry.0.messaging.0.read.watermark.
  • pnpm --filter @chatbotx.io/integration-instagram-facebook test: 31 files, 135 tests passed
  • pnpm --filter @chatbotx.io/integration-instagram-facebook check-types: passes
  • pnpm lint: passes
  • Not run: the dependent typecheck of builder/worker from the pre-commit hook, and a live Meta webhook.

Instagram messaging_seen sends read.mid and omits watermark. Requiring
watermark rejected the whole webhook, so the read and any batched message
were dropped. Match the Instagram Login schema and keep the event timestamp
on the contactMarkAsRead payload.
@github-actions github-actions Bot added the bug Something isn't working as expected label Nov 11, 2026
@realcodesiman
realcodesiman merged commit 2c4fb63 into ChatbotXIO:main Nov 11, 2026
14 checks passed
hello-jackytruong referenced this pull request in hello-jackytruong/ChatWorkAI Nov 22, 2026
Instagram messaging_seen sends read.mid and omits watermark. Requiring
watermark rejected the whole webhook, so the read and any batched message
were dropped. Match the Instagram Login schema and keep the event timestamp
on the contactMarkAsRead payload.

Co-authored-by: Mark David Prado <[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.

Instagram via Facebook Login: read receipts are dropped (instagramReadSchema requires watermark, Instagram sends only mid)

2 participants