Published on : June 12, 2020
Template Url : https://loantap.in/wp-admin/post.php?post=1103829&action=edit
Setup the template :
[cnotify_customer.template.set send.all desc="Send all Notifications"]
//***when file is not present, return error***//
[aw2_error.create message="Method is mandatory" error_code="item_missing" c.empty="@template.method" o.set=@template.ack/]
[aw2_error.create message="Event is mandatory" error_code="item_missing" c.empty="@template.event" o.set=@template.ack/]
//*****return ack when error is present*****//
[@template.return @template.ack c.aw2_error="@template.ack"/]
//**load config**//
[cnotify_customer.config o.set=@template.notification_config /]
//**check if we have event in actual notification_sets **//
[@template.set notification_set={@template.event} /]
//**get all the method config**//
[@template.get notification_config.methods.{@template.method}.{@template.event} o.set="@template.method_config" /]
//**check if notification_set is present in the event so that we override**//
[@template.set notification_set="{@template.method_config.notification_set}" c.not_empty='@template.method_config.notification_set' /]
[@template.get notification_config.notification_sets.{@template.notification_set} o.set=@template.data /]
//****iterate the data****//
[loop.@data @template.data c.not_empty='@template.data']
[if.equal lhs={@data.item.send} rhs='yes']
[@template.set service='cnotify_customer.send.{@data.key}'/]
[service.run service={@template.service} data='{@template.data}' o.set=@template.ack.{@data.key} /]
[/if.equal]
[/loop.@data]
//****if data is empty, create error****//
[aw2_error.create message="Event config is not present" error_code="item_missing" c.empty="@template.data" o.set=@template.ack/]
//****return ack****//
[@template.return @template.ack/]
[/cnotify_customer.template.set]
Setup the send notification on email function
[cnotify_customer.template.set send.email]
[env.notify_data.to_email o.set=@template.to_email_id /]
[@template.set ack.message="Email is not supposed to be sent." /]
[@template.return @template.ack c.cond='@template.data.email.send' c.neq='s:yes' /]
//*** test notification **//
[@template.set email_id="nishant@loantap.in" c.cond="cookie.debug_dev" c.eq="s:yes" /]
[env.set notify_data.from.email_id][@content_type.config.email.from_email_id /][/env.set]
//** [env.set notify_data.reply_to.email_id][env.notify_data.notification_object_id/][@content_type.config.email.reply_to_domain/][/env.set]**//
//***when email<arr> is empty***//
[@template.set_array email c.empty="@template.email"]
[to email_id={@template.to_email_id}/]
[provider id="sendgrid"/]
[/@template.set_array]
//***load email settings****//
[@template.set settings={@content_type.config.email_provider}/]
//****Default mail provider****//
[@template.set_array email.provider id={@template.settings.default} c.empty="@template.email.provider.id"/]
//****fetch the api key against the provided provider id*****//
[@template.get settings.{@template.email.provider.id}.key o.set=@template.api_key/]
//**Setting provider api key from the settings when the api key is not passed in array**//
[if.not_empty @template.api_key]
[@template.set_array email.provider key={@template.api_key} c.empty="@template.email.provider.key"/]
[/if.not_empty]
//**for the application@help.loantap.in and <app_id>@help.loantap.in**//
[@template.set_array email.from email_id={env.notify_data.from.email_id} c.not_empty="env.notify_data.from.email_id"/]
[@template.set_array email.reply_to email_id={env.notify_data.reply_to.email_id} c.not_empty="env.notify_data.reply_to.email_id"/]
//**notification to email**//
[notification_service.send-v2
email={@template.email}
template_slug={@template.data.slug}
template_post_type={@template.data.post_type}
notification_object_type={env.notify_data.notification_object_type}
notification_object_id={env.notify_data.notification_object_id}
log='yes'
tracking_set={@template.data.slug}
o.set=@template.ack/]
//*****return ack*****//
[@template.return @template.ack/]
[/cnotify_customer.template.set]
Setup the send notification on SMS function
[cnotify_customer.template.set send.sms]
[env.notify_data.to_mobile_number o.set=@template.sms.to.mobile_number /]
//*** test notification **//
[@template.set mobile_number="9762800590" c.cond="cookie.debug_dev" c.eq="s:yes"/]
//***load sms settings****//
[@template.set settings={@content_type.config.sms_provider}/]
//****Default sms provider****//
[@template.set_array sms.provider id={@template.settings.default} c.empty="@template.sms.provider.id"/]
//****fetch the api key against the provided provider id*****//
[@template.get settings.{@template.sms.provider.id} o.set=@template.settings/]
//**Setting provider api key from the settings when the api key is not passed in array**//
[if.not_empty @template.settings.key]
[@template.set_array sms.provider key={@template.settings.key} c.empty="@template.sms.provider.key"/]
[/if.not_empty]
//****getting data from settings****//
[if.equal lhs={@template.sms.provider.id} rhs="msg91" ]
[@template.set_array sms.provider sender={@template.settings.sender}/]
[@template.set_array sms.provider route={@template.settings.route}/]
[@template.set_array sms.provider country={@template.settings.country} c.empty="@template.sms.provider.country"/]
[/if.equal]
//**notification to mobile_number**//
[notification_service.send-v2
sms={@template.sms}
template_slug={@template.data.slug}
template_post_type={@template.data.post_type}
notification_object_type={env.notify_data.notification_object_type}
notification_object_id={env.notify_data.notification_object_id}
log='yes'
tracking_set={@template.data.slug}
o.set=@template.ack/]
//*****return ack*****//
[@template.return @template.ack/]
[/cnotify_customer.template.set]
Setup the send notification on whatapp function
[cnotify_customer.template.set send.whatsapp]
[env.notify_data.to_mobile_number o.set=@template.whatsapp.to.mobile_number /]
//*** test notification **//
[@template.set to_mobile_number="9762800590" c.cond="cookie.debug_dev" c.eq="s:yes"/]
//****Default sms provider****//
[@template.set whatsapp.provider='acl' c.empty="@template.whatsapp.provider"/]
//**notification to mobile_number**//
[notification_service.send-v2
whatsapp={@template.whatsapp}
template_slug={@template.data.slug}
template_post_type={@template.data.post_type}
notification_object_type={env.notify_data.notification_object_type}
notification_object_id={env.notify_data.notification_object_id}
log='yes'
tracking_set={@template.data.slug}
o.set=@template.ack/]
//*****return ack*****//
[@template.return @template.ack/]
[/cnotify_customer.template.set]