Skip to content

feat(chat): add markMessageAsPlayed endpoint (audio receipt)#2519

Open
rafavasconcelost wants to merge 1 commit intoEvolutionAPI:mainfrom
rafavasconcelost:feature/markMessageAsPlayed
Open

feat(chat): add markMessageAsPlayed endpoint (audio receipt)#2519
rafavasconcelost wants to merge 1 commit intoEvolutionAPI:mainfrom
rafavasconcelost:feature/markMessageAsPlayed

Conversation

@rafavasconcelost
Copy link
Copy Markdown

@rafavasconcelost rafavasconcelost commented Apr 27, 2026

📋 Description

Adds POST /chat/markMessageAsPlayed/{instance} for marking received audio messages as played (the blue microphone indicator in WhatsApp), mirroring the existing markMessageAsRead pattern.

Baileys natively exposes sock.sendReceipts(keys, 'played'), but Evolution currently only exposes the 'read' receipt type via /chat/markMessageAsRead. CRMs and dashboards that play back voice notes received from contacts have no way to send the played ack — this endpoint fills that gap with the same DTO/schema shape (key: id, fromMe, remoteJid) under a playedMessages array.

The implementation is fully symmetric to markMessageAsRead:

  • DTO: MarkMessageAsPlayedDto with playedMessages: Key[] (mirrors ReadMessageDto)
  • Schema: markMessageAsPlayedSchema (JSONSchema7, mirrors readMessageSchema)
  • Service: markMessageAsPlayedclient.sendReceipts(keys, 'played')
  • Controller: markMessageAsPlayedwaMonitor delegation
  • Router: POST routerPath('markMessageAsPlayed')

🔗 Related Issue

N/A — this is a new endpoint extension. Happy to open a tracking issue if maintainers prefer.

🧪 Type of Change

  • ✨ New feature (non-breaking change which adds functionality)

🧪 Testing

  • Manual testing completed
  • Functionality verified in development environment
  • No breaking changes introduced
  • Tested with Baileys connection (WhatsApp Web)

Smoke test against a running instance (Baileys, WhatsApp Web): POST /chat/markMessageAsPlayed/{instance} with a valid { playedMessages: [{ id, fromMe: false, remoteJid }] } body returns 201 { message: "Played messages", played: "success" }. The blue microphone indicator appears on the contact's WhatsApp client (verified on Android and iOS).

Without a valid API key it returns 401, matching the behavior of markMessageAsRead (confirms the route is registered and guarded correctly).

📝 Additional Notes

Use case: agent CRMs / customer support platforms (e.g. Chatwoot-like dashboards) that present audio messages from contacts with a play button. When the agent plays back the audio in the dashboard, the played receipt is forwarded to the contact's WhatsApp — same UX they get from a real WhatsApp client.

We've been running this in production on a self-hosted Coolify deployment for ~24h and confirmed it works end-to-end with no observed issues. Happy to address any review feedback.

✅ Checklist

  • My code follows the project's style guidelines (RouterBroker dataValidate, JSONSchema7 validation, Service Object pattern)
  • I have performed a self-review of my code
  • I have commented my code where helpful (Baileys sendReceipts semantics)
  • My changes generate no new warnings
  • I have manually tested my changes thoroughly
  • No dependent changes — pure addition, mirrors existing pattern

Adds POST /chat/markMessageAsPlayed/{instance} for marking received audio
messages as played (blue microphone in WhatsApp), mirroring the existing
markMessageAsRead pattern.

Baileys natively supports sock.sendReceipts(keys, 'played') but Evolution
only exposed the 'read' type via /chat/markMessageAsRead. CRMs that play
back voice notes received from contacts had no way to send the played
ack — this endpoint fills the gap with the same DTO/schema shape (key
shape: id, fromMe, remoteJid) under a 'playedMessages' array.

Mirrors:
- DTO: MarkMessageAsPlayedDto extends Key array (mirrors ReadMessageDto)
- Schema: markMessageAsPlayedSchema (JSONSchema7, mirrors readMessageSchema)
- Service: markMessageAsPlayed -> client.sendReceipts(keys, 'played')
- Controller: markMessageAsPlayed -> waMonitor delegation
- Router: POST routerPath('markMessageAsPlayed')

Use case: agent CRMs (Chatwoot-like) that present audio messages with a
play button and need to send the played receipt back to the contact when
the agent plays the audio in the dashboard.
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Sorry @rafavasconcelost, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant