ReferenceWorkflows

Workflows

Blueprints

Mastra workflows combine a visual editor that modify configuration object that you commit to your repository.

A workflow is defined by a JSON object with the following structure:

FieldTypeDescription
titlestringThe name of the workflow
statusstringThe current status of the workflow (e.g., “PUBLISHED”)
createdAtstringISO 8601 timestamp of when the workflow was created
idstringUnique identifier for the workflow
updatedAtstringISO 8601 timestamp of when the workflow was last updated
triggerobjectDefines the event that initiates the workflow
actionsarrayList of actions to be executed when the workflow is triggered

Trigger

FieldTypeDescription
idstringUnique identifier for the trigger
typestringThe type of event that triggers the workflow (e.g., “BUTTON_CLICKED”)
payloadobjectAdditional data for the trigger (can be empty)

Actions

Each action in the actions array is an object with the following structure:

FieldTypeDescription
idstringUnique identifier for the action
typestringThe type of action to be performed (e.g., “CREATE_POST”)
payloadobjectData required for the action
variablesobjectVariables used in the action (can be empty)
subActionsarrayList of actions to be executed after the main action

Payload (for CREATE_POST action)

FieldTypeDescription
poststringThe content of the post to be created
mastraConnectionIdstringConnection ID for the user or entity creating the post

SubActions

SubActions have a similar structure to main actions, with an additional field:

FieldTypeDescription
parentActionIdstringID of the parent action

Payload (for SEND_MESSAGE_TO_CHANNEL action)

FieldTypeDescription
channelIdstringID of the channel to send the message to
messagestringContent of the message, can include variables
mastraConnectionIdstringConnection ID for the user or entity sending the message

Variables

Variables can be used to dynamically insert data into actions. They are defined in the variables object of an action:

{
  "variables": {
    "message": {
      "twitterlink": {
        "refBlockId": "parentActionId",
        "path": "resultFieldName"
      }
    }
  }
}
  • refBlockId: ID of the action to reference
  • path: The field in the referenced action’s result to use