feat: Add a pre-chat form on widget (#1769)
This commit is contained in:
9
app/views/api/v1/models/_widget_message.json.jbuilder
Normal file
9
app/views/api/v1/models/_widget_message.json.jbuilder
Normal file
@@ -0,0 +1,9 @@
|
||||
json.id resource.id
|
||||
json.content resource.content
|
||||
json.message_type resource.message_type_before_type_cast
|
||||
json.content_type resource.content_type
|
||||
json.content_attributes resource.content_attributes
|
||||
json.created_at resource.created_at.to_i
|
||||
json.conversation_id resource.conversation.display_id
|
||||
json.attachments resource.attachments.map(&:push_event_data) if resource.attachments.present?
|
||||
json.sender resource.sender.push_event_data if resource.sender
|
||||
10
app/views/api/v1/widget/conversations/create.json.jbuilder
Normal file
10
app/views/api/v1/widget/conversations/create.json.jbuilder
Normal file
@@ -0,0 +1,10 @@
|
||||
json.id @conversation.display_id
|
||||
json.inbox_id @conversation.inbox_id
|
||||
json.contact_last_seen_at @conversation.contact_last_seen_at.to_i
|
||||
json.status @conversation.status
|
||||
json.messages do
|
||||
json.array! @conversation.messages do |message|
|
||||
json.partial! 'api/v1/models/widget_message', resource: message
|
||||
end
|
||||
end
|
||||
json.contact @conversation.contact
|
||||
@@ -19,7 +19,9 @@
|
||||
widgetColor: '<%= @web_widget.widget_color %>',
|
||||
enabledFeatures: <%= @web_widget.selected_feature_flags.to_json.html_safe %>,
|
||||
enabledLanguages: <%= available_locales_with_name.to_json.html_safe %>,
|
||||
replyTime: '<%= @web_widget.reply_time %>'
|
||||
replyTime: '<%= @web_widget.reply_time %>',
|
||||
preChatFormEnabled: <%= @web_widget.pre_chat_form_enabled %>,
|
||||
preChatFormOptions: <%= @web_widget.pre_chat_form_options.to_json.html_safe %>
|
||||
}
|
||||
window.chatwootWidgetDefaults = {
|
||||
useInboxAvatarForBot: <%= ActiveModel::Type::Boolean.new.cast(ENV.fetch('USE_INBOX_AVATAR_FOR_BOT', false)) %>,
|
||||
|
||||
Reference in New Issue
Block a user