Skip to content

Conversation

@bergpinheiro
Copy link
Contributor

@bergpinheiro bergpinheiro commented Oct 2, 2025

πŸ“‹ Description

This PR adds the ability to mark conversations as "read" in the WAHA-Chatwoot integration.

✨ Features

  • βœ… New WAHAMessageReadConsumer consumer to process MESSAGE_ACK events
  • βœ… Filter to process only read confirmations (ack === 3)
  • βœ… Integration with Chatwoot API using update_last_seen endpoint
  • βœ… Webhook filter to avoid infinite loops (ignores status: "read")
  • βœ… Full support for contact and conversation mapping

πŸ”§ Technical Changes

New Files:

  • src/apps/chatwoot/consumers/waha/message.ack.ts - Consumer for read events

Modified Files:

  • src/apps/chatwoot/chatwoot.module.ts - Registration of the new queue and consumer
  • src/apps/chatwoot/client/ConversationService.ts - markAsRead() method
  • src/apps/chatwoot/client/ContactConversationService.ts - markConversationAsRead() method
  • src/apps/chatwoot/consumers/waha/base.ts - Added MESSAGE_ACK to events
  • src/apps/chatwoot/services/ChatWootWAHAQueueService.ts - Routing to new queue
  • src/apps/chatwoot/api/chatwoot.webhook.controller.ts - Webhook filter
  • src/structures/enums.dto.ts - Added MESSAGE_READ enum

πŸ§ͺ How to Test

  1. Send a message from Chatwoot to WhatsApp
  2. Read the message in WhatsApp
  3. Verify that the The conversation was marked as read in Chatwoot.

πŸ“ Notes

  • Uses MESSAGE_ACK instead of MESSAGE_READ (which is not generated by WAHA)
  • Correct URL: /public/api/v1/inboxes/{inbox_identifier}/contacts/{source_id}/conversations/{conversation_id}/update_last_seen
  • Authentication using inboxIdentifier as a token
  • Webhook filter to avoid processing read receipts

πŸ”— Related

  • Resolves the need to mark conversations as read in the Chatwoot integration
  • Improves the user experience with real-time read status

Related to #1319

patron:PRO

- Add WAHAMessageReadConsumer to process MESSAGE_ACK events
- Filter to process only read confirmations (ack === 3)
- Integration with Chatwoot API using update_last_seen endpoint
- Webhook filter to avoid infinite loops (ignores status: 'read')
- Full support for contact and conversation mapping

New Files:
- src/apps/chatwoot/consumers/waha/message.read.ts - Consumer for read events

Modified Files:
- src/apps/chatwoot/chatwoot.module.ts - Registration of new queue and consumer
- src/apps/chatwoot/client/ConversationService.ts - markAsRead() method
- src/apps/chatwoot/client/ContactConversationService.ts - markConversationAsRead() and getSourceIdByChatId() methods
- src/apps/chatwoot/consumers/waha/base.ts - Added MESSAGE_ACK to events
- src/apps/chatwoot/services/ChatWootWAHAQueueService.ts - Routing to new queue
- src/apps/chatwoot/api/chatwoot.webhook.controller.ts - Webhook filter
- src/apps/chatwoot/consumers/QueueName.ts - Added WAHA_MESSAGE_READ enum

Features:
Òœ… Real-time read status between WhatsApp and Chatwoot
Òœ… Improved user experience with read confirmations
Òœ… Robust integration using official Chatwoot APIs
Òœ… Infinite loop prevention with smart filters
Òœ… Detailed logging for debugging and monitoring

Resolves the need to mark conversations as read in the Chatwoot integration
Improves the user experience with real-time read status
@nathanarend
Copy link

nathanarend commented Oct 2, 2025

+1

patron:PLUS

1 similar comment
@WilliamSantos96
Copy link

WilliamSantos96 commented Oct 2, 2025

+1

patron:PLUS

@AnxHall
Copy link

AnxHall commented Oct 2, 2025

+1

@cristyanmarcelo
Copy link

cristyanmarcelo commented Oct 2, 2025

+1

patron:PLUS

Copy link
Contributor

@devlikepro devlikepro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requires a bit of changes, but overall it's gooooood πŸŽ‰

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use event in consumer name - so it'd be message.ack.ts because it process message.ack event.

…convention

- Rename file to reflect the MESSAGE_ACK event it processes
- Update import reference in chatwoot.module.ts
- Maintains same functionality while improving code clarity
@gabrielnogueiracsc
Copy link

gabrielnogueiracsc commented Oct 5, 2025

+1

patron:PRO

@MrDandi79
Copy link

MrDandi79 commented Oct 6, 2025

+1

patron:PLUS

@Click-Hype
Copy link

Click-Hype commented Oct 10, 2025

+1

patron:PLUS

}

// Ignore messages with status "read" (from update_last_seen endpoint)
if (body.status === 'read') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no such field :(
The only message_updated we need - when agent clicks on "Retry" button in CHatWoot message.
Found a bit weird way to identify it, hopefully it'll work 🀞

@devlikepro
Copy link
Contributor

devlikepro commented Oct 12, 2025

2025.10.1 - Mark messages as Read in ChatWoot - #1319 , #1436

patron:PRO

@github-actions
Copy link

Portuguese


Title:

2025.10.1 - Marcar mensagens como lidas no ChatWoot - #1319 , #1436

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants