Skip to content

How-To: Setting Up Automated Workflows

This guide explains how to create powerful automated marketing workflows using AIOHM's visual workflow builder.

What are Workflows?

Workflows are automated sequences of tasks. They connect different marketing platforms and AI agents to create sophisticated automations for content creation, email campaigns, social media, and more.

Building Your First Workflow

Step 1: Access the Workflow Builder

  1. Navigate to Automation → Workflow Builder in the admin panel.
  2. Click "Create New Workflow".
  3. You can start from a blank canvas or use a pre-built template.

Step 2: Define a Trigger

The trigger is the event that starts your workflow.

  • Manual: You start the workflow by clicking "Run".
  • Schedule: Runs automatically at a set time (e.g., daily, weekly).
  • Webhook: Triggered by an HTTP request from an external service.

Step 3: Add Nodes

Nodes are the building blocks of your workflow. Drag nodes from the palette onto the canvas to build your sequence.

  • Agent Nodes: Perform complex tasks using AI (e.g., Marketing Agent to write content, SEO Agent to optimize it).
  • Tool Nodes: Perform specific actions (e.g., Image Generator, Data Transformer).
  • Action Nodes: Interact with external platforms (e.g., Postiz Schedule, Mautic Campaign).

Step 4: Connect Nodes and Configure

  • Drag connections from the output of one node to the input of another to define the flow of data.
  • Click on any node to open the Properties Panel, where you can configure its specific settings (e.g., provide instructions to an AI agent, select which social media account to post to).

Step 5: Test and Publish

  • Use the "Test Workflow" button to do a dry run and inspect the output of each node.
  • Once you are satisfied, click "Publish Workflow" to make it live.

📝 Example Workflow: Blog to Social Media

This workflow automatically creates a social media post whenever a new blog post is published.

mermaid
graph TD
    A[Webhook Trigger <br><i>(New Blog Post Detected)</i>] --> B[Marketing Agent <br><i>(Summarize post & write social copy)</i>];
    B --> C[Image Generator <br><i>(Create a relevant image)</i>];
    C --> D[Postiz Schedule <br><i>(Publish to Facebook & Twitter)</i>];

👨‍💻 For Developers: Technical Reference

This section provides technical details for developers looking to extend the workflow system.

Core Components

  • Models: The workflow system is powered by several Eloquent models, including:

    • WorkflowTemplate: Stores the structure of reusable templates.
    • WorkflowCampaign: An instantiated, runnable workflow created from a template.
    • WorkflowTask: Represents a single node within a workflow.
    • ExecutionLog: Records the history and output of each workflow run.
  • Artisan Commands: Several commands are available to manage workflows via the CLI:

    • php artisan workflows:list-templates: Lists all available workflow templates.
    • php artisan workflows:create-from-template: Creates a new workflow from a template.
    • php artisan workflow:run {id}: Manually triggers a specific workflow run.
    • php artisan schedule:run: Executes all scheduled workflows (this is typically run by a cron job).

Creating New Workflow Templates

The easiest way to add new, complex workflows to the platform is by creating a database seeder.

  1. Create a new seeder: php artisan make:seeder MyNewWorkflowSeeder.
  2. In the run() method, define the workflow structure as an array and create a WorkflowTemplate record.
  3. You can see a complete example of this in database/seeders/AiAgentAuditWorkflowSeeder.php.

Creating Custom Nodes

To add a new custom action or trigger to the workflow builder, you need to create a new "Node" class.

  1. Create a Node Class: Create a new class in a relevant directory, such as app/Workflows/Nodes/.
  2. Implement Required Methods: Your class should extend a base node class (if one exists) or implement a Node interface. It will need methods to define its behavior, such as:
    • getName(): A machine-readable name (e.g., my_custom_action).
    • getDescription(): A user-friendly description for the UI.
    • getInputs() / getOutputs(): Define the data ports for the node.
    • execute(array $data): The main logic for the node. This method receives data from the previous node, performs its action, and returns data for the next node.
  3. Register the Node: Register your new node class in a service provider so it appears in the workflow builder's node palette.

Released under the MIT License.