自動化機能を Microsoft Teams と使用する

このページの内容

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

This procedure describes how to integrate an automation rule with a Microsoft (MS) Teams channel to show notifications about Jira issues.

If you want Jira to send messages to an MS Teams channel, you first need to integrate Microsoft Teams with Jira automation. This integration provides a webhook URL that automation uses to send messages to your MS Teams channels. This integration can be revoked at any time.

このページの内容

Create workflow in MS Teams

To set up a Microsoft Teams integration, you need to create a flow chain that will listen to Jira webhooks:

  1. Go to Microsoft Teams and find the channel where you want to send Jira notifications. Next to the channel name, select More options (...), then select Workflows.

  2. Select More workflows, then Create from blank.
  3. In the Search connectors and triggers field, enter Webhook.
  4. Under Triggers, select the When a Teams webhook request is received trigger.
    1. In the Who can trigger the flow dropdown, select Anyone.

  5. Select New Step, search for Parse JSON, and then select this option under Actions.

    1. In the Content field, enter @{triggerBody()}.
    2. In the Schema field, add the following JSON Schema.
See the JSON Schema
{
    "type": "object",
    "properties": {
        "summary": {
            "type": "string"
        },
        "sections": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "activityTitle": {
                        "type": "string"
                    },
                    "activitySubtitle": {
                        "type": "string"
                    },
                    "activityImage": {
                        "type": "string"
                    },
                    "activityText": {
                        "type": "string"
                    },
                    "facts": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "name": {
                                    "type": "string"
                                },
                                "value": {
                                    "type": "string"
                                }
                            },
                            "required": [
                                "name",
                                "value"
                            ]
                        }
                    }
                },
                "required": [
                    "activityTitle"
                ]
            }
        },
        "potentialAction": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "name": {
                        "type": "string"
                    },
                    "targets": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "uri": {
                                    "type": "string"
                                },
                                "os": {
                                    "type": "string"
                                }
                            },
                            "required": [
                                "uri",
                                "os"
                            ]
                        }
                    },
                    "@@type": {
                        "type": "string"
                    }
                },
                "required": [
                    "name",
                    "targets",
                    "@@type"
                ]
            }
        },
        "themeColor": {
            "type": "string"
        },
        "@@context": {
            "type": "string"
        },
        "@@type": {
            "type": "string"
        }
    }
}

6. Select New Step, search for Card, and then select Post message in a chat or channel under Actions. Then:

    1. In the Post in dropdown, select Channel.
    2. In the Team and Channel dropdowns, select the team and channel where the notification should be posted.

7. In the Adaptive Card field, add the following JSON:

See the JSON schema
{
    "type": "AdaptiveCard",
    "body": [
        {
            "type": "ColumnSet",
            "columns": [
                {
                    "type": "Column",
                    "items": [
                        {
                            "type": "TextBlock",
                            "weight": "Bolder",
                            "text": "@{body('Parse_JSON')['sections'][0]['activityTitle']}",
                            "wrap": true
                        }
                    ],
                    "width": "stretch"
                }
            ]
        },
        {
            "type": "TextBlock",
            "text": "@{body('Parse_JSON')['sections'][0]['activityText']}",
            "wrap": true
        },
        {
            "type": "TextBlock",
            "weight": "Bolder",
            "text": "@{body('Parse_JSON')['sections'][1]['activityTitle']}",
            "wrap": true
        },
        {
            "type": "ColumnSet",
            "columns": [
                {
                    "type": "Column",
                    "items": [
                        {
                            "type": "TextBlock",
                            "weight": "Bolder",
                            "text": "@{body('Parse_JSON')['sections'][1]['facts'][0]['name']}",
                            "wrap": true
                        }
                    ],
                    "width": "auto"
                },
                {
                    "type": "Column",
                    "width": "auto",
                    "items": [
                        {
                            "type": "RichTextBlock",
                            "horizontalAlignment": "Right",
                            "inlines": [
                                {
                                    "type": "TextRun",
                                    "text": "@{body('Parse_JSON')['sections'][1]['facts'][0]['value']}"
                                }
                            ]
                        }
                    ],
                    "verticalContentAlignment": "Center"
                }
            ]
        },
        {
            "type": "ColumnSet",
            "columns": [
                {
                    "type": "Column",
                    "items": [
                        {
                            "type": "TextBlock",
                            "weight": "Bolder",
                            "text": "@{body('Parse_JSON')['sections'][1]['facts'][1]['name']}",
                            "wrap": true
                        }
                    ],
                    "width": "auto"
                },
                {
                    "type": "Column",
                    "width": "auto",
                    "items": [
                        {
                            "type": "RichTextBlock",
                            "horizontalAlignment": "Right",
                            "inlines": [
                                {
                                    "type": "TextRun",
                                    "text": "@{body('Parse_JSON')['sections'][1]['facts'][1]['value']}"
                                }
                            ]
                        }
                    ],
                    "verticalContentAlignment": "Center"
                }
            ]
        },
        {
            "type": "ColumnSet",
            "columns": [
                {
                    "type": "Column",
                    "items": [
                        {
                            "type": "TextBlock",
                            "weight": "Bolder",
                            "text": "@{body('Parse_JSON')['sections'][1]['facts'][2]['name']}",
                            "wrap": true
                        }
                    ],
                    "width": "auto"
                },
                {
                    "type": "Column",
                    "width": "auto",
                    "items": [
                        {
                            "type": "RichTextBlock",
                            "horizontalAlignment": "Right",
                            "inlines": [
                                {
                                    "type": "TextRun",
                                    "text": "@{body('Parse_JSON')['sections'][1]['facts'][2]['value']}"
                                }
                            ]
                        }
                    ],
                    "verticalContentAlignment": "Center"
                }
            ]
        }
    ],
    "actions": [
        {
            "type": "Action.OpenUrl",
            "title": "@{body('Parse_JSON')['potentialAction'][0]['name']}",
            "url": "@{body('Parse_JSON')['potentialAction'][0]['targets'][0]['uri']}"
        }
    ],
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.6"
}

8. Verify that the step chain looks like on the screenshot, and then select Save.

9. Copy the webhook URL to the clipboard.

Add the webhook domain to the allowlist so that you can send data to it. Otherwise, the webhook could be blocked.


Paste webhook URL in Jira

The next steps will depend on the Jira automation version you’re using:

  • For a Jira automation version older than 9.0.0:

  1. Go to your automation rule, then select the Send Microsoft Teams notification action.
  2. Paste the webhook URL into the Webhook URL field.

  • For a Jira automation version newer than 9.0.0:

  1. Create a new secret key by following these instructions and using the webhook URL obtained from the Microsoft Teams interface.
  2. Go to your automation rule, then select the Send Microsoft Teams notification action.
  3. From the Wehbook URL dropdown select the secret key created earlier.

All done! You’re now integrated with your Microsoft Teams channel.

マークダウンのサポート

Microsoft Team messages support basic markdown for rich formatting. The only limitations are:

  • 画像
  • Inline HTML
  • HTML blocks
  • カスタム ノード

If you're using characters such as * or # and you want them to appear as characters in your message content, you need to escape them; otherwise, they'll be performing a markdown function. You can escape the characters by surrounding them with backslashes, for example \#\.

Send a message to a Microsoft Teams channel when a bug is raised. The message body is using smart values formatted with markdown language using:

  1. Bold
  2. 斜体
  3. Link

このルールがトリガーされると、Microsoft Teams 内のメッセージは次のように表示されます。

Done! You should now be able to receive messages from Jira in Microsoft Teams.

最終更新日: 2024 年 10 月 17 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.