Skip to content

Webhook Examples Slack

amccook edited this page Jul 3, 2023 · 18 revisions

Prerequisites

Create a Slack App and enable Incoming Webhooks: https://api.slack.com/messaging/webhooks

Tips & Tricks

To create nicely formatted Slack messages, the following links may be helpful:

Examples

For each example, the following details will be shared:

  • Screenshot of example
  • Variables used from Turbonomic's Action DTO
  • User Variables you must supply
  • Link to JSON Workflow DTO to add webhook to your Turbonomic instance
  • Link to unescaped JSON for Slack Block Kit Builder in case you want to modify the template to your liking

Each example has been written for a specific Action. Please note the platform (On-Prem, Cloud, Container, etc), entity (VM, DB, Workload Controller, etc), and action (Move, Resize, etc) when implementing the webhooks. Webhooks may fail if implemented on the incorrect platform, entity, or action as certain Action DTO variables only exist for specific types of actions.

On-Prem VM Move

This Workflow DTO was written to accommodate On-Prem > VM > Move actions. It could work for other actions as long as the action DTO has the same variables.

image

  • Action DTO Variables

    • $action.target.className
    • $action.actionType
    • $action.actionState (using IF/ELSEIF/ELSE statement to evaluate if action is SUCCEEDED, READY, IN_PROGRESS, FAILED)
    • $action.actionMode
    • $action.userName
    • $action.updateTime
    • $action.target.displayName
    • $action.currentEntity.displayName
    • $action.newEntity.displayName
    • $action.risk.subCategory
    • $action.risk.description
    • $action.target.uuid
  • User Variables:

    • Add your Slack Webhook URL where it says <YOUR SLACK WEBHOOK URL>
    • Add your Turbo URL where it says <YOUR_TURBO_URL>
  • Workflow DTO: On-Prem VM Move

  • Slack Block Builder JSON: On-Prem VM Move

On-Prem VM Resize

This Workflow DTO was written to accommodate On-Prem > VM > Resize actions. It could work for other actions as long as the action DTO has the same variables.

  • Action DTO Variables

    • $action.target.className
    • $action.actionType
    • $action.actionState (using IF/ELSEIF/ELSE statement to evaluate if action is SUCCEEDED, READY, IN_PROGRESS, FAILED)
    • $action.actionMode
    • $action.userName
    • $action.updateTime
    • $action.target.displayName
    • $action.details
    • $action.risk.subCategory
    • $action.risk.reasonCommodities (then using a #foreach loop, iterate through each commodity, $resizeRisk)
    • $action.target.uuid
  • User Variables:

    • Add your Slack Webhook URL where it says <YOUR SLACK WEBHOOK URL>
    • Add your Turbo URL where it says <YOUR_TURBO_URL>
  • Workflow DTO: On-Prem VM Resize

  • Slack Block Builder JSON: On-Prem VM Resize