Workflows

Table of contents


ChangeDataAction

Changes the return value by extracting a specific property from the data object.

Description

This action extracts a specific property from the input data object and sets it as the new return value.

Useful when you want to isolate and pass on a nested value instead of the full data object.

IMPORTANT: If the `target` property does not exist on the data object, this may result in a `null` or an error depending on context.

Returns only the value of data->{target}.

Config Example

[
  'target' => 'propertyName'
]

CompareAction

Compares properties of a model against configured conditions.

Description

This workflow action evaluates one or more conditions against a model's properties.
Each condition can check for equality, inequality, string prefixes, or field changes.

You can also use dot-notation to access related model properties (e.g., user.name).
Useful for branching logic within workflows based on the current model state.

IMPORTANT: All conditions must pass for the action to return `true`. If any condition fails, it will short-circuit and return `false`.

Supported condition actions: equals, notEquals, startsWith, changed.

Config Example

[
  [
    'property' => 'status',
    'action'   => 'equals',
    'value'    => 'open'
  ],
  [
    'property' => 'user.name',
    'action'   => 'startsWith',
    'value'    => 'Jack'
  ]
];

CreateAction

Creates a new model instance using configuration key-value pairs.

Description

This workflow action creates a new record using the configured key-value pairs.
The target model class must be provided when initializing this action.

Each configuration value is processed through the placeholder system for dynamic replacements.
This allows template values like ###user_email### to be resolved at runtime.

IMPORTANT: Missing required fields for the target model may result in a database error.

Returns true if the object was successfully created, and tracks all saved attributes as changes.

Config Example

[
  'name' => 'Example Name',
  'email' => 'newuser@example.com',
  'role' => 'member'
];

SendEmailAction

With this Workflow you can send out emails

Description

This action sends an email using 1tool-style placeholders (starting with three hashes: ###). It uses the currently logged-in user's email address as the sender.

IMPORTANT: If any of the required fields (to, subject, text) are missing, the email will be skipped and not sent.

Attachments: Set attachments_key to a relationship name or dotted data path on the workflow's context model; the file(s) found there are attached to the email. In a proposal context, attachments_key: "files" attaches the proposal's files (Proposal::files). The resolved value must be a File / Attachable (or a collection/array of them). Note the key is attachments_key, not attachments. Similarly, to, cc, and bcc are resolved against the context model when their value matches a property/path, otherwise used verbatim.

Returns: A boolean: true if the email was sent successfully, false otherwise.

Config Example

[
  'to' => 'Recipient email address',
  'subject' => 'Email subject line',
  'text' => 'Main content/body of the email',
  'cc' => 'Optional CC address (or data path on the context model)',
  'bcc' => 'Optional BCC address (or data path on the context model)',
  'attachments_key' => 'files', // Optional: relationship/data path on the context model; its File(s) are attached
  'email_setting_id' => 'Optional EmailSetting id to send through',
];

SendHttpRequestAction

Dispatches a custom HTTP request.

Description

This action sends an HTTP request using the provided configuration options.

Useful when you want to trigger external APIs or webhooks as part of a workflow step, passing in custom headers, body content, and query parameters.

IMPORTANT: The `url` field is required. If missing, the request will not be sent and the action will return `false`.

The HTTP response (status, headers, and body) will be stored in $this->returnValue for downstream use.

Supports:

Config Example

[
  'url' => 'https://api.example.com/send',
  'method' => 'POST',
  'headers' => [
    'Authorization' => 'Bearer secret_token',
    'Content-Type' => 'application/json',
  ],
  'body' => [
    'id' => 'data.id',
    'email' => 'data.email',
  ],
  'query' => [
    'debug' => 'true'
  ]
]

SendInvoiceAction

Dispatches an invoice job for a user.

Description

This workflow action dispatches an invoice generation job for the specified user.

It uses the given userId and the current data->id (usually the invoice ID) to trigger the process.

The job runs asynchronously using Laravel's job queue system.

IMPORTANT: If `userId` is missing from the configuration, the action is skipped and **no invoice will be sent**.

Returns a boolean: true if the job was successfully dispatched, false if the config was invalid.

Config Example

[
  'userId' => 'ID of the user for whom the invoice should be dispatched',
];

SleepAction

Pauses the workflow execution for a specified number of seconds.

Description

This workflow action delays execution for a number of seconds specified in the configuration.

It is useful for debugging, simulating delays, or testing time-based behavior in workflows.

NOTE: The delay is applied using PHP’s `sleep()` function. Long delays can block execution.

Returns the original data unchanged after the sleep duration.

Config Example

[
  'sleep_duration' => 5
]

TranslateProposalAction

Generates a translated PDF for a proposal and stores it as a file.

UpdateAction

Dynamically updates model fields using key-value configuration.

Description

This workflow action updates fields on the given model using key-value pairs from the configuration.

Nested relationships can be updated by using dot notation (e.g., profile.bio).

Each value is processed through the configuration replacement system to support dynamic inputs.

IMPORTANT: Invalid relationships or keys that do not exist on the model may result in errors or be ignored.

Returns the updated model and tracks changed values internally.

Config Example

[
  'name' => 'New name value',
  'email' => 'new@email.com',
  'profile.bio' => 'Updated biography text'
]

UseChatGptAction

Sends a query to ChatGPT and returns the response.

Description

This action sends a message to OpenAI's ChatGPT API and returns the AI-generated response.

Useful when you want to automate replies, transform content, or generate text using AI within a workflow.

IMPORTANT: You must provide a valid OpenAI API key and a user `query`. If the request fails or the response is invalid, the action will return `false`.

The action includes a preset system instruction to ensure ChatGPT behaves like a task executor:

"You're an assistant. Your role is to execute tasks exactly as requested, returning only the pure result without any suggestions, explanations, or additional help. Strip everything down to just what is asked—nothing more, nothing less."

The raw response is stored in $this->returnValue['content'].

Config Example

[
  'api_key' => 'sk-xxxx',
  'query' => 'Translate this text to German: Hello, how are you?',
  'model' => 'gpt-4o' // Optional, defaults to 'gpt-4o'
]

Back to top