Skip to content

Custom Automation Actions

Rasmus Wulff Jensen edited this page Aug 20, 2023 · 3 revisions

The Automation Engine has various out-of-the box Actions, but there can be cases where you wish to make your own custom Actions

If you think the Action you need so be an out-of-the-box Action feel free to open an issue or create a Pull Request with your custom Action

Steps to make a custom Action

  1. Make a new C# class and Call it 'MyCustomCondition' (or what you like it to be called but it is recommended to suffix it 'Condition')
  2. Let the class implement interface IAutomationCondition
  3. Let the class implement the mandatory member IsConditionMetAsync

Basic Example

public class MyCustomAction : IAutomationAction
{
    public Task PerformActionAsync(WebhookAction webhookAction, ProcessingResult processingResult)
    {
        //Your Logic if the Action goes here

        TrelloClient trelloClient = webhookAction.TrelloClient; //You have full access to the TrelloClient

        WebhookActionData webhookActionData = webhookAction.Data; //This object has data about the event so you example can get the CardId of the Card for the event

        //The 'processingResult' instance can be used to communicate back what happened and if the action was executed or skipped + Any log messages back
        bool doneSomeWork = true;
        if (doneSomeWork)
        {
            processingResult.Log.Add(new ProcessingResultLogEntry("We did stuff"));
            processingResult.ActionsExecuted++;
        }
        else
        {
            processingResult.Log.Add(new ProcessingResultLogEntry("We skipped stuff (because xyz)"));
            processingResult.ActionsSkipped++;
        }
    }
}

Inside the PerformActionAsync you have access to the WebhookAction (aka the JSON given by the Webhook) + The TrelloClient for further data lookups and manipulation if needed

Real Examples

To better get a sense of how Actions look are here links to the various real-time implementations for inspiration:

Clone this wiki locally