The SendGrid Custom Notification Integration package allows you to send custom notification emails through SendGrid when specific backend events are triggered. See the list of backend events that are currently supported by the package in the package’s config.json file.
Note: It is possible to send custom notification emails when frontend events are triggered, but it is not recommended for security purposes.
Before using the package, set up the following:
Open the Wix Secrets Manager and create a new secret called velo-sendgrid-api
. Store the SendGrid API key from step 3 above in this secret.
Configure the following in your config.json file:
verifiedSenderEmail
: The verified sender email address (string) used when setting up Single Sender Verification in your SendGrid account. This is the email address your notification emails will be sent from.
recipientEmails
: The array of email addresses to send your notification emails to.
events
: An object that contains the currently supported backend events for which you can trigger email notifications. For each event, set the respective boolean. To send a notification email when one of these backend events is triggered, set that event’s boolean value to true
.
templates
: An array of event template objects that define the contents (subject and body) of the email notifications that are sent when the respective event is triggered. Customize the contents of your email notifications by editing the subject and body of each event template object as desired.
Note: The contents of your email notifications can include html style tags, and variable placeholders from the event using ${ } syntax. For example, the body of this email notification includes html line breaks and headings, and a placeholder variable for the form name that was submitted.
The possible placeholders for each event are located in the event
parameter of the backend event. In the example above, you can find the form name placeholder, formName
in the event parameter of the onFormSubmit()
event.
The following files are included in the package. Note that only exported functions that you can use in your site are listed here.
config.json
The code in this file contains the configurations needed for using this package. Follow the instructions in the Setup section to edit the file with your configurations.
events.js
The code in this file contains functions that build the contents of the event notification emails from the event template objects located in the config.json file. It also handles the placeholders in the contents.
notifier.js
The code in this file contains a function that sends the notification email contents taken from the events.js file, and the sender and recipient email information from the config.json file to sendGrid.
This Velo package uses the following npm packages. To view the npm license, see the npm readmes.
1.0 Initial version.
sendGrid, notifications, customEmails, emails, automations, events