chatwoot/app/javascript/dashboard/components/widgets
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
..
conversation feat(whatsapp): Add support for voice messages (#14606) 2026-06-02 15:33:32 +04:00
DashboardApp fix: Use addEventListener instead of onmessage to listen to chatwoot-dashboard-app:fetch-info (#10342) 2024-10-28 20:43:47 -07:00
FilterInput chore: Remove vue-multiselect and migrate to next components (#13506) 2026-02-17 16:40:12 +05:30
forms feat(V5): Update settings pages UI (#13396) 2026-02-19 15:04:40 +05:30
mentions chore: resolve sass and vue compiler deprecation warnings (#13794) 2026-05-22 12:16:43 +05:30
modal fix: Inbox delete confirmation fails due to whitespace (#12498) 2025-09-23 22:20:43 +05:30
WootWriter feat(whatsapp): Add support for voice messages (#14606) 2026-06-02 15:33:32 +04:00
AILoader.vue chore: Remove older UI (#11720) 2025-07-01 09:43:44 +05:30
AttachmentsPreview.vue feat(whatsapp): Add support for voice messages (#14606) 2026-06-02 15:33:32 +04:00
AutomationActionInput.vue chore: Remove vue-multiselect and migrate to next components (#13506) 2026-02-17 16:40:12 +05:30
AutomationActionTeamMessageInput.vue chore: Remove vue-multiselect and migrate to next components (#13506) 2026-02-17 16:40:12 +05:30
AutomationFileInput.vue chore: Remove vue-multiselect and migrate to next components (#13506) 2026-02-17 16:40:12 +05:30
BackButton.vue chore: Update buttons in integrations page (#11120) 2025-03-20 21:15:47 +05:30
ChannelItem.vue feat(voice): WhatsApp Cloud Calling — UI [6] (#14346) 2026-05-22 18:42:39 +05:30
ChatTypeTabs.vue chore: Update theme colors and add new Inter variable fonts (#13347) 2026-01-28 14:36:04 -08:00
ColorPicker.vue chore: resolve sass and vue compiler deprecation warnings (#13794) 2026-05-22 12:16:43 +05:30
EmptyState.vue chore: Remove older UI (#11720) 2025-07-01 09:43:44 +05:30
FeatureToggle.vue style: apply fixes for eslint issues [cw-3590] (#10210) 2024-10-03 15:02:12 +05:30
InboxName.vue feat(V5): Update settings pages UI (#13396) 2026-02-19 15:04:40 +05:30
LoadingState.vue feat(V5): Update settings pages UI (#13396) 2026-02-19 15:04:40 +05:30
SettingIntroBanner.vue feat(V5): Update settings pages UI (#13396) 2026-02-19 15:04:40 +05:30
ShowMore.vue feat(ee): Review Notes for CSAT Reports (#13289) 2026-01-15 19:53:57 -08:00
TableFooter.vue style: apply fixes for eslint issues [cw-3590] (#10210) 2024-10-03 15:02:12 +05:30
TableFooterPagination.vue chore: Update buttons in dashboard (#11145) 2025-03-31 17:21:32 -07:00
TableFooterResults.vue chore: Remove older UI (#11720) 2025-07-01 09:43:44 +05:30
TableHeaderCell.vue feat: Update design for report pages (#10506) 2024-11-27 18:10:15 +08:00
ThumbnailGroup.vue chore: Replace Thumbnail with Avatar (#12119) 2025-08-11 15:47:17 +05:30
UserAvatarWithName.vue chore: Replace Thumbnail with Avatar (#12119) 2025-08-11 15:47:17 +05:30
VideoCallButton.vue chore: Update reply editor design (#10575) 2025-01-08 17:49:53 +05:30