ServiceNow CMDB CI relationship sync: faster, more complete →
Mods
Turbot

Policy: Turbot > Notifications > Microsoft Teams > Control Template > Batch Body

Customize or format messages that are sent to a MS Teams channel for control.

When rendering messages for MS Teams using Nunjucks, users can create templates that include placeholders for variables or dynamic content. These placeholders can then be populated with data at runtime, allowing messages to be customized based on specific conditions or events.

Resource Types

This policy targets the following resource types:

Primary Policy

This policy is used with the following primary policy:

Controls

Policy Specification

Schema Type
string
Default
{% input %}
query notificationDetails($filter: [String!], $resourceId: ID!) {
  workspaceUrl: policyValue(
    uri: "tmod:@turbot/turbot#/policy/types/workspaceUrl"
    resourceId: $resourceId
  ) {
    value
  }
  turbotId: resource(id: "tmod:@turbot/turbot#/") {
    turbot {
      id
    }
  }
  accountableResource: resource(id: $resourceId) {
    turbot {
      id
    }
    trunk{
      title
    }
  }
  notifications(filter: $filter) {
    items {
      data
      control {
        state
        reason
        details
        type {
          trunk {
            title
          }
        }
        turbot {
          versionId
          id
          updateTimestamp
        }
        resource {
          turbot {
            id
          }
          trunk {
            title
          }
          type {
            trunk {
              title
            }
          }
        }
      }
      oldControl {
        state
        reason
        details
      }
    }
  }
}

{% endinput %}

{
  "summary": "[{{ $.accountableResource.trunk.title | replace('>', '>')}}]({{ domain }}/resources/{{$.accountableResource.turbot.id}})",
  "sections": [
    {%- for i in range(0, 3) -%}
    {%- if $.notifications.items[i] %}
      {
        "activityTitle": "<a href='{{ domain }}/resources/{{$.notifications.items[i].control.resource.turbot.id }}' style='font-weight:bold; color:black'>{{ $.notifications.items[i].control.resource.trunk.title | replace('>', '&gt;')}}</a>\n\n[{{ $.notifications.items[i].control.type.trunk.title }}]({{ domain}}/controls/{{$.notifications.items[i].control.turbot.id }})",
        "activitySubtitle": "<span style='font-size: 14px'>{% if $.notifications.items[i].oldControl.state == 'ok' %}OK{% elif $.notifications.items[i].oldControl.state == 'tbd'%}TBD{% else %}{{ $.notifications.items[i].oldControl.state | capitalize }}{% endif %}</span> → <span style=\"font-size: 14px; color: {% if $.notifications.items[i].control.state == 'alarm' or $.notifications.items[i].control.state == 'error' %}#cb1119{% elif $.notifications.items[i].control.state == 'ok' %}#36a64f{% else %}#d3d3d3{% endif %}; font-weight: bold;\">{% if $.notifications.items[i].control.state == 'ok' %}OK{% elif $.notifications.items[i].control.state == 'tbd'%}TBD{% else %}{{ $.notifications.items[i].control.state | capitalize }}{% endif %}</span> \n\n</span>\n\n<span style='font-size: 14px'>_{{ $.notifications.items[i].control.reason }}_</span>"
      }
    {%- if $.notifications.items.length <= 3 and $.notifications.items.length - 1 > i  %},{% endif %}
    {%- if $.notifications.items.length > 3 %},{% endif %}
    {%- endif %}
    {%- endfor %}
    {%- if $.notifications.items.length > 3 %}
      {
          "activityTitle": "[View all {{ $.notifications.items.length }} notifications →]({{ domain }}/resources/{{$.accountableResource.turbot.id}}/activity?search=controlNewVersionId:{{controlIds}}&level=self%2Cdescendant)",
          "markdown": true
      }
    {%- endif %}
  ]
}

Category

In Your Workspace

Developers