포시코딩

[MS][Teams] Incoming Webhook 본문

카테고리 없음

[MS][Teams] Incoming Webhook

포시 2024. 3. 13. 14:48
728x90

 

소개

https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook?tabs=newteams%2Cdotnet

 

Create an Incoming Webhook - Teams

Create an Incoming Webhook to Teams app and post external requests to Teams. Remove Incoming Webhook. Sample code(C#, Node.js) to send card using Incoming Webhook.

learn.microsoft.com

 

Example JSON

{
  "@type": "MessageCard",
  "@context": "http://schema.org/extensions",
  "themeColor": "d58200",
  "title": "title",
  "text": "text",
  "potentialAction": [
    {
      "@type": "OpenUri",
      "name": "Name",
      "targets": [
        {
          "os": "default",
          "uri": "https://www.example.com/"
        }
      ]
    }
  ]
}

 

{
  "type": "message",
  "attachments": [
    {
      "contentType": "application/vnd.microsoft.card.adaptive",
      "contentUrl": null,
      "content": {
        "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
        "type": "AdaptiveCard",
        "version": "1.2",
        "body": [
          {
            "type": "TextBlock",
            "text": "For Samples and Templates, see [https://adaptivecards.io/samples](https://adaptivecards.io/samples)"
          }
        ]
      }
    }
  ]
}

 

{
  "type": "message",
  "attachments": [
    {
      "contentType": "application/vnd.microsoft.card.adaptive",
      "content": {
        "type": "AdaptiveCard",
        "version": "1.4",
        "body": [
          {
            "type": "TextBlock",
            "text": "Request sent by: Megan"
          },
          {
            "type": "Image",
            "url": "https://c.s-microsoft.com/en-us/CMSImages/DesktopContent-04_UPDATED.png?version=43c80870-99dd-7fb1-48c0-59aced085ab6"
          },
          {
            "type": "TextBlock",
            "text": "Sample image for Adaptive Card.."
          }
        ]
      }
    }
  ]
}

 

Card Builder

https://dev.teams.microsoft.com/

 

Developer Portal

 

dev.teams.microsoft.com

위에서 만든 예시의 경우

{
  "type": "message",
  "attachments": [
    {
      "contentType": "application/vnd.microsoft.card.adaptive",
      "contentUrl": null,
      "content": // here
    }
  ]
}

만든 후 생성된 코드를 'here' 부분에 넣어 사용하면 작동한다. 

 

https://adaptivecards.io/samples/

 

Samples and Templates | Adaptive Cards

Samples and Templates These samples are just a teaser of the type of cards you can create. Go ahead and tweak them to make any scenario possible! Important note about accessibility: In version 1.3 of the schema we introduced a label property on Inputs to i

adaptivecards.io

 

 

 

++

다만 위 템플릿들로 만들어진 코멘트 남기기 등의 기능에 대해서 오류가 나는데 해당 기능은 파악중

 

 

 

참고

https://learn.microsoft.com/en-us/answers/questions/1329257/teams-incoming-webhook-response-bad-payload-receiv

https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards-and-task-modules

728x90