Customers with Marketing Cloud can use the Transaction Messaging API to send email, and this new SendEmailViaMC Flow Action enables Marketing Cloud customers to craft personalized content with flows before sending to email templates. This leverages the richness of Marketing Cloud email templates while providing a no-code way to do personalization.
In our demonstration here, we also add Salesforce CDP into the mix, and show how personalized emails can be generated that meld:
- Data from CDP profiles
- Data from web callouts driven by Apex invocable actions
- Data from core CRM records
Flow enables a lot of interesting combinations. In this demo, a Flow action calls out to a weather API and uses the results to recommend warm clothing in some email but not others. Flow also examines the salutation field of the CDP profiles and uses flow decision logic to decide which of several Marketing Cloud email templates to use.
Here’s the Flow that forms the core of the messaging personalization:
Two new invocable actions are available for installation as an unmanaged package.
SendEmailViaMC Flow Action
|token||This authorization token is generated by Marketing Cloud. See ‘Authorization’ below.|
|toRecipient||an email address. Multiple recipients aren’t supported in this initial release.|
|contactKey||Unique identifier for a subscriber in Marketing Cloud. If you don’t provide an existing subscriber key , one will be generated at send time by using the recipient’s email address.|
|definitionKey||The name of a Marketing Cloud email template (see Templates, below)|
|mergeKeys and mergeValues||These provide a way to pass up to 5 distinct merge values. If the email template specified in definitionKey has a merge variables that corresponds to a merge key, the corresponding value will be inserted into the email.|
In the screen shot above, a specific token is pasted into the Send Email action. However, Marketing Cloud tokens only last 20 minutes, so this is not a deployable solution. Fortunately, it’s easy to generate tokens using the GenerateMarketingCloudToken Flow Action, also available in this package.
To generate tokens, follow the guidance here and generate a specific API Integration:
The token generation action requires the Client Id and Client Secret that you generate, along with the Authentication Base URI, which is custom to your MC instance. It also will require your accountId:
You can place this action immediately before your send to efficiently refresh your token on an as-needed basis:
Merging Flow Values into Marketing Cloud Templates
Marketing Cloud users will be familiar with MC templates, which look like this:
The template shown here demonstrates simple string templates but also shows a merge field that interprets the incoming string as HTML.
If you go back to the example configuration of the SendEmailUsingMC, notice that mergeKey1 is ‘FirstName’. That matches the %%FirstName%% in the template above, so when the email is sent, Marketing Cloud will merge in the value of mergeValue1. In this case, that’s a record lookup. In the video, you’ll see that the record comes from a CDP profile, but it could also come from a CRM record.
The customized weather makes use of Flow’s own Text Template resource. Here’s the one that’s used in the sample flow:
Flow uses the Assignment element to conditionally populate WeatherWarning.