Skip to main content

Defining Notification Content

To structure the content for different types of triggers (such as on create, update, status changes, and reminders), you can implement a function named populate_triggers within the AppointmentView class. This function returns a dictionary containing the content for email and SMS notifications based on various trigger events.

class AppointmentView(AppointmentBaseView):
def populate_triggers(self):
triggers = {
"video": {
"completed": {
"sms": {
"body": "Thanks for attending the appointment",
},
"email": {
"subject": "Appointment Completed",
"body": "Thanks for attending the appointment",
}
},
"no_show": {
"sms": {
"body": "You have not attended the appointment"
},
"email": {
"subject": "Appointment No Show",
"body": "You have not attended the appointment"
}
},
# Include other trigger events and their notification content configurations here
},
# Additional triggers for different appointment types (e.g., "f2f", "audio") can be defined similarly
}
# Additional configurations for reminders can also be added here

return triggers

triggers = property(populate_triggers)

Explanation:

  • The populate_triggers function within the AppointmentView class generates a dictionary structure containing various trigger events (e.g., "completed," "no_show") along with their corresponding SMS and email notification content configurations for different appointment types (e.g., "video," "f2f," "audio").
  • The function allows for customization of the notification content for each trigger event, enabling tailored messages to be sent based on specific scenarios such as appointment completions, no-shows, cancellations, scheduling, and updates.
  • By defining the content in this structured manner, you can easily manage and modify the notification messages sent to recipients based on different trigger events and appointment types.

Passing Dynamic Parameters for Notifications

To handle the dynamic parameters that are passed to the triggers for notifications based on the appointment data, you can customize the get_trigger_params function within the AppointmentView class. This function allows the addition of extra parameters that can be utilized in the notification content to personalize the messages sent to the notification recipients.

class AppointmentView(AppointmentBaseView):
def get_trigger_params(self, instance):
result = {
'title': instance.title,
'description': instance.description,
'start_time': instance.start_time.strftime('%d %B %Y %I:%M %p'),
'duration': str(instance.duration) + " minutes",
"program_email": "abcd@zelthy.com",
"program_number": "1800 000 0000",
"program": "Sanofi Dupap",
"email_signature": "Thanks and Regards \n DKSH"
}
return result

Explanation:

  • The get_trigger_params function within the AppointmentView class is designed to provide a dictionary containing dynamic parameters based on the appointment data. These parameters can include details like the appointment title, description, start time, duration, program email, program number, program name, and email signature.
  • By overriding this function, additional parameters specific to the appointment or recipient details can be included, ensuring that the notifications contain personalized information relevant to each notification recipient.
  • The dynamic parameters retrieved from this function can be utilized in the notification content configurations specified for different trigger events, enhancing the customization and relevance of the messages sent to the recipients based on the appointment data.