Skip to content

Commit

Permalink
Merge pull request #1789 from tactilenews/1787_update_whats_app_creat…
Browse files Browse the repository at this point in the history
…e_template

Update WhatsApp create template to add default welcome message
  • Loading branch information
mattwr18 authored Feb 26, 2024
2 parents 0b3237c + af27609 commit 55bc4fb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/tasks/whats_app/create_templates.rake
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
# rubocop:disable Style/FormatStringToken
desc 'Create WhatsApp templates'
task create_whats_app_templates: :environment do
welcome_message_hash = { welcome_message: I18n.t('.')[:adapter][:whats_app][:welcome_message].gsub('%{project_name}', '{{1}}') }
default_welcome_message = ["*#{File.read(File.join('config', 'locales', 'onboarding', 'success_heading.txt'))}*",
File.read(File.join('config', 'locales', 'onboarding',
'success_text.txt'))].join("\n\n").gsub('100eyes', '{{1}}')
default_welcome_message_hash = { default_welcome_message: default_welcome_message }
requests_hash = I18n.t('.')[:adapter][:whats_app][:request_template].transform_values do |value|
value.gsub('%{first_name}', '{{1}}').gsub('%{request_title}', '{{2}}')
end
template_hash = welcome_message_hash.merge(requests_hash)
template_hash = default_welcome_message_hash.merge(requests_hash)
template_hash.each do |key, value|
WhatsAppAdapter::CreateTemplate.perform_later(template_name: key, template_text: value)
end
Expand Down

0 comments on commit 55bc4fb

Please sign in to comment.