feat: allow captain to access contact attributes (#13850)

# Pull Request Template

## Description

Captain v1 does not have access to contact attributes. Added a toggle to
let user choose if they want contact information available to Captain.

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)

## How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration.

Specs and locally
<img width="1924" height="740" alt="CleanShot 2026-03-19 at 18 48 19@2x"
src="https://github.com/user-attachments/assets/353cfeaa-cd58-40eb-89e7-d660a1dc1185"
/>

![Uploading CleanShot 2026-03-19 at 18.53.26@2x.png…]()


## Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [x] I have commented on my code, particularly in hard-to-understand
areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [x] Any dependent changes have been merged and published in downstream
modules
This commit is contained in:
Aakash Bakhle
2026-03-20 16:15:06 +05:30
committed by GitHub
parent a9123e7d66
commit 290dd3abf5
17 changed files with 159 additions and 45 deletions

View File

@@ -0,0 +1,27 @@
class BackfillFeatureContactAttributesForAssistants < ActiveRecord::Migration[7.1]
# Only backfill assistants on accounts with captain_integration_v2 enabled.
# V1 assistants never had contact attributes, so limit to v2.
def up
return unless ChatwootApp.enterprise?
Account.feature_captain_integration_v2.find_each do |account|
account.captain_assistants.each do |assistant|
next if assistant.feature_contact_attributes.present?
assistant.update(feature_contact_attributes: true)
end
end
end
def down
return unless ChatwootApp.enterprise?
Account.feature_captain_integration_v2.find_each do |account|
account.captain_assistants.each do |assistant|
next if assistant.feature_contact_attributes.blank?
assistant.update(feature_contact_attributes: nil)
end
end
end
end

View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.1].define(version: 2026_02_26_153427) do
ActiveRecord::Schema[7.1].define(version: 2026_03_20_074636) do
# These extensions should be enabled to support this database
enable_extension "pg_stat_statements"
enable_extension "pg_trgm"