An introduction and overview of workflow extensions.
actionUrl
: the URL where an HTTPS request is sent when the action is executed. The request body will contain information about which user the action is executing on behalf of, and what values were entered for the input fields.
objectTypes
: which CRM objects this action can be used with.
published
: by default, custom actions are created in an unpublished state. Unpublished actions are only visible in the developer portal associated with your HubSpot application. To make a custom action visible to users, update the published flag on your action definition to true.
inputFields
: the inputs that the action receives. These will be filled by the user.
inputFieldDependencies
: these rules define the relationships between two or more inputs, based on their dependencyType
, such as in this example here. You can use the following dependencyType
options:
SINGLE_FIELD
: these rules allow fields to be grayed out until other fields meet specific conditions. Use this to make sure a field is pre-filled before allowing visitors to continue filling out the rest of the form. Controlling (parent) fields will provide values to the corresponding dependent (child) fields.CONDITIONAL_SINGLE_FIELD
: these rules allow fields to be hidden until other fields meet specific conditions. Use this to show or hide specific fields based on a previous selection. For example, if your business is a bakery, you can add a checkbox to ask visitors if they like cake and, only if the checkbox is selected, display a field to ask what flavor of cake they like.outputFields
: the values that the action will output that can be used by later actions in the workflow. A custom action can have zero, one, or many outputs.
objectRequestOptions
: properties of the enrolled object included in the payload to the actionUrl.
labels
: copy that describes to the user what the action’s fields represent and what the action does. English labels are required, but labels can be specified in any of the following supported languages as well:
fr
)de
)ja
)es
)pt-br
)nl
)pl
)sv
)it
)da_dk
)fi
)no
)zh-tw
)executionRules
: a list of definitions you can specify to surface errors from your service to the user creating the workflow.
functions
: code snippets that are run in order to transform the payload being sent to a url and/or transform the response from that url.
event
contains the data that is passed to the functionexports.main
is the method that will be called when the function is run.callback
function can be used to return a result.functionSource
format will be in string. Ensure that the characters in the code have been escaped.
Generally, the definition of a function will follow the format:
name
: the internal name of the input field, separate from its label. The label displayed in the UI must be defined using the labels section of the custom action definition.type
: the type of value required by the input.fieldType
: how the input field should be rendered in the UI. Input fields mimic CRM properties, learn more about valid type
and fieldType
combinationssupportedValueTypes
have two valid values:
OBJECT_PROPERTY
: the user can select a property from the enrolled object or an output from a previous action to use as the value of the field.STATIC_VALUE
: this should be used in all other cases. It denotes that the user must enter a value themselves.isRequired
: this determines whether the user must give a value for this input or notinputFieldDependencies
. Learn more about defining your custom action.optionsURL
will be formatted as follows:
Field | Description |
---|---|
portalId | The ID of the HubSpot account. |
actionDefinitionId | Your custom action definition ID. |
actionDefinitionVersion | Your custom action definition version. |
objectTypeId | The workflow object type the action is being used in. |
inputFieldName | The input field you’re fetching options for. |
inputFields | The values for the fields that have already been filled out by the workflow user. |
q | The search query provided by the user. This should be used to filter the returned options. This will only be included if the previous option fetch returned searchable: true and the user has entered a search query. |
after | The pagination cursor. This will be the same pagination cursor that was returned by the previous option fetch; it can be used to keep track of which options have already been fetched. |
Field | Description |
---|---|
q | The pagination cursor. If this is provided, the workflows app will render a button to load more results at the bottom of the list of options when a user is selecting an option, and when the next page is loaded this value will be included in the request payload under fetchOptions.after . This field is optional. |
after | The default value is false . If this is true , the workflows app will render a search field to allow a user to filter the available options by a search query. When a search query is entered, options will be re-fetched with that search term in the request payload under fetchOptions.q . This field is optional. |
searchable:true
.PRE_FETCH_OPTIONS
: a function that configures the payload sent from HubSpot.POST_FETCH_OPTIONS
: a function that transforms the response from your service into a format that’s understood by HubSpot.id
in the function definition.
Field | Description |
---|---|
portalId | The ID of the HubSpot account. |
actionDefinitionId | Your custom action definition ID. |
actionDefinitionVersion | Your custom action definition version. |
objectTypeId | The workflow object type the action is being used in. |
inputFieldName | The input field you’re fetching options for. |
inputFields | The values for the fields that have already been filled out by the workflow user. |
q | The search query provided by the user. This should be used to filter the returned options. This will only be included if the previous option fetch returned searchable: true and the user has entered a search query. |
after | The pagination cursor. This will be the same pagination cursor that was returned by the previous option fetch; it can be used to keep track of which options have already been fetched. |
Field | Description |
---|---|
webhookUrl | The webhook URL for HubSpot to call. |
body | The request body. This is optional. |
httpHeaders | A map of custom request headers to add. This is optional. |
contentType | The Content-Type of the request. The default value is application/json . |
accept | The Accept type of the request. The default value is application/json . |
httpMethod | The HTTP method with which to make the request. The default is POST , but other valid values include GET , POST , PUT , PATCH , and DELETE . |
POST_FETCH_OPTIONS
function. The definition for a POST_FETCH_OPTIONS
function is the same as a PRE_FETCH_OPTIONS
function. When external external data fetch options are defined, a dropdown menu will be rendered in the input options for the action.
type
and fieldType
combinationsactionURL
. For example, you can copy output fields to an existing property in HubSpot.
labels
: copy describing what the action’s fields represent and what the action does. English labels are required, but labels can be specified in any of the following supported languages as well: French (fr
), German (de
), Japanese (ja
), Spanish (es
), Brazilian Portuguese (pt-br
), and Dutch (nl
).actionName
: the action’s name shown in the Choose an action panel in the workflow editor.actionDescription
: a detailed description for the action shown when the user is configuring the custom action.actionCardContent
: a summarized description shown in the action’s card.appDisplayName
: The name of the section in the “Choose an Action” panel where all the actions for the app are displayed. If appDisplayName is defined for multiple actions, the first one found is used.inputFieldLabels
: an object that maps the definitions from inputFields to the corresponding labels the user will see when configuring the action.outputFieldLabels
: an object that maps the definitions from outputFields to the corresponding labels shown in the workflows tool.inputFieldDescriptions
: an object that maps the definitions from inputFields to the descriptions below the corresponding labels.executionRules
: an object that maps the definitions from your executionRules to messages that will be shown for action execution results on the workflow history. There is a separate section in these docs for execution rules.actionUrl
.
callbackId
: a unique ID for the specific execution. If the custom action execution is blocking, use this ID.object
: the values of the properties requested in objectRequestOptions
.InputFields
: the values for the inputs that the user has filled out.outputFields
: the values of the output fields defined earlier. These values can be used in later actions.hs_execution_state
: an optional special value that can added to outputFields. It is not possible to specify a retry, only the following values can be added:
SUCCESS
and FAIL_CONTINUE
indicate that the action has completed and the workflow should move on to the next action to execute. If no execution state is specified, status codes will be used to determine the result of an action:
actionURL
and parse data from the actionURL
. There are two types of execution functions:
PRE_ACTION_EXECUTION
POST_ACTION_EXECUTION
PRE_ACTION_EXECUTION
functions to format data before sending it to the actionURL
The function definition will be formatted as follows:
actionURL
, use a POST_ACTION_EXECUTION
function to format data for HubSpot.
The function definition will be formatted as follows:
completed (2xx or 4xx status code)
response from your service, the workflow will stop executing (“block”) that enrollment until you tell the workflow to continue.
When blocking, you can specify a value for the hs_default_expiration
field, after which your custom action will be considered expired. The execution of the workflow will then resume and the action following your custom action will be executed, even if the action is not completed.
To block a custom action, your action execution response must have the following format:
Field | Description |
---|---|
hs_execution_state | To block workflow execution, this must be set to BLOCK for your custom action. This is a required field. |
hs_expiration_duration | The duration must be specified in ISO 8601 Duration format. If not provided, a default expiration of 1 week will be used. This is optional. |
/callbacks/{callbackId}/complete
Format the request body as follows:
Field | Description |
---|---|
hs_execution_state | The final execution state. This is a required field. The valid values for this field are SUCCESS to indicate that your custom action completed successfully, and FAIL_CONTINUE to indicate that there is a problem with your custom action execution. |
actionURL
’s response body, in the following format:
executionRules
will be tested in the order provided. If there are multiple matches, only the message from the first rule that matches is displayed to the user.
The rule matches when the execution output corresponds to a specified value in the rule. For example, consider this set of executionRules
:
{"errorCode": "ALREADY_EXISTS", "widgetName": "Test widget"}
: This would match the first rule, since errorCode
is equal to ALREADY_EXISTS
. In this instance, even though there is a widgetName
output, it isn’t used in the rule definition so any value is allowed.{"errorCode": "WIDGET_SIZE", "sizeError": "TOO_SMALL"}
: This would match the second rule, since TOO_SMALL
is one of the matching sizeError
s, and errorCode
is WIDGET_SIZE
.{"errorCode": "WIDGET_SIZE", "sizeError": "NOT_A_NUMBER"}
: This would match the third rule, since even though the errorCode
is WIDGET_SIZE
, the sizeError
does not match any of the values specified by the second rule (TOO_SMALL
or TOO_BIG
).published
flag on your action definition to true
. If an action is unpublished, portals that have already added the action to their workflow will still be able to edit and execute already added actions. But, they won’t be able to add the action again.
widgetName
: a static input fieldwidgetColor
: a dropdown field with optionswidgetOwner
: a field representing a HubSpot owner.widgetQuantity
: a field whose derived from a property (that the user creating the workflow selects) on the enrolled object.objectTypes
field isn’t specified in the custom action definition, this action will be available in all workflows types.