Skip to main content

Notifications

Trigger a Plugin from Custom Trigger

Introduction

There are many blogs and documents available to trigger Power Automate from a journey by raising a custom trigger. In this blog, we walk you through how you can trigger a Plugin to execute your business logic. This will be helpful in scenarios where it requires complex calculations or with high volume to avoid the Power Automate service protection limit.

Scenario Description

In this scenario, Contoso has various systems where they want to sync live journey data for different purposes like customer profiles for Data Warehouse for master data management, ERP for credit verification, and CDP platform to send live journey progress. Contoso’s Marketing team would like to build a journey where they can decide based on the different conditions what type of information they want to send to those systems. This blog will explain a scenario to send customer profile information to the Data Warehouse system.


Contoso has a minimum of 1 M contacts in their Segment based Journey. Therefore, triggering a Power Automate via raising a custom trigger in the Journey will be costly and may hit the service protection limits.

Solution

This solution will trigger the Dataverse Plugin by activating a custom trigger from a journey. The Plugin will post the message to the Azure Service Bus Queue. From the Queue, customers can use any azure integration tool such as logic app, Azure Function or ADF to send information to downstream systems.

In order to build out the solution, we will:

  • Complete preparation tasks
  • Build the automation
  • Build the journey

Preparation Tasks

To prepare to build out the required logic, we first need to:

  1. Create a Service Bus and Queue
  2. Create a new custom trigger to trigger a plugin
  3. Register custom trigger to a plugin

Create Service Bus and Queue

Go to your Azure Admin Portal and Create a Service Bus and Queue by following the steps mentioned here. Once you have Service Bus and Queue ready, you can Register Service Bus into dataverse as a service endpoint. Please refer to this link for step-by-step instructions.

pastedimage1669246889577v1.png

Create a new custom trigger to trigger a plugin

Next, we will create a new Real-Time Marketing trigger that will be called every time a customer journey needs to post the message to the Azure Service Bus. We are making this a generic, reusable component that can be used across multiple journeys. The trigger uses the contact, email and phone number parameters to send it to the downstream system. In my scenario downstream system needs that information to identify the customer and flag them for further communication.

pastedimage1669247371534v2.png

Click “Next” and click on “Go to code snippet”

pastedimage1669247458746v3.png

This will open a new tab and show the code. Copy the Name value and keep it aside for the next step mentioned below.

pastedimage1669247484979v4.png

Register custom trigger action to a plugin

Go back to the Plugin registration tool where you have registered your Azure Service Buse queue endpoint. Under that, click on Register New Step and paste the custom trigger name you have copied in the above step into the “Message” text box.

pastedimage1669247576053v5.png

You can write any custom plug-in which you can use to register your custom trigger as a Step. Below is an example where I have my own custom plugin where I can see my custom trigger as a message to register as a step. Once this is done, whenever you have a step in your journey that will activate the custom trigger will trigger this plugin code.

pastedimage1669247613189v6.png

Building the automation

Once everything is ready, you can create any journey you would like and add the “Activate a Custom Trigger” Action as per below. This will call the plugin and post the message into the Azure Service Bus Queue.

pastedimage1669247684138v7.png

In the Azure Serv Bus message will arrive, and it will look like the below.

pastedimage1669247722365v8.png

Caveats and Considerations

When going through the above scenario and solutions, the following should also be considered:

  • The above solution assumes that customers will do a Performance Test to ensure they are not overloading Dynamics 365 Async Server. Otherwise, the entire D365 Marketing environment will slow down.
  • We recommend not registering the custom trigger action step as Synchronous Operation.
  • Triggering a Plugin from a custom trigger in a journey will not return anything back. It is the same behavior as Power Automate. The system will fire the action and forget.

Comments