Customer SendGrid Integration
This option is best for customers who only need to send email notifications and whose email content aligns with the simple templating variables provided by HaaS for dynamic templates. This gives the customer full control over the templates/branding and using their own SendGrid account (which is useful for reputation purposes, especially SendGrid ia already used to send customer emails).
Overview
The SendGrid HaaS notifications work by:
- Granting an API Key to HaaS that allows Mail Send API access
- Create dynamic templates for each of the notification types and configuring the template IDs into HaaS
- Configuring HaaS to send from a specific email address who domain is properly verified in SendGrid.
All of these settings are configured per brand, so you may have different templates/from addresses and even API keys per brand.
Templates
The templates required align to the event types in the adapter sendNotification endpoint, but HaaS does the heavy lifting of converting the user and account IDs to human friendly names appropriate for email content.
The SendGrid dynamic templates allow customer control of email branding in a way completely separate from HaaS. The active version of a template can be changed without affecting the template ID, allowing for templates to be upgraded and rolled back to previous versions if an issue is detected.
There is a specific JSON payload for each event type which HaaS will send to the sendMail SendGrid API as a data template data payload. The following sections will describe the JSON payload for each event and a sample template for each.
All template examples are demonstrated using https://mjml.io, a lightweight JavaScript framework designed to help create responsive email-friendly HTML content. Whilst using MJML is used here for example purposes, you're not required to use it - you are free to create templates using any method or tool you prefer.
To preview the output, visit https://mjml.io, click "Try it live" on the homepage, and paste the template code into the editor.
Example Template: Arrangement Actionβ
- Subject:
CDR Arrangement {{ arrangementAction }}
- Event:
{
"name": "Joe Bloggs",
"sender": "Mark Smith",
"adr": "Test Software Product",
"arrangementAction": "STARTED",
"accountDetails": [
{ "maskedAccountNumber": "XXXX5685", "accountNickname":"Account 1"},
{ "maskedAccountNumber": "XXXX5487", "accountNickname":"Account 2"}
],
"dashboardUrl": "https://dashboard.exampleholder.com"
}
- Sample Template:
<mjml>
<mj-head>
<mj-attributes>
<mj-class name="h1" font-size="30px" />
</mj-attributes>
</mj-head>
<mj-body>
<mj-section background-color="#fafafa">
<mj-column>
<mj-text mj-class="h1">
{{#equals arrangementAction "STARTED"}}
CDR Arrangement Started
{{/equals}}
{{#equals arrangementAction "AMENDED"}}
CDR Arrangement Amended
{{/equals}}
{{#equals arrangementAction "REVOKED"}}
CDR Arrangement Revoked
{{/equals}}
{{#equals arrangementAction "EXPIRED"}}
CDR Arrangement Expired
{{/equals}}
</mj-text>
</mj-column>
</mj-section>
<mj-section background-color="#fafafa">
<mj-column>
<mj-text>Hi {{name}}</mj-text>
<mj-text>
{{#equals arrangementAction "STARTED"}}
{{ sender }} has set-up a sharing arrangement with {{ adr }} and is sharing data from one or more of your accounts:
{{/equals}}
{{#equals arrangementAction "AMENDED"}}
{{ sender }} has amended an existing sharing arrangement with {{ adr }} and is sharing data from one or more of your accounts:
{{/equals}}
{{#equals arrangementAction "REVOKED"}}
An existing sharing arrangement for {{ adr }} was revoked on request by {{ sender }} for one or more of your joint accounts:
{{/equals}}
{{#equals arrangementAction "EXPIRED"}}
An existing sharing arrangement for {{ adr }} has expired for one or more of your joint accounts:
{{/equals}}
</mj-text>
<mj-text>
<ul>
{{#each accountDetails}}
<li>{{this.maskedAccountNumber}} - {{this.accountNickname}}</li>
{{/each}}
</ul>
</mj-text>
</mj-column>
</mj-section>
<mj-section background-color="#fafafa">
<mj-column>
<mj-text> What is CDR data sharing?</mj-text>
<mj-text>The Consumer Data Right is an Australian government initiative to enable the secure transfer of data held by us to accredited parties (Accredited Data Recipients).</mj-text>
<mj-text>To manage your data sharing settings please goto: <a href="{{ dashboardUrl }}">{{ dashboardUrl }}</a></mj-text>
</mj-column>
</mj-section>
</mj-body>
</mjml>
Full example templates can be found in the Customer Managed SendGrid Setup Runsheet.