feat: Use inbox image as avatar for the bot (#6859)
This commit is contained in:
parent
463c09184c
commit
91dc7733b0
@ -161,9 +161,6 @@ ANDROID_SHA256_CERT_FINGERPRINT=AC:73:8E:DE:EB:56:EA:CC:10:87:02:A7:65:37:7B:38:
|
|||||||
# for mobile apps
|
# for mobile apps
|
||||||
# FCM_SERVER_KEY=
|
# FCM_SERVER_KEY=
|
||||||
|
|
||||||
## Bot Customizations
|
|
||||||
USE_INBOX_AVATAR_FOR_BOT=true
|
|
||||||
|
|
||||||
### APM and Error Monitoring configurations
|
### APM and Error Monitoring configurations
|
||||||
## Elastic APM
|
## Elastic APM
|
||||||
## https://www.elastic.co/guide/en/apm/agent/ruby/current/getting-started-rails.html
|
## https://www.elastic.co/guide/en/apm/agent/ruby/current/getting-started-rails.html
|
||||||
|
|||||||
@ -439,7 +439,8 @@
|
|||||||
"LABEL": "Features",
|
"LABEL": "Features",
|
||||||
"DISPLAY_FILE_PICKER": "Display file picker on the widget",
|
"DISPLAY_FILE_PICKER": "Display file picker on the widget",
|
||||||
"DISPLAY_EMOJI_PICKER": "Display emoji picker on the widget",
|
"DISPLAY_EMOJI_PICKER": "Display emoji picker on the widget",
|
||||||
"ALLOW_END_CONVERSATION": "Allow users to end conversation from the widget"
|
"ALLOW_END_CONVERSATION": "Allow users to end conversation from the widget",
|
||||||
|
"USE_INBOX_AVATAR_FOR_BOT": "Use inbox name and avatar for the bot"
|
||||||
},
|
},
|
||||||
"SETTINGS_POPUP": {
|
"SETTINGS_POPUP": {
|
||||||
"MESSENGER_HEADING": "Messenger Script",
|
"MESSENGER_HEADING": "Messenger Script",
|
||||||
|
|||||||
@ -320,6 +320,17 @@
|
|||||||
{{ $t('INBOX_MGMT.FEATURES.ALLOW_END_CONVERSATION') }}
|
{{ $t('INBOX_MGMT.FEATURES.ALLOW_END_CONVERSATION') }}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="isAWebWidgetInbox" class="settings-item settings-item">
|
||||||
|
<input
|
||||||
|
v-model="selectedFeatureFlags"
|
||||||
|
type="checkbox"
|
||||||
|
value="use_inbox_avatar_for_bot"
|
||||||
|
@input="handleFeatureFlag"
|
||||||
|
/>
|
||||||
|
<label for="emoji_picker">
|
||||||
|
{{ $t('INBOX_MGMT.FEATURES.USE_INBOX_AVATAR_FOR_BOT') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<woot-submit-button
|
<woot-submit-button
|
||||||
v-if="isAPIInbox"
|
v-if="isAPIInbox"
|
||||||
|
|||||||
@ -119,13 +119,15 @@ export default {
|
|||||||
return type;
|
return type;
|
||||||
},
|
},
|
||||||
agentName() {
|
agentName() {
|
||||||
if (this.message.message_type === MESSAGE_TYPE.TEMPLATE) {
|
|
||||||
return 'Bot';
|
|
||||||
}
|
|
||||||
if (this.message.sender) {
|
if (this.message.sender) {
|
||||||
return this.message.sender.available_name || this.message.sender.name;
|
return this.message.sender.available_name || this.message.sender.name;
|
||||||
}
|
}
|
||||||
return 'Bot';
|
|
||||||
|
if (this.useInboxAvatarForBot) {
|
||||||
|
return this.channelConfig.websiteName;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.$t('UNREAD_VIEW.BOT');
|
||||||
},
|
},
|
||||||
avatarUrl() {
|
avatarUrl() {
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
|
|||||||
@ -78,6 +78,9 @@ export default {
|
|||||||
const { available_name: availableName, name } = this.sender;
|
const { available_name: availableName, name } = this.sender;
|
||||||
return availableName || name;
|
return availableName || name;
|
||||||
}
|
}
|
||||||
|
if (this.useInboxAvatarForBot) {
|
||||||
|
return this.channelConfig.websiteName;
|
||||||
|
}
|
||||||
return this.$t('UNREAD_VIEW.BOT');
|
return this.$t('UNREAD_VIEW.BOT');
|
||||||
},
|
},
|
||||||
availabilityStatus() {
|
availabilityStatus() {
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
export default {
|
export default {
|
||||||
computed: {
|
computed: {
|
||||||
useInboxAvatarForBot() {
|
useInboxAvatarForBot() {
|
||||||
return window.chatwootWidgetDefaults.useInboxAvatarForBot;
|
return this.channelConfig.enabledFeatures.includes(
|
||||||
|
'use_inbox_avatar_for_bot'
|
||||||
|
);
|
||||||
},
|
},
|
||||||
hasAConnectedAgentBot() {
|
hasAConnectedAgentBot() {
|
||||||
return !!window.chatwootWebChannel.hasAConnectedAgentBot;
|
return !!window.chatwootWebChannel.hasAConnectedAgentBot;
|
||||||
|
|||||||
@ -22,15 +22,16 @@ const preChatFields = [
|
|||||||
global.chatwootWebChannel = {
|
global.chatwootWebChannel = {
|
||||||
avatarUrl: 'https://test.url',
|
avatarUrl: 'https://test.url',
|
||||||
hasAConnectedAgentBot: 'AgentBot',
|
hasAConnectedAgentBot: 'AgentBot',
|
||||||
enabledFeatures: ['emoji_picker', 'attachments', 'end_conversation'],
|
enabledFeatures: [
|
||||||
|
'emoji_picker',
|
||||||
|
'attachments',
|
||||||
|
'end_conversation',
|
||||||
|
'use_inbox_avatar_for_bot',
|
||||||
|
],
|
||||||
preChatFormOptions: { pre_chat_fields: preChatFields, pre_chat_message: '' },
|
preChatFormOptions: { pre_chat_fields: preChatFields, pre_chat_message: '' },
|
||||||
preChatFormEnabled: true,
|
preChatFormEnabled: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
global.chatwootWidgetDefaults = {
|
|
||||||
useInboxAvatarForBot: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
describe('configMixin', () => {
|
describe('configMixin', () => {
|
||||||
test('returns config', () => {
|
test('returns config', () => {
|
||||||
const Component = {
|
const Component = {
|
||||||
@ -51,7 +52,12 @@ describe('configMixin', () => {
|
|||||||
expect(wrapper.vm.channelConfig).toEqual({
|
expect(wrapper.vm.channelConfig).toEqual({
|
||||||
avatarUrl: 'https://test.url',
|
avatarUrl: 'https://test.url',
|
||||||
hasAConnectedAgentBot: 'AgentBot',
|
hasAConnectedAgentBot: 'AgentBot',
|
||||||
enabledFeatures: ['emoji_picker', 'attachments', 'end_conversation'],
|
enabledFeatures: [
|
||||||
|
'emoji_picker',
|
||||||
|
'attachments',
|
||||||
|
'end_conversation',
|
||||||
|
'use_inbox_avatar_for_bot',
|
||||||
|
],
|
||||||
preChatFormOptions: {
|
preChatFormOptions: {
|
||||||
pre_chat_message: '',
|
pre_chat_message: '',
|
||||||
pre_chat_fields: preChatFields,
|
pre_chat_fields: preChatFields,
|
||||||
|
|||||||
@ -48,6 +48,7 @@ class Channel::WebWidget < ApplicationRecord
|
|||||||
has_flags 1 => :attachments,
|
has_flags 1 => :attachments,
|
||||||
2 => :emoji_picker,
|
2 => :emoji_picker,
|
||||||
3 => :end_conversation,
|
3 => :end_conversation,
|
||||||
|
4 => :use_inbox_avatar_for_bot,
|
||||||
:column => 'feature_flags',
|
:column => 'feature_flags',
|
||||||
:check_for_column => false
|
:check_for_column => false
|
||||||
|
|
||||||
|
|||||||
@ -18,8 +18,9 @@ json.chatwoot_website_channel do
|
|||||||
json.out_of_office_message @web_widget.inbox.out_of_office_message
|
json.out_of_office_message @web_widget.inbox.out_of_office_message
|
||||||
json.utc_off_set ActiveSupport::TimeZone[@web_widget.inbox.timezone].now.formatted_offset
|
json.utc_off_set ActiveSupport::TimeZone[@web_widget.inbox.timezone].now.formatted_offset
|
||||||
end
|
end
|
||||||
|
# Remove the following defaults by June 2023 as it would be covered by the feature flags
|
||||||
json.chatwoot_widget_defaults do
|
json.chatwoot_widget_defaults do
|
||||||
json.use_inbox_avatar_for_bot ActiveModel::Type::Boolean.new.cast(ENV.fetch('USE_INBOX_AVATAR_FOR_BOT', false))
|
json.use_inbox_avatar_for_bot @web_widget.use_inbox_avatar_for_bot
|
||||||
end
|
end
|
||||||
json.contact do
|
json.contact do
|
||||||
json.pubsub_token @contact_inbox.pubsub_token
|
json.pubsub_token @contact_inbox.pubsub_token
|
||||||
|
|||||||
@ -27,9 +27,6 @@
|
|||||||
allowMessagesAfterResolved: <%= @web_widget.inbox.allow_messages_after_resolved %>,
|
allowMessagesAfterResolved: <%= @web_widget.inbox.allow_messages_after_resolved %>,
|
||||||
disableBranding: <%= @web_widget.inbox.account.feature_enabled?('disable_branding') %>
|
disableBranding: <%= @web_widget.inbox.account.feature_enabled?('disable_branding') %>
|
||||||
}
|
}
|
||||||
window.chatwootWidgetDefaults = {
|
|
||||||
useInboxAvatarForBot: <%= ActiveModel::Type::Boolean.new.cast(ENV.fetch('USE_INBOX_AVATAR_FOR_BOT', false)) %>,
|
|
||||||
}
|
|
||||||
window.chatwootPubsubToken = '<%= @contact_inbox.pubsub_token %>'
|
window.chatwootPubsubToken = '<%= @contact_inbox.pubsub_token %>'
|
||||||
window.authToken = '<%= @token %>'
|
window.authToken = '<%= @token %>'
|
||||||
window.globalConfig = <%= raw @global_config.to_json %>
|
window.globalConfig = <%= raw @global_config.to_json %>
|
||||||
|
|||||||
@ -0,0 +1,12 @@
|
|||||||
|
class MigrateEnvVarToChannelFeature < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
return unless ActiveModel::Type::Boolean.new.cast(ENV.fetch('USE_INBOX_AVATAR_FOR_BOT', false))
|
||||||
|
|
||||||
|
Channel::WebWidget.find_in_batches do |widget_batch|
|
||||||
|
widget_batch.each do |widget|
|
||||||
|
widget.use_inbox_avatar_for_bot = true
|
||||||
|
widget.save!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2023_04_04_030719) do
|
ActiveRecord::Schema.define(version: 2023_04_07_191457) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "pg_stat_statements"
|
enable_extension "pg_stat_statements"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user