Workflows

Overview

It allows you to create email workflows which can be triggered by different events and execute a sequence of tasks.

https://i.imgur.com/7GHUog5.png

Workflows

A Workflow is initiated by a Trigger and executes a sequence of Tasks in a specified order. The package uses a DataBus to facilitate the transfer of information between tasks, ensuring smooth data handling and process flow.

Workflows Logs

The workflow logs are stored in the database and can be accessed via the WorkflowLogs button in the bottom bar.

https://i.imgur.com/vQdJXcp.png

Triggers

Triggers act as the starting points for workflows, determining how and when a workflow is activated.

Each trigger defines the conditions under which a workflow will be executed.

Note: Additional trigger types will be introduced in future updates.

ObserverTrigger

The Observer Trigger can listen to Eloquent Model Events and will then pass the Model which triggered the Event to the Workflow.

To make it Work, add the WorkflowObservable to your Eloquent Model.

 use WorkflowObservable;

ButtonTrigger

The Button Trigger is able to render a button in your “frontend” and Execute a Workflow based by a click on it. ButtonTrigger also accept an Model which they pass to the Workflow.

You can influence the buttons by adding your own classes or styles directly to each ButtonTrigger. Also you can publish the blade and change it according to your needs.

You have multiple ways of rendering ButtonTrigger.

ByName
 {!! LaravelCompany\Mail\Triggers\ButtonTrigger::renderButtonByName('name', $model) !!}
ByWorkflowId
 {!! LaravelCompany\Mail\Triggers\ButtonTrigger::renderButtonByWorkflowId(workflow_id, $model) !!}
ByCategory

This will return all Triggers from the Category.

 {!! LaravelCompany\Mail\Triggers\ButtonTrigger::renderButtonsByCategory('categoryName', $model) !!}

Tasks

A Task is a single code execution Node in the Workflow.

TaskDescription
ChangeModelChanges an Eloquent Model (Its not saving the changes to the DB)
DomPDFThe DomPDF Task offers you a way to generate a PDF from HTML and put it to the DataBus (Works great with the HtmlInput Task).
ExecuteThe Execute Task offers you to execute Shell Commands and is able to push the output of them to the DataBus.
HtmlInputThe HtmlInput Task offers you a Trix Input Field which is able to render Blade. You can put in placeholders for dynamic content in two Ways. From the Model passed through the Workflow or from the DataBus.
HttpStatusThe HttpStatus offers you a way to receive the Http Status of a given URL.
PregReplaceThe PregReplace Task offers you a way to to a preg replace on a Value from the Model or a DataBus Variable.
LoadModelLoads an Eloquent Model from the DB. You can provide the Class and the id.
SaveFileThe SaveFile Task allows you to save Data to a File. Works easily with your registered Storage defines.
SaveModelSaves an Eloquent Model.
SendMailThe SendMail Task allows you to send a Mail. You can pass the Content and Attachments to it. (Works great with HtmlInput and DomPDF)
SendSlackMessageThis Task let you send a Slack Message. Please read the Section about Slack Notifications to make your app ready too use this.

SendSlackMessage

To send Slack messages you need to follow this 3 points.

  1. You need to install Slack notifications Laravel Slack Documentation
  2. You need to set up an incoming Slack Webhook Slack Documentation
  3. Set the WebhookUrl to your env file with WORKFLOW_SLACK_CHANNEL=YourSlackWebhookUrl

DataBus

The DataBus is a way to pass information between the single Tasks. This keeps the Tasks independent of each other.

ResourceDescription
ValueResourceThe Value Resource is the simplest Resource. You can just write your Data in an input field.
ConfigResourceThe Config Resource lets you access values from your Config Files.
ModelResourceThe ModelResource lets you access the Data from the passed Eloquent Model.
DataBusResourceThe DataBusResource lets you access the Data from the DataBus. This means all values which got set by a previous Task are access able here.