The first step to create an interaction in Distributed Marketing is to configure an external integration component. Your component works with Distributed Marketing as follows.
- When the personalization window is loaded, Distributed Marketing calls an interface method on the integration component with the list of selected members.
- Standard Distributed Marketing users interact with the external integration component as you define. For example, select a value from a pick list populated with available alternate email addresses.
- The external integration component can fire an event anytime with custom data for individual campaign members. To set custom data for multiple members, multiple events can fire.
Your custom component must be flagged as global and implement the mcdm_15:MessagePersonalizationHandler
interface.
To use this interface, create an Aura.Action
attribute named personalizationReadyHandler with a default
method to capture the list of selected members when the personalization window
loads. Each selected member object contains properties such as the campaign member’s
name and ID. Your component can use these properties to further customize your user
experience.
<aura:component access="GLOBAL" implements="mcdm_15:MessagePersonalizationHandler">
<aura:attribute
access="GLOBAL"
name="personalizationReadyHandler"
type="Aura.Action"
default="{!c.messagePersonalizationReady}"
/>
Hello, world!
</aura:component>
This example controller method accepts the list of selected pending campaign members
and sets custom data for each member by firing an mcdm_15:JourneyApprovalsDataProvided event for each one. Each approved
member’s record in the associated journey’s event data extension receives the value
bar for the custom field foo.
({
//Handler for action personalizationReadyHandler to receive member data
messagePersonalizationReady: function(component, data) {
// Get array of members (JourneyApproval objects)
var members = data.getParam('arguments').members;
// Loop through each member
members.forEach(function(member) {
// Get, configure and Fire an event (e.mcdm_15:JourneyApprovalsDataProvided)
// with updated custom data for each member.
$A.get('e.mcdm_15:JourneyApprovalsDataProvided')
.setParams({
id: member.campaignMemberId,
data: {
'foo' : 'bar'
}
})
.fire();
});
}
})
This outline includes the shape of each selected member object, called a JourneyApproval object. You can reference this data within your external integration component.
JourneyApproval: {
/**
* The ID of the Marketing Cloud Engagement Journey.
*
* @type {String}
*/
externalJourneyId,
/**
* The Salesforce ID of the associated Contact or Lead object.
*
* @type {String}
*/
objectId,
/**
* The type of Campaign Member object, e.g. Lead or Contact.
*
* @type {String}
*/
objectType,
/**
* The Salesforce ID of the associated Campaign.
*
* @type {String}
*/
campaignId,
/**
* The Salesforce ID of the associated Campaign Member
*
* @type {String}
*/
campaignMemberId,
/**
* The first name of the associated Campaign Member.
*
* @type {String}
*/
firstName,
/**
* The last name of the associated Campaign Member.
*
* @type {String}
*/
lastName,
/**
* Maps messages to personalization values via their ID's.
*
* e.g., introduction and closing values for the message
* with ID 'abc' can be accessed on a JourneyApproval object
* using the following syntax:
* journeyApproval.messages['abc'].introduction
* journeyApproval.messages['abc'].closing
*
* @type {Object}
*/
messages,
/**
* The currently selected greeting option.
*
* This object contains the following properties:
* greeting.label - The UI display text
* greeting.value - The greeting payload
*
* @type {Object}
*/
greeting,
/**
* A map of key value pairs set by a registered
* plugin component
*
* @type {Object}
*/
customData,
/**
* The current status (Pending, Rejected, Failed) of
* the associated Campaign Member.
*
* @type {String}
*/
status
}