Email Notifications
A common notification method is an email. This can be accomplished easily in the SDK using the HQ API, but some parameters need a little more explanation.
Which Method to Use
The general convention is to use the most recent HQ method, which in this case (at the time of writing this article) is SendNotification5WithHtml module. The latest method will be indicated by the number in the method name, 5. This latest version introduces the notification_time parameter, which allows for notifications to be scheduled. Notice that there are many other SendNotification methods in the HQ API. Any of these can be used to send an email, but each one will offer slightly different functionality. For instance, only the methods with “WithHtml” will allow for HTML to be sent in an email.
Note
HQ preserves backwards compatibility by creating new methods endpoints with new parameters. This is why there are five different SendNotification methods.
Parameter details
text_body/html_body - The body of the email will be placed in both of these parameters. The text_body is used for non-web browser email viewing.
add_html_header_and_footer - If set to True
, this will include email headers and footers that the FI has
configured. Generally, this will be the FI’s logo.
add_disclaimer - If set to True
, this will include any disclaimer language the FI has configured. Generally,
this will be a short statement about how the email was automatically generated, and how to treat the notification.
ui_short_name - Due to older existing logic in the Q2 platform, this value (For the SendNotification methods
specifically) should be set to Q2
. If this value is not set to Q2, header/footer and disclaimer values will not
populate in the email message
notification_flavor - Used for emphasis with certain notification types. This can be set to None
if not needed.
target_user_id - Used to set preferences of the message, such as language or themes.
Example call
params = SendNotification5WithHtml.ParamsObj(
self.logger, # logger
"Email", # notification type
"test@email.com", # target address
"testing email", # subject
"Text Body", # text body
"USA", # ISO A3 Country Code
"<p>HTML Body</p>", # HTML body
True, # header and footer boolean
True, # disclaimer boolean
"Q2", # UI short name
None, # notification flavor
self.online_user.user_id, # target user id
None, # notification time
hq_credentials=self.hq_credentials
)
await SendNotification5WithHtml.execute(params)