アクティビティの種類を作成する

Version:
日本語翻訳に関する免責事項

このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。

このトピックでは、SymposiumReminderという名前のカスタムマーケティングオートメーションアクティビティタイプを作成および設定する方法について説明します。 SymposiumReminderは、マーケティング電子メールの受信をオプトアウトしたかどうかに応じて、連絡先を「真」または「偽」の パス に沿って移動する責任があります。

大事な

アクティビティの種類では、1つの既定のパスまたはtrue/falseパスを定義する必要があります。追加のカスタムパスを定義することはできません。

メモ

アクティビティ・タイプでカスタム・ファセットを使用する場合は、モデルを自動化エンジン にデプロイ する必要があります。

SymposiumReminderアクティビティタイプには、次のものも含まれます。

  • 外部サービスを使用して、役職に基づいて連絡先の役割を決定します。

  • 外部サービスを使用して、連絡先の優先電子メール アドレスに電子メールを送信します。「from」メールアドレスは、NoReplyAddressパラメータで設定できます。

IActivityを実装するクラスを作成します

カスタムSymposiumReminderアクティビティと2つのカスタムサービスを実装するには:

  1. IActivityを実装するSymposiumReminderという名前のクラスを作成します。

    using System;
    using Sitecore.XConnect.Collection.Model;
    using Sitecore.Xdb.MarketingAutomation.Core.Processing.Plan;
    using Sitecore.Framework.Conditions;
    using System.Collections.Generic;
    using Documentation.Examples.Services;
    using Sitecore.Xdb.MarketingAutomation.Core.Activity;
    
    namespace Documentation.Examples
    {
        public class SymposiumReminder : IActivity
        {
            // Parameters
            public string NoReplyAddress { get; set; }
    
            public IJobService JobService { get; set; }
    
            public IEmailService EmailService { get; set; }
    
            public IActivityServices Services { get; set; }
    
            // Custom service
    
            public SymposiumReminder(IJobService jobService, IEmailService emailService)
            {
                EmailService = emailService;
                JobService = jobService;
            }
    
            public ActivityResult Invoke(IContactProcessingContext context)
            {
                Condition.Requires(context.Contact).IsNotNull();
                string preferredMail = String.Empty;
    
                if (context.Contact.Emails() != null && !context.Contact.ConsentInformation().DoNotMarket)
                {
                    preferredMail = context.Contact.Emails().PreferredEmail.SmtpAddress;
    
                    string subject = "Join us at Symposium!";
    
                    // Change e-mail subject depending on job title
                    if (context.Contact.Personal() != null)
                    {
                        if (JobService.IsJobInCategory(context.Contact.Personal().JobTitle, JobService.DeveloperCategory))
                        {
                            subject = "Geek out with us at Symposium!";
                        }
                        else if (JobService.IsJobInCategory(context.Contact.Personal().JobTitle, JobService.ExecutiveCategory))
                        {
                            subject = "Magnify your marketing with Sitecore Experience Cloud";
                        }
                    }
    
                    EmailService.SendMail(preferredMail, NoReplyAddress, subject);
    
                    // Move to "true" path
                    return new SuccessMove("true");
                }
    
                // Move to "false" path
                return new SuccessMove("false");
            }
        }
    }
  2. SymposiumReminderアクティビティタイプが依存するカスタムサービス(IJobServiceおよびIEmailService)を作成します。アクティビティの種類がカスタムサービスに依存していない場合は、この手順をスキップできます。

    using System.Collections.Generic;
    
    namespace Documentation.Examples.Services
    {
        public interface IEmailService
        {
            void SendMail(string to, string from, string subject);
        }
    
        public class EmailService : IEmailService
        {
            public void SendMail(string to, string from, string subject)
            {
                // E-mail sending logic here
            }
        }
    
        public interface IJobService
        {
            string DeveloperCategory { get; }
            string MarketerCategory { get; }
            string ExecutiveCategory { get; }
    
            bool IsJobInCategory(string job, string category);
        }
    
        public class JobService : IJobService
        {
            public string DeveloperCategory { get { return "developer"; } }
            public string MarketerCategory { get { return "marketer"; } }
            public string ExecutiveCategory { get { return "executive"; } }
    
            private List<string> DeveloperJobTitles { get; set; }
            private List<string> MarketerJobTitles { get; set; }
            private List<string> ExecutiveJobTitles { get; set; }
    
            public JobService()
            {
                DeveloperJobTitles = new List<string>()
                    {
                        "developer",
                        "software developer",
                        "software engineer"
                    };
    
                MarketerJobTitles = new List<string>()
                    {
                        "marketer",
                        "digital strategist",
                        "marketing manager"
                    };
    
                ExecutiveJobTitles = new List<string>()
                    {
                        "ceo",
                        "coo",
                        "cdo"
                    };
            }
    
            public bool IsJobInCategory(string job, string category)
            {
                if (category == DeveloperCategory)
                {
                    return DeveloperJobTitles.Contains(job.ToLowerInvariant());
                }
    
                if (category == MarketerCategory)
                {
                    return MarketerJobTitles.Contains(job.ToLowerInvariant());
                }
    
                if (category == ExecutiveCategory)
                {
                    return ExecutiveJobTitles.Contains(job.ToLowerInvariant());
                }
    
                return false;
            }
        }
    }

シンポジウムリマインダーパス

このSymposiumReminderでは、次の2つのパスが定義されています。

  • true

  • false

各パスには、Sitecoreのアクティビティ タイプの記述子に一致するパス アイテムがあります。関連項目:

シンポジウムリマインダーサービス

このSymposiumReminderは、次の2つのカスタム サービスに依存しています。

  • IJobService連絡先の役職をリスト内のエントリと照合する責任があります。

  • IEmailServiceは、電子メールの送信を担当します - たとえば、ブランドがEmail Experience Managerを使用していない場合など。

どちらのサービスもコンストラクターを介して挿入され、Automation Engineのアクティビティ タイプの構成の一部である必要があります。関連項目:

SymposiumReminderパラメータ

このSymposiumReminderでは、1つのカスタムパラメータが定義されています。

  • NoReplyAddress

このパラメーターには、アクティビティ タイプの記述子に一致するパラメーター項目があり、SymposiumReminderタイプを使用するアクティビティがプランに追加されるときに、Automation Plan Defintion Managerによって設定されます。関連項目:

シンポジウムリマインダー結果

SymposiumReminderは、連絡先がマーケティング電子メールの受信をオプトアウトしたかどうかに応じて、SuccessMove("true")またはSuccessMove("false")を返します。

関連項目:

Sitecoreでアクティビティ記述子を作成する

Sitecoreでアクティビティ記述子は、アクティビティ タイプごとに作成する必要があります。アクティビティ記述子は、マーケティングオートメーションUIで使用され、アクティビティタイプ記述子ロケーター APIを使用してアクセスされます。

  1. コンテンツ エディタを開き、/sitecore/system/Settings/Analytics/Marketing Automation/Activity Typesに移動します。

  2. Activity Types項目を右クリックし、アクティビティの種類>挿入します。

  3. 新しいアクティビティタイプに、アクティビティタイプクラスに対応する名前を付けます (例: Symposium Reminder

  4. Implementation Typeを指定します (このフィールドの値は、自動化エンジン構成のimplementationTypeパラメーターの値と一致する必要があります)。

  5. Parameters サブアイテムを右クリックし、No Reply Addressという名前のパラメータアイテムを挿入します。この場合、パラメータはデフォルトにフォールバックし、必須ではありません。

  6. Paths サブアイテムを右クリックし、2つのパスアイテムを挿入します。各パス項目は、アクティビティタイプで使用されるものと同じKey を定義する必要があります。

マーケティングオートメーションエンジンへのアクティビティタイプの追加

アクティビティは、マーケティングオートメーションエンジンの設定に登録する必要があります。

  1. Automation Engineルートの次のフォルダーに移動します。 \App_Data\Config\sitecore\MarketingAutomation

    先端

    ローカルインスタンスでは、Automation Engineは C:\path\to\xconnect\App_data\jobs\continuous\AutomationEngine

  2. sc.MarketingAutomation.ActivityTypes.xmlを拡張し、カスタムアクティビティを登録する新しいXMLファイルを作成します。

    <Settings>
      <Sitecore>
        <XConnect>
            <Services>
                <MarketingAutomation.Activity.SymposiumReminder>
                    <Type>Sitecore.Xdb.MarketingAutomation.Locator.ActivityTypeRegistration, Sitecore.Xdb.MarketingAutomation</Type>
                    <LifeTime>Singleton</LifeTime>
                    <Options>
                        <Id>{A21EA3B7-6CE4-4C5D-AFE4-50F2D0ECE197}</Id>
                        <ImplementationType>Documentation.Examples.SymposiumReminder, Documentation.Examples</ImplementationType>
                    </Options>
                </MarketingAutomation.Activity.SymposiumReminder>
            </Services>
        </XConnect>
        </Sitecore>
    </Settings>
    手記

    Idノードは、Sitecoreのアクティビティ記述子アイテムのIDです。

  3. アクティビティDLL(この場合はDocumentation.Examples.dll)をMarketing Automation Engineルートにデプロイします。

アクティビティタイプサービスをマーケティングオートメーションエンジンに追加する

SymposiumReminderアクティビティは、2つの外部サービスに依存しています。これらのサービスは、自動化エンジンに登録する必要があります。

  1. Automation Engineルートの次のフォルダーに移動します。 \App_Data\Config\sitecore\MarketingAutomation

    先端

    ローカル インスタンスでは、Automation EngineはC:\path\to\xconnect\App_data\jobs\continuous\AutomationEngineの下にあります

  2. sc.MarketingAutomation.ActivityServices.xmlを拡張し、カスタムサービスを登録する新しいXMLファイルを作成します。カスタムサービスを使用していない場合は、この手順をスキップできます。

    <Settings>
    <!--
        Marketing Automation Activity Services configuration
    -->
    <Sitecore>
        <XConnect>
        <MarketingAutomation>
            <Engine>
            <Services>
                <Documentation.EmailService>
                    <Type>Documentation.Examples.IEmailService, Documentation.Examples</Type>
                    <As>Documentation.Examples.EmailService, Documentation.Examples</As>
                    <LifeTime>Singleton</LifeTime>
                </Documentation.EmailService>
                <Documentation.JobService>
                    <Type>Documentation.Examples.IJobService, Documentation.Examples</Type>
                    <As>Documentation.Examples.JobService, Documentation.Examples</As>
                    <LifeTime>Singleton</LifeTime>
                </Documentation.JobService>
            </Services>
            </Engine>
        </MarketingAutomation>
        </XConnect>
    </Sitecore>
    </Settings>
    手記

    ノード名は一意である必要があります。たとえば、Documentation.EmailServiceノードは1つだけ存在できます。ノード名はユーザー次第であり、サービスの完全な名前空間である必要はありません。

  3. アクティビティ サービスDLL(この場合はDocumentation.Examples.dll)をMarketing Automation Engineルートにデプロイします。

ファセットが読み込まれていることを確認する

次のファセットは、コンタクトがアクティビティ内で評価されるときに使用可能である必要があります。ファセットキーをC:\path\to\xconnect\App_data\jobs\continuous\AutomationEngine\App_Data\Config\sitecore\MarketingAutomation\sc.MarketingAutomation.ContactLoader.xml設定ファイルIncludeFacetNamesセクションにパッチします。  

<Settings>
<!--
    Marketing Automation contact loader configuration
-->
<Sitecore>
    <XConnect>
    <MarketingAutomation>
        <Engine>
        <Services>
            <!-- Include or exclude contact facets for the contact during loading -->
            <!--
            <MarketingAutomation.Loading.ContactFacetsConfigurator>
            <Options>
                <IncludeFacetNames>
                <Facet1>PersonalInformation</Facet1>
                <Facet2>EmailAddressList</Facet2>
                <Facet3>ConsentInformation</Facet3>
                </IncludeFacetNames>
            </Options>
            </MarketingAutomation.Loading.ContactFacetsConfigurator>
            -->
        </Services>
        </Engine>
    </MarketingAutomation>
    </XConnect>
</Sitecore>
</Settings>
この記事を改善するための提案がある場合は、 お知らせください!