Sample email flow: notification with call to action (cta)
Note: Sample flows are provided by OL Connect Automate, once installed. It appears in the flows folder in the Import dialog in Node-RED which allows you to import the sample into a new or existing flow; see Importing and Exporting Flows in the Node-RED documentation. Instructions are given in this topic, but can also be found in the Read me comment that comes with the sample flow.
For a list of all sample flows, see Sample flows.
This sample email flow generates personalized email messages for XML data using the email content node and sends the result via the SendGrid service.
In its simplest form, an email flow may consist of a node that captures data, such as a folder capture or http in node, the the email content node to generate email content and a node to send the messages via an Email Service Provider (ESP) like SendGrid.
In this example the flow can be triggered either via an inject node, which provides a hard-coded path to a data file in msg.filename
or using the folder capture node by adding the data file into the watched directory.
Tip: Adding multiple inject nodes to your flow is a great way to test the flow with data files of different sizes.
Prerequisites
Before running the sample flow:
-
Download the following resources and deploy them to the OL Connect Server using the Send to Server option in OL Connect Designer (see Sending files to Connect Server or to another server):
-
Create the following directories in the root of your drive before deploying this example:
\workspace\email\cta
\workspace\email\cta\in
-
Download the following resources and save them in the
\workspace\email\cta
directory. -
In the settings of the data mapping, email content and sendgrid node, select the OL Connect Server to which the resources are sent.
-
Sign up with sendgrid.com for a trial or full account.
-
Create an API Key via the Settings section of the SendGrid dashboard.
-
In the settings of the sendgrid node of the flow:
-
Enter the key in the API Key field.
-
Select the Send all messages to the Test address option.
-
Enter your email address in the Test address field.
-
The notification with call to action (cta) flow
The data mapping node extracts data from a data file and stores the data in the OL Connect database.
The email content node merges this data with a template, returning an array with information about the generated messages in msg.payload
.
This data is processed by the sendgrid node which sends the email messages using the SendGrid API.
Use the inject nodes to trigger the process with a data set of 2 records or 10 records.
Alternatively, trigger the process using the Folder capture node, by copying one of the resource files (email-cta-2.xml or email-cta-10.xml) into the \workspace\email\cta\in
directory.