Chatwoot/app/services/message_templates/template/csat_survey.rb
2021-06-23 19:29:27 +05:30

24 lines
582 B
Ruby

class MessageTemplates::Template::CsatSurvey
pattr_initialize [:conversation!]
def perform
ActiveRecord::Base.transaction do
conversation.messages.create!(csat_survey_message_params)
end
end
private
delegate :contact, :account, to: :conversation
delegate :inbox, to: :message
def csat_survey_message_params
{
account_id: @conversation.account_id,
inbox_id: @conversation.inbox_id,
message_type: :template,
content_type: :input_csat,
content: I18n.t('conversations.templates.csat_input_message_body')
}
end
end