From af276093bb0ba152e0fee2c40a7cf9c5449626fd Mon Sep 17 00:00:00 2001 From: mattwr18 Date: Mon, 19 Feb 2024 09:05:32 +0100 Subject: [PATCH] Update WhatsApp create template to add default welcome message --- lib/tasks/whats_app/create_templates.rake | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/tasks/whats_app/create_templates.rake b/lib/tasks/whats_app/create_templates.rake index ab3381f33..cf04ef93e 100644 --- a/lib/tasks/whats_app/create_templates.rake +++ b/lib/tasks/whats_app/create_templates.rake @@ -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