Closed10

【teams】incoming webhookからワークフローへの移行

ranran

アダプティブカードデザイナー

GUIでテンプレートが作れる
https://adaptivecards.io/designer/

teamsを選択

超・シンプルなやつ

payload=$(cat << EOF                                                     
{
    "type": "AdaptiveCard",
    "body": [
        {
            "type": "TextBlock",
            "size": "Medium",
            "weight": "Bolder",
            "text": "test"
        }
    ],
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.5"
}
EOF
)

コピペしたやつをpayload変数に代入

webhook_url="さっき取得したURLをペースト"

さっき取得したURLをwebhook_urlに代入

curl -Ssi -H "Content-Type: application/json" -d "$payload" $webhook_url

送信

HTTP/1.1 202 Accepted
# 以下略

いけてそう?と思いきや投稿されない

ranran

bodyにattachmentsとかいうのがいる?

The execution of template action 'Send_each_adaptive_card' failed: the result of the evaluation of 'foreach' expression '@triggerOutputs()?['body']?['attachments']' is of type 'Null'. The result must be a valid array.
ranran

これでとりあえず届く

 payload=$(cat << EOF                                                     
{
   "type":"message",
   "attachments":[
      {           
         "contentType":"application/vnd.microsoft.card.adaptive",
         "content":{                                             
            "$schema":"http://adaptivecards.io/schemas/adaptive-card.json",
            "type":"AdaptiveCard",
            "version":"1.2",
            "body":[
               {
                  "type":"TextBlock",
                  "text":"This is notification",
                  "color":"warning"
               }                   
            ]   
         }   
      }   
   ]   
}   
EOF
   
)
 curl -Ssi -H "Content-Type: application/json" -d "$payload" $webhook_url

このスクラップは3ヶ月前にクローズされました