// BLOG — AUTOMATIONS — TEAMS BOT

APPROVE
DENY

One of the basic actions is a need to approve/deny a request. Using the Adaptive Card Designer, I copied out the basics of the approve/deny JSON and edited to how it is below. You'll note that the data key under the Action.Submit is highly customizable.

In this example, you'll see the information that I determined was necessary to be able to handle the approval/denial of a submission from our service desk to our software subject matter experts. I added the following fields for the response handler workflow:

  • Type — Used to condition the initial noop on the response handler workflow to determine which sub-workflow is required
  • ServiceTicketId
  • ApprovedTicketNote — The ticket note ID used to generate the approval. On approval, this is used to obtain the note/time entry and send the same information off to Azure DevOps to create the work item.
  • CardID/CardActivityId — The information returned from the original message needed to update this message again once the response is recorded.
{
  "type": "Container",
  "id": "466ee0a4-b5ba-520e-0b5d-53841fffe66e",
  "padding": "Default",
  "items": [
    {
      "type": "ActionSet",
      "actions": [
        {
          "type": "Action.ShowCard",
          "title": "Approve",
          "card": {
            "type": "AdaptiveCard",
            "body": [
              {
                "type": "Input.Text",
                "id": "ApproveReason",
                "placeholder": "Add a reason",
                "isMultiline": true,
                "isRequired": true
              },
              {
                "type": "ActionSet",
                "actions": [
                  {
                    "type": "Action.Submit",
                    "title": "Submit",
                    "data": {
                      "Type": "QAApproval",
                      "ServiceTicketId": "{{ CTX.body.Entity.id }}",
                      "ApprovedTicketNote": "{{ CTX.sorted_notes[CTX.last_note_int].id }}",
                      "CardId": "{{ CTX.card_id }}",
                      "CardActivityId": "{{ CTX.card_activity_id }}"
                    }
                  }
                ]
              }
            ],
            "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
            "padding": "None"
          },
          "style": "positive",
          "isPrimary": true
        },
        {
          "type": "Action.ShowCard",
          "title": "Decline",
          "card": {
            "type": "AdaptiveCard",
            "body": [
              {
                "type": "Input.Text",
                "id": "DeclineReason",
                "placeholder": "Add a reason",
                "isMultiline": true,
                "isRequired": true
              },
              {
                "type": "ActionSet",
                "actions": [
                  {
                    "type": "Action.Submit",
                    "title": "Submit",
                    "data": {
                      "Type": "QAApproval",
                      "ServiceTicketId": "{{ CTX.body.Entity.id }}",
                      "CardId": "{{ CTX.card_id }}",
                      "CardActivityId": "{{ CTX.card_activity_id }}"
                    }
                  }
                ]
              }
            ],
            "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
            "padding": "None"
          }
        }
      ],
      "spacing": "None"
    }
  ],
  "spacing": "None"
}