Use intents for Workflows
- How to
- 6 minutes
Workflows provide the following intents:
- Create a new workflow: an intent to create a workflow and, optionally, an associated trigger
- Create a new workflow from template by id: an intent to create a workflow from a template by providing the document ID of the template
- Create a new workflow from template: an intent to create a workflow from a template providing interactive guidance for app requirements and task connections configuration
- View workflow: an intent that opens an existing workflow in the editor by a given ID
- Search workflows: an intent to search for workflows, thus opening the list of workflows for given filter criteria
- Automate DQL Query: an intent to create a new workflow with a single Execute DQL Query task and fill the task with the passed DQL query
- Automate code: an intent to create a new workflow with a single Run JavaScript task and fill the task with the passed code snippet
Create a new workflow
Do you have data in your app that should serve as a workflow starting point, for example, a daily report? You can use intents to guide the user from your app to a new workflow.
Define the intent
An intent to create a workflow requires at least the following mandatory properties:
{
"title": "Workflow from intent",
"tasks": {}
}
Here is an example of an intent for a workflow with two sequential tasks and an interval-based trigger:
{
"title": "Workflow from intent",
"tasks": {
"task1": {
"name": "task1",
"action": "dynatrace.automations:run-javascript",
"input": {
"script": "export default async function () { \n console.log('Hello world.')\n}"
},
"position": { "x": 0, "y": 1 }
},
"task2": {
"name": "task2",
"action": "dynatrace.automations:http-function",
"input": {
"url": "https://www.dynatrace.com/contact/",
"method": "GET"
},
"position": { "x": 0, "y": 2 },
"predecessors": ["task1"]
}
},
"trigger": {
"schedule": {
"trigger": {
"type": "interval",
"intervalMinutes": 25
}
}
}
}
Intent payload details
A workflow can consist of a list of tasks. Each task has the following properties:
action: one of the actions which are made available by appsinput: action parameters depending on theactionposition: the position of the task in the graphpredecessors: an optional list of predecessor tasks
An optional trigger can be provided to define how the workflow is executed. It can specify either a schedule or an eventTrigger. If omitted, an on-demand trigger is assumed.
-
schedulecan be one of the following types:- cron:
{ "type": "cron", "cron": "0 * * * *" } - interval:
{ "type": "interval", "intervalMinutes": 30 } - time:
{ "type": "time", "time": "09:00" }
- cron:
-
eventTriggercan be one of the following types::-
event:
{
"triggerConfiguration": {
"type": "event",
"value": { "query": "..." }
}
} -
davis-problem:
{
"triggerConfiguration": {
"type": "davis-problem",
"value": {
"onProblemClose": false,
"categories": {
"monitoringUnavailable": true,
"availability": true,
"error": true,
"slowdown": true,
"resource": true,
"custom": true,
"info": true
}
}
}
} -
davis-event:
{
"triggerConfiguration": {
"type": "davis-event",
"value": {
"onProblemClose": false,
"types": ["APPLICATION_ERROR_RATE_INCREASED"]
}
}
}
-
"Davis" is the former brand name for Dynatrace AI, now called "Dynatrace Intelligence." Legacy strings and files may still use "Davis" and these references remain valid.
Create a new workflow from a template by ID
An exported workflow is an exact copy of a workflow. To import it into another environment, you'll need to adjust details such as the owner, actor, connections, and more. Using a workflow template makes it easier to transport a workflow from one environment to another.
Workflow templates are environment-agnostic representations of workflows, enriched with information about required apps and connections. Dependencies for specific versions of required apps are evaluated, and links to the Dynatrace Hub make installation simple. Connections for action types are listed and can be configured for the workflow. All steps are optional, allowing users to skip them if needed.
If you want users to have interactive guidance when configuring a workflow, use intents based on workflow templates instead of workflows.
This specific intent references a workflow template by its document ID and optionally allows further input values to tweak the selected workflow template.
Define the intent
Below is an example of an intent referencing a workflow template document:
{
"workflowTemplateId": "dynatrace.slack.davis-problem-notification"
}
Intent payload details
workflowTemplateId: The document ID as a string. This is typically your app name concatenated with a period (.) and the document name, as provided in the app manifest that ships the template. (Required)inputs: A list of input objects. Each object contains:targetsA list of target properties specified as JSON Path strings in dot notation (e.g.,path.to.prop.foo,path.to.prop.bar, etc.).value: The value to set for the specified targets.
Note: Values for task properties that hold connection IDs will always be set to the connection selected by the user in the "Create workflow from template" wizard in the Workflows app, no matter the inputs configuration.
Create a new workflow from template
For an explanaition about workflow vs workflow template please see the description of the intent Create a new workflow from template by id -
We always recommend to use Create a new workflow from template by id over this intent, unless you encounter a limitation where you cant ship the template with your app. Please also mind the length restriction of an URL and therefore an intent, which effects the size of the workflow template you can provide.
Define the intent
Here is an example of an intent for a workflow with two sequential tasks and an interval-based trigger:
{
"metadata": {
"dependencies": {
"apps": [
{
"id": "dynatrace.automations",
"version": "^1.0.0"
},
{
"id": "dynatrace.slack",
"version": "^1.2.0"
}
]
},
"inputs": [
{
"type": "connection",
"schema": "app:dynatrace.slack:connection",
"targets": ["tasks.send_message.connection"]
}
]
},
"workflow": {
"title": "Workflow from intent",
"tasks": {
"send_message": {
"name": "send_message",
"description": "Send a message to a Slack workspace",
"action": "dynatrace.slack:slack-send-message",
"input": {
"message": "",
"reaction": [],
"connection": "",
"workflowID": "{{ execution().workflow.id }}",
"executionID": "{{ execution().id }}",
"executionDate": "{{ execution().started_at }}",
"appendToThread": false,
"selectedRequestType": 0,
"attachmentToggleValue": "none"
},
"position": {
"x": 0,
"y": 1
}
},
"run_javascript": {
"name": "run_javascript",
"description": "Build a custom task running js Code",
"action": "dynatrace.automations:run-javascript",
"input": {
"script": "export default async function () { \n console.log('Hello world.')\n}"
},
"position": {
"x": 0,
"y": 2
},
"predecessors": ["send_message"]
}
},
"trigger": {
"schedule": {
"trigger": {
"type": "interval",
"intervalMinutes": 25
}
}
}
}
}
Intent payload details
metadatacontains app dependencies and connection configuration information (required).dependenciescontains app dependencies.appsis a list of required apps as objects consisting of appidandversion.versionsupports npm style semver version range syntax.
inputsdeclares a set of input definitions for workflow task input configuration the user provides on import. It consists oftype(the only supported type, for now, is "connection"), type-specific attributes (schemaas fully qualified settings schema id for connection type), andtargetsas a list of JSON path style (dot notation) qualifiers to specify the task inputs to update with the connection id value from the wizard.
workflowis similar to the workflow definition described inCreate a new workflowsection above but deliberately omits actor and owner information to allow environment-agnostic creation (required).
View workflow
An intent that opens an existing workflow in the editor by a given ID.
Define the intent
{
"dynatrace.workflows.id": "00000000-0000-0000-0000-000000000000"
}
Intent payload details
You need to provide only one property, either dynatrace.workflows.id or workflow.id.
dynatrace.workflows.id: the UUID of the workflowworkflow.id: the UUID of the workflow
Search workflows
An intent to search for workflows, thus opening the list of workflows for given filter criteria.
Define the intent
{
"dt.searchQuery": {
"search": "My workflow",
"owner": "00000000-0000-0000-0000-000000000000",
"triggerType": "Manual"
}
}
Intent payload details
dt.searchQuery: object (required)search: filter by a search stringowner: filter by the owner of the workflowtriggerType: filter by the trigger type. Available options areManual,Schedule, andEvent.
Automate DQL Query
Using dt.query in the intent payload, you can create a new workflow with a single Execute DQL Query task that will execute the passed query.
Define the intent
{
"dt.query": "fetch logs\n| limit 100"
}
Intent payload details
dt.query: the DQL query (required)
Automate code
Using dt.code in the intent payload, you can create a new workflow with a single Run JavaScript task to execute the passed code.
Define the intent
{
"dt.code": "export default async function () {\n return \"Hello, world!\";\n}"
}
Intent payload details
dt.code: the code snippet (required)