To replace or customize an activity flow:
In a Visual Studio project, create and build a new activity flow.
Add existing or new activities to it.
Classes in this topic are available in the following namespaces:
Mediachase.Commerce.Workflow. Contains the workflows.
Mediachase.Commerce.Workflow.Activities.Cart. Contains the activities.
Configure the activity flows in a .CS file (the config file _\\Configs\\ecf.workflow.config_ is no longer needed).
An activity flow should inherit from the ActivityFlow class. You can decorate it with an ActivityFlowConfiguration attribute.
Each activity flow should have a unique name. If the Name parameter is not provided, the engine gets the ActivityFlow class name. In this example, Name is _ExampleActivityFlow_. The activity flow name is used to look up and execute.
**Example: ExecutionManager.ExecuteActivityFlow(workflowName, parameters)**
An activity flow should implement a Configure method to declare which activities are executed, and how they are executed. You can configure an activity flow to override another flow of the same name and mode by setting a higher priority. The default priority is zero (0). For example, you configure two flows with the same name and all in beta mode:
When the activity flow "**Example**" is called in beta mode, it creates an instance of AlphaExampleActivityFlow class, not BetaExampleActivityFlow. This means that only the AlphaExampleActivityFlow is registered for the "Example" activity flow.
You can register a workflow without the ActivityFlowConfiguration attribute. If a workflow is inherited from the ActivityFlow class and not decorated by the attribute, it is still registered with same name as the name of class.
## Create an activity to send notifications
The following example creates a new workflow activity, then uses it in a new workflow. It uses this workflow to replace the shipped CartCheckout workflow. The new activity sends an automated email to store customers after an order completion. This example illustrates how to update and customize a flow.
### Create an activity
Create a Workflow Activity Library project in Visual Studio. In this example, we named the project CustomActivityLibrary1.
Add a new activity to the activities project for the email. Name the activity SendNotification.
Set the inheritance for the activity to Mediachase.Commerce.WorkflowCompatibility.Activity.
Make sure you installed the _EPiServer.Commerce.Core_ NuGet package.
Add the code to the new activity's code-behind file (_SendNotification.cs_) from the Code Sample section in this document. Ensure the naming is correct, that you create the stub of the method to send the email, and that your method is called in the activity's Execute method. A stub for the method is provided in the SendEmailNotification() method. See the SendEmails method code in the _/Templates/Everything/BusinessControls/CheckoutControls/CheckoutWizardModule.cs_ file.
Use the activity OrderGroup object reference to retrieve the information about the order to be put in the email. To generate the formatted copy of the email body text with the order information, use the Mediachase.Commerce.Engine.Template.TemplateService. See sending [Order notifications](🔗) for information about the template service.
Build the project.
### Add activity to activity flow
Add the activity created above (along with other activities contained in the _Mediachase.Commerce.Workflow.dll_) to a new activity flow. Use this activity flow to replace the CartCheckoutActivityFlow (Mediachase.Commerce.Workflow.CartCheckoutActivityFlow).
Create a Activity Flow project in Visual Studio. In this example, name the project MyCustomCartCheckout.
Make sure you installed _EPiServer.Commerce.Core_ NuGet package.
Add a class to the customCartCheckout project. In this example, name it CustomCartCheckout. Set the inheritance for the activity flow to Mediachase.Commerce.Engine.ActivityFlow. And decorate the class with ActivityFlowConfiguration attribute. By setting the Name as CartCheckout, you override the default implementation of Mediachase.Commerce.Workflow.CartCheckoutActivityFlow.
In the activity flow file (in this example named CustomCartCheckout.cs), implement the Configure method to configure the list of activities to be executed, and add the last step to use the SendNotification activity. See the relevant code in the code sample section in this document.
Build the project.
Locate the newly-built assembly and copy it to the project's _bin_ folder.
Recompile, and access the website where this activity is used during checkout.
**Example: starting code for the SendNotification activity**