-
Notifications
You must be signed in to change notification settings - Fork 4
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
- 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')
- Let the class implement interface
IAutomationCondition
- Let the class implement the mandatory member
IsConditionMetAsync
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
To better get a sense of how Actions
look are here links to the various real-time implementations for inspiration:
- Source Code: AddChecklistToCardAction
- Source Code: AddChecklistToCardIfLabelMatchAction
- Source Code: AddCommentToCardAction
- Source Code: AddCoverOnCardAction
- Source Code: AddLabelsToCardAction
- Source Code: AddMembersToCardAction
- Source Code: AddStickerToCardAction
- Source Code: RemoveCardDataAction
- Source Code: RemoveChecklistFromCardAction
- Source Code: RemoveCoverFromCardAction
- Source Code: RemoveLabelsFromCardAction
- Source Code: RemoveMembersFromCardAction
- Source Code: RemoveStickerFromCardAction
- Source Code: SetFieldsOnCardAction
- Source Code: StopProcessingFurtherAction
If you are looking for info on a specific method in TrelloDotNet then expand the Pages above and input the 'MethodName' (Example: 'AddCardAsync')