Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

How to create an email notification

How to create an email template

  1. Contact any front-end developer in your team, and ask them to create the template
  2. Replace any dummy data in the email template with the correct data from DB for example, the following is the template from Front End dev
<html>
Hi {{User name}},
Your booking has been confirmed
</html>

Then backend dev need to update to be

<html>
Hi <%= user.name %>,
Your booking has been confirmed
</html>

See Engineering to test the email

How to send email

If you want to send a mailer every transaction done or specific date you can create services on this folder app/services and when the job has to run periodically, use Sidekiq Scheduler feature, see config/sidekiq_scheduler.yml if you just need to send once you can use https://api.rubyonrails.org/classes/ActionMailer/MessageDelivery.html

OwnerMailer.method_name(params).deliver_later(wait: 15.minutes)

To Owner : If you want to send notification for owner or restaurant you can write your code on app/mailers/owner_mailer.rb and write your email template on this folder app/views/owner_mailer and you can call your method by

OwnerMailer.method_name(params).deliver_later

To User : If you want to send notification for user you can write your code on app/mailers/user_mailer.rb and write your email template on this folder app/views/user_mailer and you can call your method by

UserMailer.method_name(params).deliver_later

To Staff : If you want to send notification for hungryhub staff you can write your code on app/mailers/staff_mailer.rb and write your email template on this folder app/views/staff_mailer and you can call your method by

StaffMailer.method_name(params).deliver_later

How to send email periodically

If you want to send email periodically like MonthlyReportWorker you can create your worker on this folder app/workers/schedule_workers and you can call those worker on this file config/sidekiq_scheduler.yml with this format:

monthly_report_restaurant_performance: (scheduller name)
  cron: "0 10 1 * * Asia/Bangkok" #Run monthly at 10 AM (when the cronjob will run the worker)
  class: ScheduleWorkers::MonthlyReportWorker (worker class)

you can user "cron" or "every"

if you use every
every: "20m" 
it should run the worker every 20 minutes

if you use cron like
cron: "0 10 * * mon Asia/Bangkok" 
it will run every monday at 10 AM Bangkok time zone