chatwoot/app
Gabriel Jablonski 37eed5de1e
feat(whatsapp): Add support for voice messages (#14606)
> Reopened from #13613, now from a personal fork
(`gabrieljablonski/chatwoot`) so maintainers can push edits —
organization-owned forks don't support "Allow edits from maintainers".
The previous PR is closed in favor of this one; same commits, same diff.

## Description

This PR adds support for sending voice messages (voice notes) through
the WhatsApp Cloud API. When agents record audio in Chatwoot, it is now
transcoded in the browser from WebM/Opus to OGG/Opus and sent with the
`voice: true` flag, so it appears as a native voice note bubble on
WhatsApp — not as a file/document attachment.

Closes #13283

**Key Changes:**
- Added `webmOpusToOgg.js` — a pure JS EBML parser + OGG page builder
that remuxes browser-recorded WebM/Opus audio into OGG/Opus entirely
client-side, with no server-side dependencies.
- Updated `AudioRecorder.vue` to use an explicit `mimeType` hint, proper
resource cleanup, and an `AUDIO_EXTENSION_MAP` for correct file
extensions.
- Renamed `mp3ConversionUtils.js` → `audioConversionUtils.js` and added
OGG conversion support via the new remuxer.
- Updated `ReplyBox.vue` to request OGG format for WhatsApp channels,
pass `isVoiceMessage` per-attachment, and handle recording errors with a
user-facing alert.
- Updated `MessageBuilder` to read the `is_voice_message` param and
persist it in attachment metadata.
- Updated `WhatsappCloudService` to:
- Normalize `audio/opus` → `audio/ogg` content type on ActiveStorage
blobs (works around Marcel gem re-detection).
- Send the `voice: true` flag when the attachment is a voice message
with `audio/ogg` content type.
  - Use WhatsApp Cloud API `v24.0` for the attachment endpoint.
- Added `AUDIO_CONVERSION_FAILED` i18n key.

**How it works:**
1. The browser records audio as WebM/Opus (Chrome/Firefox default).
2. `audioConversionUtils.js` remuxes it to OGG/Opus using the pure-JS
`webmOpusToOgg` remuxer — no server transcoding needed.
3. The OGG file is uploaded with `is_voice_message: true` in the form
payload.
4. `MessageBuilder` persists `is_voice_message` in the attachment's
`meta` hash.
5. `WhatsappCloudService` normalizes the blob content type if needed,
then sends the attachment with `voice: true` so WhatsApp renders it as a
voice note.

## Type of change

- [X] New feature (non-breaking change which adds functionality)

## How Has This Been Tested?

1. Record a voice message in a WhatsApp Cloud conversation.
2. Verify the audio is transcoded to OGG (check file extension in the
attachment preview).
3. Verify the message arrives on WhatsApp as a voice note bubble (not a
document/file).
4. Send an image or document attachment and verify it still works as
before (no `voice` flag).
5. Send a regular (non-voice) audio file and verify it arrives without
the voice flag.

---------

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
Co-authored-by: Muhsin <12408980+muhsin-k@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-02 15:33:32 +04:00
..
actions fix: Skip redundant contact saves in ContactIdentifyAction (#13778) 2026-03-11 21:40:38 -07:00
assets feat: Hide installation identifier (#11722) 2025-06-17 15:45:40 -07:00
builders feat(whatsapp): Add support for voice messages (#14606) 2026-06-02 15:33:32 +04:00
channels fix: Move contact events to account stream rather than individual user stream (#11082) 2025-03-13 17:46:48 -07:00
controllers feat(onboarding): honor return_to hint in Instagram OAuth callback (#14568) 2026-06-02 15:28:08 +05:30
dashboards feat: Add platform-wide status banners for outage notifications (#13943) 2026-04-29 17:18:38 +04:00
dispatchers feat: Unread Count: added api, store refresher, invalidation and events (2/3)[CW-6851] (#14369) 2026-05-20 17:36:09 +05:30
drops fix: render agent variables in automation messages (#14338) 2026-05-04 13:25:40 +05:30
fields fix(super-admin): prefill confirmed_at in new user form (#13662) 2026-03-10 12:14:58 +05:30
finders feat(voice): Wire Twilio voice flow through unified call model (#14091) 2026-04-30 11:25:39 +04:00
helpers feat(onboarding): honor return_to hint in Instagram OAuth callback (#14568) 2026-06-02 15:28:08 +05:30
javascript feat(whatsapp): Add support for voice messages (#14606) 2026-06-02 15:33:32 +04:00
jobs feat: scheduler fairness [AI-159] (#14425) 2026-05-27 16:01:51 +05:30
listeners feat(conversations): remove unread count feature flag (CW-7237) (#14610) 2026-06-02 14:35:37 +05:30
mailboxes fix: captain-v2 cannot see image attachments shared via email (#14449) 2026-05-19 10:11:32 +05:30
mailers fix: validate OpenAI hook credentials (#14068) 2026-05-18 14:08:57 +05:30
models feat: Implemented search results page functionality (#11086) 2026-06-02 15:19:23 +05:30
policies fix(contacts): align contact export permissions (#14601) 2026-06-01 13:58:57 +05:30
presenters feat(webhooks): Emit inbox_updated when an inbox is disconnected (#14504) 2026-05-22 09:00:18 +04:00
services feat(whatsapp): Add support for voice messages (#14606) 2026-06-02 15:33:32 +04:00
views feat: Implemented search results page functionality (#11086) 2026-06-02 15:19:23 +05:30