Sample email flows: triggered by HTTP request
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.
Prerequisites
Before running either sample flow:
-
Download the following resource and deploy it 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):
-
In the settings of the email content and sendgrid nodes, 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.
-
Trigger using an end point (GET request)
This sample email flow generates personalized email messages using the email content node based on data provided via the http in node.
For an http in node that uses the `GET` method Node-RED automatically captures URL parameters and stores them in msg.payload
.
The email content node passes objects stored in msg.payload
to the Data Model of the template, allowing the template to use this data for personalization purposes (in scripts or expressions).
Sample URL for the end point using the GET method: [http://localhost:1880/email/cta?first=Emmerich&email=eballinger0@olacme.com
Use the inject nodes to trigger the process with a data set of 1 record. These pass JSON data via msg.payload
.
Trigger by submitting JSON data (POST request)
In this example the http in node is set up to listen to POST requests.
Use the tool Postman.app to submit sample data this process.
-
Add a request using the POST method. Sample URL:
http://localhost:1880/email/cta
-
Click Body and choose raw.
-
Add the JSON data below to the text area and before posting, set the format of the
raw
data to JSON.Copy[
{
"first": "Emmerich",
"last": "Ballinger",
"email": "eballinger0@olacme.com",
"guid": "6faffd34-6a9a-4aa3-abdc-4a86da569713"
},
{
"first": "Jody",
"last": "Ekell",
"email": "jekell1@olacme.com",
"guid": "706bb59a-804c-469c-9f77-a19896adceb6"
}
]