The Business Requirement:
Our imaginary customer utilizes an Emarsys Contact Form on their main website as a contact form. We can also use custom forms but this is a topic of another blog. After a contact fills out the form, an automation program is triggered with a Form Entry Point. The contact enters the automation program. As you see from the contact form below, there is a field as the topic of request and this field determines the choice of department that the contact wants to reach.
Our customer requires that for some departments, we need to send departmental email notifications to different departmental email inboxes. For example, if the contact chooses HR as the topic of request, an email should be sent to the HR department. And, Emarsys doesn’t provide this functionality as standard. And in Emarsys, only the contact who enters the program can receive emails from Emarsys with a “Send Email” channel node.
Firstly, It would be better to explain how Emarsys Forms behave. All the information on the form has an equivalent field on the contact database. Let's say, salutation is a standard field on the contact object. But the topic of request and comment fields are custom fields. When the contact fills out the form, the information basically is going to be saved to the contact's fields. And you can use these fields to send emails or create leads on c4c via a webhook. If a contact is already existing with the email address, they update the fields but if no contact exists with that email address, a new contact is created. Basically, the standard field "email" is the unique identifier for the contacts in the Emarsys Forms.
As you see in the automation program below, the contact can choose to contact with HR or Finance department, in this case, we want to send all the information that the contact has filled out on the forms to these departments. Or if the contact chooses the Sales department, we can create a lead on C4C. The real use cases can be much more complicated. That is why, I am showing a simple use case here to help us focus on our real topic which is sending departmental notifications.
Steps to do:
- Creation of the Webhook
On the Webhook Creation page, we need to create the payload with the contact fields and map these payload fields to the Emarsys contact fields. You can refer to the screenshot below:
The payload would look like this if the webhook is triggered:
Example JSON payload:
{ "salutation": "1", "first_name": "Can", "last_name": "Akalin", "email": "canakalin@test.com", "company": "Test Co", "your_department": "3", "website": "
www.test.com", "zipcode": "34655", "street": "Kozyatağı", "house_number": "3121", "city": "Istanbul", "country": "178", "phone": "+9055555555", "topic_of_request": "HR", "comment": "I want to contact to HR department", "notification_email": "test@outlook.com", "contact_form": "Contact Form"}
And also after we complete the iflow design and deploy it. We need to put a runtime endpoint here to be able to trigger the iflow. And of course the basic authentication details.
Steps to do before designing the iflow:
1. Outlook(my preferred Email Service Provider) connection to Integration Suite will be needed. A test Outlook account will be used for testing purposes. Later on, you can use your real email inbox.
OUTLOOK SMTP: smtp.office365.com
Port: 587
Proxy Type: Internet
Protection: STARTTLS
2. Integration Suite’s “Test Connectivity” Functionality can be used to validate the certificates for Outlook. Later on, these certificates will be added to
Manage Security -->Keystore in the Integration Suite. Screenshot below:
3. Click add --> Certificate. And then upload the certificates that you have downloaded from the Connectivity Test.
4. Let's say we have an Outlook inbox with an email inbox like "test@outlook.com" and a password. We need to define this password in Manage Security --> Security Material of Integration Suite as we did something similar for the certificates. The "Name" field that we gave is important because later on we will use this name to assign this credential to our iflow. Please take note of it.
General Overview of Our Iflow Design:
Here basically we trigger the iflow with a POST call via an Emarsys Webhook with the payload that we want to use in the email content.
On the second content modifier, we have saved our fields from the Emarsys payload so that we can use them in our email content. We can call them later as Camel Expression. For example, ${property.iv_notification_email} is basically the email address that we send the email notification to. You can check this blog for the details of the Camel Simple Expression Language:
https://blogs.sap.com/2016/11/25/get-to-know-camels-simple-expression-language-in-hci/
Configuring the mail adapter settings:
1. On the credentials name, we will use the credentials that we have set up for our Outlook email inbox. The other email settings are the ones that I shared above while we were getting the Outlook certificate.
2. Here we structure how our email will look like. We can even use complex HTML designs and structures and I will go simple for this example as our only purpose is to send departmental notification emails. So, text content would be fine.
As you can see from the screenshot, we use our Camel Simple Expression Language. ${property.iv_notification_email}, This is basically the email address we will send notification emails to. And as you have remembered, we have saved this to properties in the second content modifier.
So basically an email structure would be set up like the below:
I did it in the same structure as Emarsys Forms notifications:
A contact registered through the following form:
${property.iv_contact_form}
The following data provided by the contact:
Salutation: ${property.iv_salutation}
First Name: ${property.iv_first_name}
Last Name: ${property.iv_last_name}
Email: ${property.iv_email}
Company: ${property.iv_company}
Department: ${property.iv_your_department}
Web Site: ${property.iv_website}
ZIP Code: ${property.iv_zipcode}
Street: ${property.iv_street}
House Number: ${property.iv_house_number}
City: ${property.iv_city}
Country: ${property.iv_country}
Phone: ${property.iv_phone}
Which topic is your request about?: ${property.iv_topic_of_request}
Comment or Request: ${property.iv_comment}
Eventually, an email will look like this:
CONCLUSION
I have tried to explain as much detailed as possible. But certainly, there might be some steps that I have probably missed so you can ask me about them. I would be glad to answer them all. In our scenario, I have tried to answer a simple business use case and this business use case can be improved and extended. So, with logic, in an automation program, we can now send notification emails according to the contact's choices to different email inboxes. This is important for many companies and this can be achieved with simple iflow design and configuration.
Special thanks to Onur Yurt for helping out with the design of the iflow.