chatwoot/app/javascript/widget/components
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
..
Availability fix: Widget shows 'away' on initial load despite agents being online (#12869) 2025-11-20 20:27:44 +05:30
Form feat: Add RTL Support to Widget (#11022) 2025-03-21 09:39:03 -07:00
layouts feat: Support customizable welcome text, availability messages, and UI toggles (#11891) 2025-07-08 14:26:00 -07:00
pageComponents/Home/Article fix: TypeError: Cannot read properties of null (reading 'config') (#12356) 2025-09-03 17:07:34 +05:30
PreChat chore: Update theme colors and add new Inter variable fonts (#13347) 2026-01-28 14:36:04 -08:00
template chore: Remove older UI (#11720) 2025-07-01 09:43:44 +05:30
AgentMessage.vue fix(slack): Show correct sender name and avatar for Slack replies (#13624) 2026-02-26 16:15:15 +05:30
AgentMessageBubble.vue feat: Improve CSAT responses (#11485) 2025-05-16 14:18:52 +05:30
AgentTypingBubble.vue feat: Add RTL Support to Widget (#11022) 2025-03-21 09:39:03 -07:00
Banner.vue feat: Add RTL Support to Widget (#11022) 2025-03-21 09:39:03 -07:00
ChatAttachment.vue fix: Prioritize SDK enableFileUpload flag when explicitly set (#13091) 2025-12-17 19:03:54 +05:30
ChatFooter.vue feat: Migrate availability mixins to composable and helper (#11596) 2025-08-22 00:43:34 +05:30
ChatHeader.vue feat: Migrate availability mixins to composable and helper (#11596) 2025-08-22 00:43:34 +05:30
ChatHeaderExpanded.vue feat: Support customizable welcome text, availability messages, and UI toggles (#11891) 2025-07-08 14:26:00 -07:00
ChatInputWrap.vue chore: Use widget color for chat input focus state (#13214) 2026-01-14 14:33:56 +05:30
ChatMessage.vue feat: Add RTL Support to Widget (#11022) 2025-03-21 09:39:03 -07:00
ChatSendButton.vue feat: Add RTL Support to Widget (#11022) 2025-03-21 09:39:03 -07:00
ConversationWrap.vue feat: Add RTL Support to Widget (#11022) 2025-03-21 09:39:03 -07:00
DragWrapper.vue style: apply fixes for eslint issues [cw-3590] (#10210) 2024-10-03 15:02:12 +05:30
FileBubble.vue feat: Add RTL Support to Widget (#11022) 2025-03-21 09:39:03 -07:00
FooterReplyTo.vue chore: Remove older UI (#11720) 2025-07-01 09:43:44 +05:30
GroupedAvatars.vue chore: Replace Thumbnail with Avatar (#12119) 2025-08-11 15:47:17 +05:30
HeaderActions.vue feat: Support customizable welcome text, availability messages, and UI toggles (#11891) 2025-07-08 14:26:00 -07:00
ImageBubble.vue feat: Add RTL Support to Widget (#11022) 2025-03-21 09:39:03 -07:00
MessageReplyButton.vue chore: Remove older UI (#11720) 2025-07-01 09:43:44 +05:30
ReplyToChip.vue chore: Remove older UI (#11720) 2025-07-01 09:43:44 +05:30
TeamAvailability.vue feat: Migrate availability mixins to composable and helper (#11596) 2025-08-22 00:43:34 +05:30
UnreadMessage.vue fix: show agent name in unread bubble for Captain replies (#13876) 2026-03-23 20:03:31 +05:30
UnreadMessageList.vue chore: Remove older UI (#11720) 2025-07-01 09:43:44 +05:30
UserMessage.vue fix(widget): Queue SDK-set conversation attributes and labels for first message (#13912) 2026-04-02 12:09:24 +04:00
UserMessageBubble.vue feat: Add RTL Support to Widget (#11022) 2025-03-21 09:39:03 -07:00
VideoBubble.vue feat: Eslint rules (#9839) 2024-08-05 14:02:16 +05:30