Skip to main content

Use intents for Workflows

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: 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 apps
  • input: action parameters depending on the action
  • position: the position of the task in the graph
  • predecessors: 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.

  • schedule can be one of the following types:

    • cron: { "type": "cron", "cron": "0 * * * *" }
    • interval: { "type": "interval", "intervalMinutes": 30 }
    • time: { "type": "time", "time": "09:00" }
  • eventTrigger can 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"]
      }
      }
      }

Create a new workflow from template

An exported workflow is an exact copy of a workflow. You'll need to adjust information like owner, actor, connections, and more to import it into another environment. Use a workflow template to transport a workflow from one environment to another easily.

Workflow templates are an environment-agnostic workflow representation enriched by information about required apps and connections. Dependencies for specific versions of required apps are evaluated, and links to the Dynatrace Hub allow for easy installation. Connections for action types are listed and are configurable for the workflow. All steps are optional, and users can skip them at their convenience. Use the "new workflow from template" intent if you want users to have interactive guidance when configuring the workflow.

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

  • metadata contains app dependencies and connection configuration information (required).
    • dependencies contains app dependencies.
    • inputs declares a set of input definitions for workflow task input configuration the user provides on import. It consists of type (the only supported type, for now, is "connection"), type-specific attributes (schema as fully qualified settings schema id for connection type), and targets as a list of JSON path style (dot notation) qualifiers to specify the task inputs to update with the connection id value from the wizard.
  • workflow is similar to the workflow definition described in Create a new workflow section 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 workflow
  • workflow.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 string
    • owner: filter by the owner of the workflow
    • triggerType: filter by the trigger type. Available options are Manual, Schedule, and Event.

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)
Still have questions?
Find answers in the Dynatrace Community