chatwoot/app/javascript/dashboard/api
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
..
captain feat: UI changes for document auto sync [AI-153] (#14258) 2026-05-11 20:13:29 +05:30
channel feat(voice): WhatsApp Cloud Calling — UI [6] (#14346) 2026-05-22 18:42:39 +05:30
enterprise perf: update the logic to purchase credits (#12998) 2025-12-08 10:52:17 +05:30
helpCenter feat: bulk change category for articles (#14443) 2026-05-26 17:32:58 +05:30
inbox feat(whatsapp): Add support for voice messages (#14606) 2026-06-02 15:33:32 +04:00
integrations feat: new Captain Editor (#13235) 2026-01-21 13:39:07 +05:30
specs feat(whatsapp): Add support for voice messages (#14606) 2026-06-02 15:33:32 +04:00
account.js feat: Reconnect logic (#9453) 2024-06-03 15:54:19 +05:30
accountActions.js feat: Create modal to merge two contacts (#2457) 2021-10-13 18:35:13 +05:30
agentBots.js feat: sign webhooks for API channel and agentbots (#13892) 2026-04-06 15:28:25 +05:30
agentCapacityPolicies.js feat: Agent capacity policy index page with CRUD actions (#12409) 2025-09-12 16:22:42 +05:30
agents.js feat: Adds bulk_invite api for onboarding view (#8931) 2024-02-16 17:01:27 +05:30
ApiClient.js feat: update tool-chain to latest (#7975) 2023-09-27 14:02:34 +05:30
assignableAgents.js chore: Add Assignable Agents API (#4722) 2022-05-23 19:24:07 +05:30
assignmentPolicies.js feat: Agent assignment policy index page with CRUD actions (#12373) 2025-09-10 12:07:21 +05:30
attributes.js feat: Render contact custom attributes in contact/conversation sidebar (#3310) 2021-11-11 15:23:33 +05:30
auditLogs.js feat: audit logs UI (#6803) 2023-04-17 19:11:05 +05:30
auth.js fix: Prevent display_name reset when updating password (#10374) 2025-06-11 19:05:30 -04:00
automation.js feat: add a common upload endpoint (#7806) 2023-08-31 10:36:02 +07:00
bulkActions.js feat: Add Bulk actions to conversations (#4647) 2022-06-03 11:12:22 +05:30
CacheEnabledApiClient.js fix: idb is not available in firefox private mode [CW-2217] (#7524) 2023-07-14 13:35:30 +05:30
campaigns.js feat: Add campaign (#2177) 2021-05-04 15:08:41 +05:30
cannedResponse.js Chore: Scope URLs with account_id (#601) 2020-03-09 23:27:10 +05:30
changelog.js feat: Changelog card components (#12673) 2025-10-27 14:39:49 +05:30
channels.js Chore: Add Facebook app set up documentation (#647) 2020-03-28 11:43:02 +05:30
companies.js feat(companies): add notes and history to company details (#14401) 2026-05-11 23:15:25 +05:30
contactNotes.js feat: Add notes for Contacts (#3273) 2021-10-25 18:35:58 +05:30
contacts.js feat(voice): WhatsApp Cloud Calling — UI [6] (#14346) 2026-05-22 18:42:39 +05:30
conversations.js feat: Unread Count: Frontend changes for showing unread count badges (3/3)[CW-6851] (#14372) 2026-05-20 19:21:25 +05:30
csatReports.js fix: CSAT filter metrics rendering & conversation reports not working [CW-1840, CW-1818] (#7170) 2023-05-23 16:47:04 +05:30
customRole.js chore: Custom Roles to manage permissions [ UI ] (#9865) 2024-09-17 11:40:11 -07:00
customViews.js feat: Adds the ability to delete a segment (#3836) 2022-01-24 17:37:43 +05:30
dashboardApps.js feat: Allow users to create dashboard apps to give agents more context (#4761) 2022-06-01 11:13:10 +05:30
endPoints.js fix: Prevent display_name reset when updating password (#10374) 2025-06-11 19:05:30 -04:00
inboxes.js feat(voice): WhatsApp Cloud Calling — UI [6] (#14346) 2026-05-22 18:42:39 +05:30
inboxHealth.js feat(whatsapp): add webhook registration and status endpoints (#13551) 2026-03-16 12:48:16 +05:30
inboxMembers.js Chore: Inbox Members API improvements (#3008) 2021-09-14 11:55:02 +05:30
integrations.js feat(apps): Shopify Integration (#11101) 2025-03-19 15:37:55 -07:00
labels.js feat: IndexedDB based caching for labels, inboxes and teams [CW-50] (#6710) 2023-03-27 12:16:25 +05:30
liveReports.js feat: Add live report for teams (#10849) 2025-03-12 16:03:09 -07:00
macros.js feat: Add API module and Vuex store for Macros (#5603) 2022-10-11 22:54:17 -07:00
mfa.js feat: allow disabling 2FA with a backup code (#14102) 2026-04-28 10:09:41 +07:00
notifications.js fix: Inbox view Read/Snoozed display filters (#8907) 2024-02-17 13:59:25 +05:30
notificationSubscription.js Feature: Add web push notification permission in frontend (#766) 2020-05-06 00:10:56 +05:30
notion_auth.js feat: notion OAuth setup (#11765) 2025-06-26 19:16:06 +05:30
onboarding.js refactor(onboarding): use separate onboarding controller (#14507) 2026-06-01 13:34:11 +05:30
reports.js feat: Add conversations summary CSV export (#13110) 2026-01-13 12:30:26 +04:00
samlSettings.js feat: SAML UI [CW-2958] (#12345) 2025-09-15 19:33:54 +05:30
search.js feat: Advanced Search Backend (#12917) 2026-01-07 15:30:49 +05:30
sla.js feat(ee): Add SLA management UI (#8777) 2024-02-20 23:03:22 -08:00
slaReports.js fix: Add more filters for SLA download reports (#9231) 2024-04-16 09:00:52 +05:30
summaryReports.js feat: label reports overview (#11194) 2025-06-11 14:35:46 +05:30
teams.js feat: IndexedDB based caching for labels, inboxes and teams [CW-50] (#6710) 2023-03-27 12:16:25 +05:30
userNotificationSettings.js Chore: Scope URLs with account_id (#601) 2020-03-09 23:27:10 +05:30
webhooks.js Chore: Scope URLs with account_id (#601) 2020-03-09 23:27:10 +05:30
yearInReview.js feat(ce): Add Year in review feature (#13078) 2025-12-15 17:24:45 -08:00