marketing Automation deploying Sitecore How-To

Sitecore 9: Deploying Activity Type to Sitecore UI and Marketing Automation engine

As a result of previous efforts we have the following assets ready for deployment:

  • Demo9.Features.dll - assembly that has activity type backend implementation
  • Sendpromoemail.plugin.js - bundled UI components
  • Activity definition item in Sitecore.

First we need to deploy assembly to Marketing Automation engine by uploading it to
<XConnectRootFolder>\App_data\jobs\continuous\AutomationEngine

Next we need to register our newly created activity type in configuration. We can create an xml patch file.
<XConnectRootFolder>\App_data\jobs\continuous\AutomationEngine\App_Data\Config\sitecore\ MarketingAutomation_patch\sc.MarketingAutomation.ActivityTypes.xml

   
<Settings>
    <!--
    Marketing Automation activity type registrations.
  -->
    <Sitecore>
        <XConnect>
            <Services>
                <MarketingAutomationDemo.Activity.SendPromoEmailActivity>
                    <Type>Sitecore.Xdb.MarketingAutomation.Locator.ActivityTypeRegistration, Sitecore.Xdb.MarketingAutomation</Type>
                    <LifeTime>Singleton</LifeTime>
                    <Options>
                        <Id>{F8B0DFFD-E3D3-4EA2-B3FA-8BFCAA4E41DA}</Id>
                        <ImplementationType>Demo9.Features.MarketingAutomation.Activities.SendPromoEmailActivity, Demo9.Features</ImplementationType>
                    </Options>
                </MarketingAutomationDemo.Activity.SendPromoEmailActivity>
            </Services>
        </XConnect>
    </Sitecore>
</Settings>
 

Make sure you set ID to the item ID of the action type definition. Note that node name like
MarketingAutomationDemo.Activity.SendPromoEmailActivity is up to you but make sure it is unique across all activity definitions.

Next, we need to deploy and register our UI bundle with Marketing Automation UI.

First upload Sendpromoemail.plugin.js to the following folder:
<sitecoreroot>\sitecore\shell\client\Applications\MarketingAutomation\plugins
As suggested by documentation we need to create the following patch file to register plugin within Sitecore.
<sitecoreroot>\App_Config\Include\MarketingAutomation\Demo9.Plugin.config

   
<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
    <sitecore role:require="Standalone or ContentManagement">
        <marketingAutomation>
            <pluginDescriptorsRepository>
                <plugins>
        <demo9 path="./plugins/sendpromoemail.plugin.js"/>
                </plugins>
            </pluginDescriptorsRepository>
        </marketingAutomation>
    </sitecore>
</configuration>
 

All good, now it's time to test.

Navigate to Marketing Automation Editor. Sitecore will try to load custom plugin with SystemJS and will most likely fail in the default setup with the following error:

marketing Automation

In the console you can find the following error:

   
main.26a730503150bac385ab.bundle.js:1 Error: Unexpected token <
  Evaluating http://demo9.brimit.com/sitecore/shell/client/Applications/MarketingAutomation/plugins/sendpromoemail.plugin.js
  Loading ./plugins/sendpromoemail.plugin.js
    at eval (<anonymous>)
  

You can quickly figure out that SystemJS tried to load script and was redirected to Sitecore login page. There are no cookies supplied by SystemJS, and so request to load plugin does not pass forms authentication enabled for Sitecore folders. As a workaround, we can grant access to /plugins folder by adding the following configuration to web.config

   
   <location path="sitecore/shell/client/Applications/MarketingAutomation/plugins">
    <system.web>
      <authorization>
        <allow users="*"/> <!--this will allow access to everyone-->
      </authorization>
    </system.web>
  </location>
 

If everything was done correct, you will find your custom action in Plan Editor Toolbox under Marketing actions.

marketing Automation

You can drag and drop it to the plan editor and click on the action to make sure editor loads fine. Remember we created very basic read only editor that only shows a label.

marketing Automation

In the next post, I will create a more advanced activity type with parameters and multiple paths. I will also make use of activity services and Interaction data in the backend implementation.

You can find full source code on GitHub

Fly high with Sitecore 9.