---
title: "Marketing Automation API for Commerce campaigns"
slug: "marketing-automation-api-for-commerce-campaigns"
abstract: "Overview of the Automation Provider and the methods available."
---
# Marketing Automation API for Commerce campaigns

The Automation Provider is generic for all marketing automation campaigns and encompasses the following functionality:

- Creation of a Abandoned Cart marketing automation campaign based on an existing template.
- Creation of a New Order Placed marketing automation campaign based on an existing template.
- Contact enrollment into automation campaigns.
- Contact removal from automation campaigns.

The following class diagram shows the relationship between the `IAutomationProvider` and the `AutomationProvider` and lists the methods they contain.

![AutomationProvider.png](https://doc.sitecore.com/api/markdown-image/xp/en/developers/103/sitecore-experience-commerce/images/AutomationProvider.png)

<details>
<summary><h2>Methods</h2></summary>

The table below lists the methods available for the Automation Provider.

| Method | Description |
| --- | --- |
| `CreateFromTemplate` | Creates a marketing automation campaign based on a template.<br><br>`shopName` represents the name of the storefront the campaign is being created for.` templateName` is the name of the template that is used to create the plan.<br><br>The resulting campaign name is: shopName + “ “ + templateName.<br><br>> [!important]<br>> For Commerce marketing automation campaigns, you must adhere to the naming convention shopName + “ “ + templateName.<br><br>`Activates` indicates if the campaign is to be activated immediately after its creation.  The marketing automation campaign is activated by default. |
| `EnrollCurrentContact` | Enrolls the current contact into the plan.<br><br>`shopName` and `basePlanName` are concatenated to form the name of the plan to be retrieved via the `IAutomationPlanProvider`.<br><br>`customValues` represent values that are stored along with the contact in the automation campaign.<br><br>This method is called, for example, whenever a contact interacts with the cart on the shopping site to enroll them into Commerce marketing automation campaigns. |
| `RemoveContactFromPlan` | Removes the contact from the current plan. For example, when the shopping cart is submitted and turned into an order, this method is called to remove the contact from the abandoned cart campaign. |
| `RemoveCurrentContactFromPlan` | Removes the current contact from the given plan. |

The default implementation is dynamically loaded based on the following configuration.

```xml
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>

    <automationProvider type="Sitecore.Commerce.MarketingAutomation.Providers.AutomationProvider, Sitecore.Commerce.Connect.MarketingAutomation" singleInstance="true"/>

  </sitecore>
</configuration>

```

To extend the current implementation, you can implement the `IAutomationProvider` interface and change the above configuration.

</details>

<details>
<summary><h2>Automation Plan Provider</h2></summary>

The Automation Plan Provider is responsible for returning the plan for the current storefront:

![AutomationPlanProviderClassDiagram.png](https://doc.sitecore.com/api/markdown-image/xp/en/developers/103/sitecore-experience-commerce/images/AutomationPlanProviderClassDiagram.png)

The following table details the methods available.

| Method | Description |
| --- | --- |
| `GetPlan` | Returns the automation plan based on the given `shopName` and `basePlanName`. The default implementation simply concatenates `shopName` and `basePlanName` and returns the plan matching that name.  If none is found, null is returned. |

The default implementation is dynamically loaded based on the following configuration.

```xml
Sitecore.Commerce.MarketingAutomation.config
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>

    <automationPlanProvider type="Sitecore.Commerce.MarketingAutomation.Providers.AutomationPlanProvider, Sitecore.Commerce.Connect.MarketingAutomation" singleInstance="true"/>

  </sitecore>
</configuration>

```

To extend the current implementation, you can implement the `IAutomationPlanProvider` interface and change the above configuration.

</details>

<details>
<summary><h2>Automation Plan Custom Value Providers</h2></summary>

These Custom Value providers deliver additional information that is part of the campaign state when enrolled into a plan.  Currently, a version for Cart and Orders are available. These are the values passed into the `customValues` of the `EnrollCurrentContact` method of the `IAutomationProvider` interface.

![CustomValueProvidersClassDiagram.png](https://doc.sitecore.com/api/markdown-image/xp/en/developers/103/sitecore-experience-commerce/images/CustomValueProvidersClassDiagram.png)

The following table lists the methods available.

| Method | Description |
| --- | --- |
| `GetCustomValues` | The arguments of the called pipeline are passed as an input parameter to the method. For carts, by default, the following information is returned:<br><br><ul><li>External Id</li><li>Shop name</li><li>Serialized cart</li></ul><br><br>For orders, by default, the following information is returned:<br><br><ul><li>Order Id</li><li>External Id</li></ul><br><br>The **Send Commerce Email** marketing automation campaign activity uses the custom values to pass information to the email rendering so that the rendering can extract cart information to be part of the marketing automation campaign email.<br><br>> [!important]<br>> For Commerce marketing automation campaigns, do not use the Send Email action. |

</details>