iachat/app/javascript/widget
Muhsin Keloth b3d0af84c4
fix(widget): Queue SDK-set conversation attributes and labels for first message (#13912)
### Description

When integrating the web widget via the JS SDK, customers call
setConversationCustomAttributes and setLabel on chatwoot:ready — before
any conversation exists. These API calls silently fail because the
backend endpoints require an existing conversation. When the visitor
sends their first message, the conversation is created without those
attributes/labels, so the message_created webhook payload is missing the
expected metadata.

This change queues SDK-set conversation custom attributes and labels in
the widget store when no conversation exists yet, and includes them in
the API request when the first message (or attachment) creates the
conversation. The backend now permits and applies these params during
conversation creation — before the message is saved and webhooks fire.

###  How to test

  1. Configure a web widget without a pre-chat form.
2. Open the widget on a test page and run the following in the browser
console after chatwoot:ready:
`window.$chatwoot.setConversationCustomAttributes({ plan: 'enterprise'
});`
`window.$chatwoot.setLabel('vip');` // must be a label that exists in
the account
  3. Send the first message from the widget.
4. Verify in the Chatwoot dashboard that the conversation has plan:
enterprise in custom attributes and the vip label applied.
5. Set up a webhook subscriber for `message_created` confirm the first
payload includes the conversation metadata.
6. Verify that calling `setConversationCustomAttributes` / `setLabel` on
an existing conversation still works as before (direct API path, no
regression).
  7. Verify the pre-chat form flow still works as expected.
2026-04-02 12:09:24 +04:00
..
api fix(widget): Queue SDK-set conversation attributes and labels for first message (#13912) 2026-04-02 12:09:24 +04:00
assets fix: html/body background not applied in appearance mode (#13955) 2026-03-31 16:55:21 +05:30
components fix(widget): Queue SDK-set conversation attributes and labels for first message (#13912) 2026-04-02 12:09:24 +04:00
composables fix: html/body background not applied in appearance mode (#13955) 2026-03-31 16:55:21 +05:30
constants feat: widget opened and closed events (#11240) 2025-04-24 17:01:39 +05:30
helpers perf: reduce presence update frequency and fix background tab throttling (#13726) 2026-03-09 18:23:44 +05:30
i18n chore: Update translations (#13832) 2026-03-17 16:02:40 -07:00
mixins feat: Migrate availability mixins to composable and helper (#11596) 2025-08-22 00:43:34 +05:30
store fix(widget): Queue SDK-set conversation attributes and labels for first message (#13912) 2026-04-02 12:09:24 +04:00
views fix: html/body background not applied in appearance mode (#13955) 2026-03-31 16:55:21 +05:30
App.vue chore: Use widget color for chat input focus state (#13214) 2026-01-14 14:33:56 +05:30
router.js chore: Add cache to improve widget performance (#11163) 2025-03-24 16:04:49 -07:00