Describe the bug
When custom conversation attributes are queued via the JS SDK before a conversation exists (window.$chatwoot.setConversationCustomAttributes({...}) called right after "chatwoot:ready", with no active conversation yet), they are silently lost when the visitor's first message is submitted through the pre-chat form.
Root cause: PreChatForm.vue's onSubmit() calls this.clearConversations() (which resets conversation/pendingCustomAttributes to {}) before dispatching conversation/createConversation. The createConversation action only sends whatever customAttributes was explicitly passed in from the form (conversationCustomAttributes, from pre-chat custom fields), it never reads pendingCustomAttributes from state, unlike sendMessage/sendMessageWithData and sendAttachment, which do merge in pendingCustomAttributes/pendingLabels for every message after the first one.
So conversation custom attributes set via the SDK survive if the visitor's inbox has no pre-chat form (first message goes through the plain sendMessage path once the conversation already exists client-side), but are dropped whenever a pre-chat form is enabled, which is the default/common setup.
To Reproduce
- Enable "Pre Chat Form" on a Website inbox.
- Embed the widget and, before opening it, run:
window.addEventListener('chatwoot:ready', () => { window.$chatwoot.setConversationCustomAttributes({ referral_code: 'ABC123' }); });
- Open the chat bubble → click "Start Conversation" → fill the pre-chat
form (name + message) → submit.
- Open the created conversation in the agent dashboard.
- Check "Conversation Information" → the referral_code custom attribute
(already registered in Settings > Custom Attributes, scope Conversation)
is empty.
Expected behavior
Conversation custom attributes queued via window.$chatwoot.setConversationCustomAttributes() before the conversation exists should still be attached to the conversation once it's created via the pre-chat form, the same way they'd be attached to the second message sent in that conversation.
Environment
Docker
Cloud Provider
DigitalOcean
Platform
Browser
Operating system
Windows 11
Browser and version
Chrome 153
Docker (if applicable)
No response
Additional context
Confirmed in the current develop branch source (app/javascript/widget/store/modules/conversation/actions.js and
app/javascript/widget/views/PreChatForm.vue) , not fixed in the latest version. Happy to open a PR with the fix (already have a working patch + test in my fork).
Describe the bug
When custom conversation attributes are queued via the JS SDK before a conversation exists (
window.$chatwoot.setConversationCustomAttributes({...}) called right after "chatwoot:ready", with no active conversation yet), they are silently lost when the visitor's first message is submitted through the pre-chat form.Root cause:
PreChatForm.vue's onSubmit()callsthis.clearConversations()(which resets conversation/pendingCustomAttributes to {}) before dispatching conversation/createConversation. The createConversation action only sends whatever customAttributes was explicitly passed in from the form (conversationCustomAttributes, from pre-chat custom fields), it never reads pendingCustomAttributes from state, unlike sendMessage/sendMessageWithData and sendAttachment, which do merge in pendingCustomAttributes/pendingLabels for every message after the first one.So conversation custom attributes set via the SDK survive if the visitor's inbox has no pre-chat form (first message goes through the plain sendMessage path once the conversation already exists client-side), but are dropped whenever a pre-chat form is enabled, which is the default/common setup.
To Reproduce
window.addEventListener('chatwoot:ready', () => { window.$chatwoot.setConversationCustomAttributes({ referral_code: 'ABC123' }); });form (name + message) → submit.
(already registered in Settings > Custom Attributes, scope Conversation)
is empty.
Expected behavior
Conversation custom attributes queued via window.$chatwoot.setConversationCustomAttributes() before the conversation exists should still be attached to the conversation once it's created via the pre-chat form, the same way they'd be attached to the second message sent in that conversation.
Environment
Docker
Cloud Provider
DigitalOcean
Platform
Browser
Operating system
Windows 11
Browser and version
Chrome 153
Docker (if applicable)
No response
Additional context
Confirmed in the current
developbranch source (app/javascript/widget/store/modules/conversation/actions.js andapp/javascript/widget/views/PreChatForm.vue) , not fixed in the latest version. Happy to open a PR with the fix (already have a working patch + test in my fork).