How to Use Workflows to Send Emails When Content is Created, Deleted, Published, Updated etc...

How to Use Workflows to Send Emails When Content is Created, Deleted, Published, Updated etc...

Workflows can be used to send out emails whenever content is updated created, deleted, published, or updated. This is very useful when you want to notify Admins or Managers of new content being added to the CMS.

Building the Workflow

Create a new workflow and name it something descriptive, and have it set to enabled.

Click Add Event and select the Content filter on the left. From here you can choose from any of the options you want to key off. In this example we will do Content Created, but any of the options with lightning bolt icons on them work with the next steps.

Choose one or more Content Type you want this Workflow to kick off from. In this example we are only choosing FAQ Item, but you can do any number of Content Types to key off of.

After creating the event, click on it and select** Startup task**. This will indicate it is the first event to run in the Workflow.

Click Add a Task, and select the Content filter on the left. From here Add Retrieve Content.

Give this task a title and then add "correlationId()" to the Content Item Id field. If you want more context on what this is and how correlation works in Workflows, you can check out the OrchardCore correlation documentation.

Connect the initial node over to the new task we just created.

Add another task and choose the Send Email option

Build out the Email using the relevant fields. All you need to get a basic email working is Title, Recipients, Subject, Body Plain Text.

We are using Liquid Expressions to get some dynamic metadata into the subject and body, there is documentation here on how it works:

When testing Workflows, if you click on Instances you can see all of the previous runs of the workflow and see the status of it. If you click on the State tab, you can get the Workflow JSON data structure that the Liquid Expressions are referencing

workflow, Content
vgarg