feat(ee): Add Captain features (#10665)
Migration Guide: https://chwt.app/v4/migration This PR imports all the work related to Captain into the EE codebase. Captain represents the AI-based features in Chatwoot and includes the following key components: - Assistant: An assistant has a persona, the product it would be trained on. At the moment, the data at which it is trained is from websites. Future integrations on Notion documents, PDF etc. This PR enables connecting an assistant to an inbox. The assistant would run the conversation every time before transferring it to an agent. - Copilot for Agents: When an agent is supporting a customer, we will be able to offer additional help to lookup some data or fetch information from integrations etc via copilot. - Conversation FAQ generator: When a conversation is resolved, the Captain integration would identify questions which were not in the knowledge base. - CRM memory: Learns from the conversations and identifies important information about the contact. --------- Co-authored-by: Vishnu Narayanan <vishnu@chatwoot.com> Co-authored-by: Sojan <sojan@pepalo.com> Co-authored-by: iamsivin <iamsivin@gmail.com> Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
This commit is contained in:
@@ -40,8 +40,6 @@ class Integrations::App
|
||||
ENV['SLACK_CLIENT_SECRET'].present?
|
||||
when 'linear'
|
||||
account.feature_enabled?('linear_integration')
|
||||
when 'captain'
|
||||
account.feature_enabled?('captain_integration') && InstallationConfig.find_by(name: 'CAPTAIN_APP_URL').present?
|
||||
else
|
||||
true
|
||||
end
|
||||
|
||||
@@ -18,7 +18,6 @@ class Integrations::Hook < ApplicationRecord
|
||||
include Reauthorizable
|
||||
|
||||
attr_readonly :app_id, :account_id, :inbox_id, :hook_type
|
||||
before_validation :ensure_captain_config_present, on: :create
|
||||
before_validation :ensure_hook_type
|
||||
|
||||
validates :account_id, presence: true
|
||||
@@ -64,30 +63,6 @@ class Integrations::Hook < ApplicationRecord
|
||||
|
||||
private
|
||||
|
||||
def ensure_captain_config_present
|
||||
return if app_id != 'captain'
|
||||
# Already configured, skip this
|
||||
return if settings['access_token'].present?
|
||||
|
||||
ensure_captain_is_enabled
|
||||
fetch_and_set_captain_settings
|
||||
end
|
||||
|
||||
def ensure_captain_is_enabled
|
||||
raise 'Captain is not enabled' unless Integrations::App.find(id: 'captain').active?(account)
|
||||
end
|
||||
|
||||
def fetch_and_set_captain_settings
|
||||
captain_response = ChatwootHub.get_captain_settings(account)
|
||||
raise "Failed to get captain settings: #{captain_response.body}" unless captain_response.success?
|
||||
|
||||
captain_settings = JSON.parse(captain_response.body)
|
||||
settings['account_email'] = captain_settings['account_email']
|
||||
settings['account_id'] = captain_settings['captain_account_id'].to_s
|
||||
settings['access_token'] = captain_settings['access_token']
|
||||
settings['assistant_id'] = captain_settings['assistant_id'].to_s
|
||||
end
|
||||
|
||||
def ensure_hook_type
|
||||
self.hook_type = app.params[:hook_type] if app.present?
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user