Workflows Setup

Add powerful drag & drop automation workflows to your Laravel Mail platform. Create automated email sequences triggered by events like user registration, purchase completion, or custom actions.

Installation

1. Install via Composer

composer require the42coders/workflows

2. Register Routes

Add the following to your web.php routes file. Make sure to secure these routes with your authentication middleware:

3. Publish Assets

php artisan vendor:publish --provider="App\Workflows\WorkflowsServiceProvider" --tag=assets

Optional: You can also publish config, language files, and views using the respective tags: --tag=config, --tag=lang, --tag=views

How Workflows Work

A workflow consists of Triggers and Tasks. The trigger starts the workflow, and tasks are individual nodes that execute code in sequence. Information is passed between tasks using the DataBus system.

Workflow Concept Diagram
T
Triggers

Starting points that initiate workflows based on events

A
Tasks

Individual code execution nodes that perform actions

D
DataBus

System for passing data between workflow components

Available Triggers

Observer Trigger

Listens to Eloquent Model events (created, updated, deleted) and automatically starts workflows when these events occur.

Setup: Add the trait to your Eloquent models:

use WorkflowObservable;

Use case: Send welcome emails when users register, or notify admins when orders are placed.

Button Trigger

Renders clickable buttons in your frontend that execute workflows when clicked. Perfect for manual actions.

Render by Name:
App\Workflows\Triggers\ButtonTrigger::renderButtonByName('workflow_name', $model)
Render by Workflow ID:
App\Workflows\Triggers\ButtonTrigger::renderButtonByWorkflowId(1, $model)
Render by Category:
App\Workflows\Triggers\ButtonTrigger::renderButtonsByCategory('email_actions', $model)

Use case: "Send Invoice" buttons on order pages, or "Archive User" buttons in admin panels.

Email-Related Tasks

Key tasks for building email automation workflows:

SendMail

Send emails with dynamic content and attachments. Works perfectly with HtmlInput and DomPDF tasks.

Core Email Task
HtmlInput

Rich text editor with Blade template support. Create email templates with dynamic placeholders.

Template Builder
DomPDF

Generate PDF attachments from HTML content. Perfect for invoices, receipts, and reports.

PDF Generation
LoadModel

Load additional data from your database to use in email templates and conditions.

Data Loading

Getting Started

Ready to build workflows? After installation, visit /workflows in your Laravel application to access the drag & drop workflow builder.

Example: Welcome Email Workflow

  1. Set up an Observer Trigger on your User model for the "created" event
  2. Add an HtmlInput Task to create a welcome email template with user placeholders
  3. Add a SendMail Task to send the welcome email
  4. Connect the tasks in the visual workflow builder
  5. Save and activate your workflow

Now every new user registration will automatically trigger a personalized welcome email!