Develop > Presentation layer > Customize marketing > Marketing customization: Management Center > Customizing triggers, targets, and actions > Add a new trigger, target or action > Create the campaign element task command


Example: campaign element task command for a trigger (customer event type)

When creating a custom trigger for a marketing activity, you can refer to this sample when developing the trigger's task command.

To understand what a customer event trigger is, see Types of Dialog activity triggers and when they are processed.


Sample

Here is the task command implementation code for an example trigger. In this example, there is an external system that detects credit fraud. The external system can detect credit card fraud, or credit account fraud. The external system will send a message to the marketing services that one of these occurrences of fraud has occurred for a customer. Using this customized trigger, a Marketing Manager would be able to create a Dialog activity to specify how to follow up with the customer in this situation (for example, send a mobile text message or an e-mail depending on their level of coverage, and then send a follow up message after a certain period of time). The eventType parameter can be one of (CreditCard, CreditAccount) to allow different handling depending on the type of fraud that has occurred.

This task command example defines the validateParameters method to validate the trigger parameters and return any errors.

package com.mycompany.commerce.marketing.commands.elements; 
import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.logging.Logger; 
import com.ibm.commerce.foundation.common.exception.ApplicationError; import com.ibm.commerce.foundation.common.util.logging.LoggingHelper; import com.ibm.commerce.marketing.commands.elements.MarketingCampaignElementTaskCmdImpl; import com.mycompany.commerce.marketing.logging.CustomMarketingMessageKeys; 
public class CustomFraudDetectedTriggerTaskCmdImpl 
extends MarketingCampaignElementTaskCmdImpl 
implements CustomFraudDetectedTriggerTaskCmd {

    private final static String PARAM_EVENT_TYPE = "eventType";     private final static String PARAM_CREDIT_CARD = "CreditCard";     private final static String PARAM_CREDIT_ACCOUNT = "CreditAccount"; 
    private static final Logger LOGGER = LoggingHelper.getLogger(CustomFraudDetectedTriggerTaskCmdImpl.class);     private final static String CLASSNAME = CustomFraudDetectedTriggerTaskCmdImpl.class.getName();     
    public CustomFraudDetectedTriggerTaskCmdImpl() {}

    public List validateParameters(Map elementParameters) {
        final String METHOD_NAME = "validateParameters";         if (LoggingHelper.isEntryExitTraceEnabled(LOGGER)) {
            LOGGER.entering(CLASSNAME, METHOD_NAME, elementParameters);         }    

        List validationErrors = new ArrayList(); 
        Object eventType = elementParameters.get(PARAM_EVENT_TYPE);         if (eventType == null || eventType.toString().length() == 0) {
            ApplicationError validateError = new ApplicationError(
                    ApplicationError.TYPE_GENERIC_ERROR,                     CustomMarketingMessageKeys._APP_ACTIVITY_FRAUD_EVENT_TYPE_IS_MISSING,                     null, LOGGER.getResourceBundleName());             validationErrors.add(validateError); 
        } else {
            if (PARAM_CREDIT_CARD.equals(eventType.toString()) == false &&                     PARAM_CREDIT_ACCOUNT.equals(eventType.toString()) == false) {
                ApplicationError validateError = new ApplicationError(
                        ApplicationError.TYPE_GENERIC_ERROR,                         CustomMarketingMessageKeys._APP_ACTIVITY_FRAUD_EVENT_TYPE_IS_INVALID,                         null, LOGGER.getResourceBundleName());                 validationErrors.add(validateError);             }
        }

        if (LoggingHelper.isEntryExitTraceEnabled(LOGGER)) {
            LOGGER.exiting(CLASSNAME, METHOD_NAME, validationErrors);         }        
        return validationErrors;     }
}


Related concepts

Campaign element task commands

Related reference

Example: campaign element task command for a trigger (daily check type)

Example: campaign element task command for a target

Example: campaign element task command for an action


+

Search Tips   |   Advanced Search