Action Playbook Bricks
Purpose | Explore this guide to discover the various types of Action Playbook Bricks, along with examples of popular ones used in the Playbook App. Learn how to set them up with easy-to-follow instructions, giving you a understanding of how they work and where they can be useful. |
---|
Last Updated | September 03, 2024 |
---|
Introduction to Action Playbook Bricks: Support Video
What are Action Playbook bricks?
Action Playbook Bricks are used to automate various tasks. These bricks can be created and managed within the Brick Management section.
Brick types
Trigger Bricks
Triggers are events that initiate a playbook. They can be internal events, such as a scheduled time, or external events, such as a webhook. When a Trigger is activated, it starts the Playbook.
Triggers can be thought of as a special type of Action Brick that activates a Flow when certain conditions are met.
You can determine the category of the Trigger Brick by the red color assigned to it.
Operator Bricks
Operator Bricks determine how a Playbook flows. Think of them as the decision-makers of the Playbook. They are like inspectors set up at certain levels of the Playbook which check if the parameters set up by you are being followed. For example, you might configure an Operator Brick to examine incoming data and check if it meets specific criteria. If the data matches these criteria, the Operator Brick allows it to continue down a particular path, perhaps performing certain actions or transformations. On the other hand, if the data doesn't meet the criteria, the Operator Brick can reroute it or trigger different actions.
You can determine the category of the Operator Brick by the blue color assigned to it.
Transform Bricks
Transforms are used to modify data that is passed between actions. They can be used to filter data, add metadata, or perform calculations. Transforms are especially useful when working with data from multiple sources or when the data needs to be formatted in a specific way.
You can determine the category of the Transform Brick by the orange color assigned to it.
Execute Bricks
Executes are tasks that are performed by the Playbook. They can be anything from sending an email to making an API call. Each action has specific inputs and outputs and can be customized to suit the needs of the Playbook.
You can determine the category of the Action Brick by the green color assigned to it.
Creating an Action Playbook Brick
To create a new Playbook Brick:
-
Navigate to Settings / Brick Management V3.
-
Click CREATE BRICK in the top right corner.
-
Fill in the name and description, and select Action Playbook Brick as the type.
If you have an existing Brick you can use the fork option to skip various steps of the configuration process.
Configuration
Before using a Playbook Brick, several configurations are required. These configurations can be set in the Configuration > Configuration tab.
The configuration JSON includes the following fields:
Name | Description | Type |
---|---|---|
brickId | A random identifier | String |
label | The name of the brick as it will appear in Playbooks | String |
description | The description of the brick | String |
placeholder | Placeholder value for the brick | String |
params | What parameters the brick can use. These parameters will be explained in the parameters section | List of objects |
icon | The icon that will appear next to the brick in Playbooks. The icons section below will explain how to use icons | String |
type | Can be one of execute, trigger, transform, operator. | String |
input | Whether the brick allows input nodes | Boolean |
output | Whether the brick allows output nodes | Boolean |
canTest | Whether the brick gets a debug option | Boolean |
Parameters
Playbook Bricks can have multiple parameters to determine their behavior. The parameters can be of the following types:
-
text
: Allows any string input. -
select
: Provides a dropdown menu for selection. -
secret
: Allows selection from configured secrets. -
jinja2
: Indicates that the input string contains a Jinja template. -
prompt
: Indicates that the input string contains an LLM prompt.
Each parameter has the following fields:
Name | Description | Type | Required |
---|---|---|---|
name | Name of the parameter. Use this name to reference the parameter in your code. | String | Yes |
label | The name that will be shown in the playbook | String | Yes |
type | The parameter type. This can be one of the types shown above | String | Yes |
placeholder | Placeholder value | String | No |
default | Default value | String | No |
required | Whether the parameter is required | Boolean | No, will default to False |
options | A list of options for the select parameter type. These options have a value and a label | List of objects | Only required for select type |
secretType | What type of secret to use (e.g. "BASIC", "APIKEY") | String | No, will default to all secret types |
Icons
The icon string should begin with:
data:image/{{image_type}}+xml;base64,
Where image_type
can be png
, jpeg
, or svg
.
This prefix should be followed by your base64 encoded icon.
Writing the Brick Code
To start coding your brick:
-
Navigate to Code.
-
Click + to add a Python file.
-
Name the file main.py.
Brick Class
Implement a Brick class that contains the core logic of your brick. This class should extend BaseBrick.
__init__()
This method initializes the brick and sets up its configuration.
Parameters:
config
: A configuration object containing the parameters. You can retrieve the values using the parameter names as keys.
run()
This method contains the logic for executing the brick's task.
Parameters:
-
task
(Object): An object containing task information with the following attributes:event
(dict): The base event.state
(dict): The playbook state.variables
(dict): The output from upstream tasks.
-
in_nodes
(list): Input nodes. -
out_nodes
(list): Output nodes.
Returns: A routed_task (RoutedTask):
-
session_id
(String): The task's session ID, retrievable from the input task (task.session_id).event
(Dict): The base event, retrievable from the input task (task.event
).
-
state
(Dict): The playbook state, retrievable from the input task (state). -
variables
(Dict): The variables, retrievable from the input task (variables). -
out_nodes
(List): The output nodes.