Chatwoot/app/services/message_templates/template/csat_survey.rb

25 lines
582 B
Ruby
Raw Normal View History

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