Custom Actions¶
Produce Custom Action Messages¶
You can use Custom Actions to enable communication between two Applications on either the same cluster or across different clusters.
Note
To understand the purpose of Custom Actions or view the overall structure of how they work, check out the documentation in the overview page here.
To ensure the Custom Action being sent is handled properly, the app.yaml outputs needs to be declared:
Note
You can choose any name for the type.
This is how the Custom Action Manager chooses which Consumer Application (Executor) will receive the Custom Action object.
The Custom Action Object in the main.py script supports the following attributes :
| Attribute | Required | Default Value | Description |
|---|---|---|---|
resource |
required | N/A | The KRNAsset that this Custom Action is meant for. |
type |
required | N/A | The name of Custom Action. |
title |
required | N/A | Title of the Custom Action |
description |
required | N/A | Description details of the Custom Action |
expiration_date |
required | N/A | Absolute datetime or a timedelta (from now) when the Control Change will expire. |
payload |
required | N/A | The custom information of the Custom Action that will be required by the Consumer Application |
trace_id |
optional | N/A | A custom id for tracking the Custom Action status |
Custom Action UI Schemas¶
You can define a UI schema for each Custom Action type your Application produces. This creates an input form in the Kelvin UI's Applications section where users can configure settings specific to this publisher application.
Example
A publisher that sends email actions might expose a field for a default subject line. This is set on the publisher application and applies to the actions it generates.
Note
The producer UI schema is independent of the consumer UI schema. Each serves a different purpose and neither defines the payload data exchanged between the two applications -- that is handled in code.
Declare the schemas in the ui_schemas.custom_actions section of your app.yaml, keyed by action type name:
| app.yaml Example | |
|---|---|
Each file is a JSON Schema that defines the configuration fields presented to users in the Kelvin UI for this publisher application:
Note
Custom Action payload schemas are optional. If not provided, the payload field is treated as free-form JSON with no UI validation.
See UI Schemas in the app.yaml reference for full details on the schema format.
Example¶
In this example we will create a Producer Application that will;
- Package the email details into a Custom Action Object
- Send the Custom Action object directly to the Consumer Application (Executor) for processing.
- Package the Custom Action object in a Recommendation and publish the "Recommendation with Custom Action" to the Kelvin UI for approval. (Typically, you would choose either direct sending or publishing with a Recommendation—not both.)
Check out the Consume Custom Actions documentation here to see how to receive this Custom Action in a Consumer Application (Executor).
app.yaml
| app.yaml Example | |
|---|---|
Publisher Application