During Litium application startup, the marketing automation addons are registered using the IConnectorInstaller class. In Voyado the implementation is at src\Litium.AddOns.VoyadoConnector\Installer.cs
Setup
The setup classes described in the previous section are added first. They will run during application startup.
public void Install(IAppBuilder appBuilder)
{
appBuilder
.AddConnector(Constants.ConnectorName, (connectorRegistration) =>
{
connectorRegistration
.AddSetup<InstallConsents>()
.AddSetup<InstallStore>()
});
}
Customer sync service
This service will sync Litium customers into Voyado contacts. ContactType in Voyado is "Member".
public void Install(IAppBuilder appBuilder)
{
appBuilder
.AddConnector(Constants.ConnectorName, (connectorRegistration) =>
{
connectorRegistration
.AddCustomerSyncService((customerSyncServiceRegistration) =>
{
customerSyncServiceRegistration
.UseSyncService<CustomerSyncService>()
.AddExceptionHandler<HttpClientExceptionCondition>()
.AddExceptionHandler<HttpRequestExceptionCondition>()
.AddExceptionHandler<MappingExceptionCondition>();
})
});
}
Marketing automation will not automatically trigger events when customers are created or updated. When a user is created, call the following method from your accelerator code to register the customer with Voyado.
//customerSystemId is the systemId of Litium person
IoC.Resolve<MarketingAutomationService>().RegisterUserCreated(customerSystemId);
Order sync service
Voyado needs to be notified when order states are changing. The following information is sent:
- User who created the order.
- Voyado receipt API
- Voyado orders API
The implementation is in the src\Litium.AddOns.VoyadoConnector\SyncServices\OrderSyncService.cs
This service is registered in install.cs, as follows:
.AddOrderSyncService((orderSyncServiceRegistration) =>
{
orderSyncServiceRegistration
.UseSyncService<OrderSyncService>()
.AddExceptionHandler<HttpClientExceptionCondition>()
.AddExceptionHandler<HttpRequestExceptionCondition>()
.AddExceptionHandler<MappingExceptionCondition>();
})
As described in the install section, the order state change needs to be triggered to Litium marketing automation from the accelerator state transitions, \src\Litium.Accelerator\StateTransition\OrderStateBuilder.cs :
//Order Confirmed
var confirmed = new State<OrderCarrier>((short)OrderState.Confirmed, OrderState.Confirmed.ToString(),
(orderCarrier, currentState, token) =>
{
//Order confirmed entry action.
//now the order is confirmed, reduce the stock balances.
OrderUtilities.ReduceStockBalance(ModuleECommerce.Instance.Orders[orderCarrier.ID, token], ModuleECommerce.Instance.AdminToken);
//notify campaigns engine to take order confirmation actions.
ModuleECommerce.Instance.CampaignCalculator.HandleOrderConfirmation(orderCarrier, ModuleECommerce.Instance.AdminToken);
//Send order confirmation email.
IoC.Resolve<IMailService>().SendEmail(new OrderConfirmationEmail(orderCarrier.ID, orderCarrier.CustomerInfo.Address.Email, orderCarrier.WebSiteID), false);
//Marketing automation integration code to execute when an order is confirmed.
IoC.Resolve<MarketingAutomationService>().RegisterOrderStateChanged(orderCarrier.ID);
},
null);
Product feeds
Product feeds are configured from the following code in Installer.cs:
.AddProductFeedService<ProductFeedItem>("Common", "common", (productFeedServiceRegistration) =>
{
productFeedServiceRegistration
.UseConverter<VariantToProductFeedConverter>()
.UseSerializer<ProductFeedSerializer>()
.SetFeedPickupFolder($"{PluginSettings.Instance.Configuration.FeedPickupFolder}")
.SetScheduler(PluginSettings.Instance.Configuration.WebsiteFeeds.DefaultDueTime,
PluginSettings.Instance.Configuration.WebsiteFeeds.DefaultInterval,
PluginSettings.Instance.Configuration.WebsiteFeeds.Enabled)
.SetForceDownload(true);
})
.AddMarketFeedService(_converterFactory);
The common product feed exports all the variants. It uses the Litium.AddOns.MarketingAutomation.ProductFetcher to query the Litium database to get the total list of variants. This fetcher is set by default and is not configured above.
You can add your own fetcher by using, .UseFecther<class that implements IFeedFetcher>()
AddMarketFeedService is the extension method, that adds a feed for each website.
The list of feeds configured can be accessed through:
http://<your domain>/marketingAutomationApi/Voyado/feeds
Note that the above is a web-API endpoint. If the endpoint fails to work, this can be due to version mismatch of underlying assemblies. Add Litium.Web.WebApi.Abstractions to your Litium.Accelerator.Mvc project, and add the necessary assembly redirections. A warning of the mismatch will usually be displayed.