Posting messages in MS Team Private channels

お困りですか?

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

コミュニティに質問

プラットフォームについて: Cloud のみ - この記事は クラウド プラットフォームのアトラシアン製品に適用されます。

要約

This article describes how to integrate Jira Cloud with MS Teams, allowing users to post messages in private MS Teams channels. 

診断

Jira Cloud integration with MS Teams does not allow posting messages to private MS Teams channels.

原因

Because MS Teams "Bot" users can't be recognized as members of the private team channel, it is not possible to use standard integration workflow to send messages to private channels. 

ソリューション

To overcome this issue, we can create a custom workflow in MS Teams that iterates over the incoming webhook payload to create a custom message that is posted to a private channel. 

The steps to do that are described below: 

  1. Create the Jira Automation Rule
    1. Add the trigger that will begin the Automation Rule execution
    2. Add the "Send Microsoft Teams message" block to the Automation Rule



  2. Create MS Teams Workflow
    1. From the channel options  select Workflows and look for "Post to a channel when a webhook request is received" template: 
       A context menu for a private channel named Private_Channel is displayed. The Workflows option is highlighted, indicating it has been selected. Other available options include Channel notifications, Pin, Hide, Manage channel, Add members, Get email address, Get link to channel, Rename channel, Manage tags, Archive channel, Delete channel, and Leave channel. A lock icon next to the channel name signifies its private status.
    2. Copy the webhook URL from MS Teams workflow and use it in Jira Automation Rule "Send Microsoft Teams message" block as a Webhook URL. 
  3. In the automation rule configure Message titile and details, check "Include issue summary in message" box: 
  4. Edit MS Teams Workflow. 
    1. The complete workflow will look as follows (we will go through the steps below): 
    2. The first step should be "When a Teams webhook request is received". 
      1. The "Who" field should be set to "Anyone".
      2. The HTTP POST URL is the URL used in Jira Automation Rule (point 2.b). 
    3. Initialize variables "bodyText", "Newline" and "Urlvar". 
      1. bodyText – This variable will be appended by all the text fields Jira will send in its packet.
      2. Newline – This is simply a <br> tag to break the text values into lines.
      3. Urlvar – This will store the url that points back to the ticket in Jira.
    4. Create an ‘Apply to each’ action that will cycle through the data packets.
      1. Use "attachments" output.
        A screenshot of the Microsoft Power Automate flow configuration screen. The flow is set up to Apply to each item in the attachments output from a previous step. Subsequent actions include Parse the content, Parse the Body, another Apply to each, Parse JSON, and a final Apply to each. A red arrow points from the words Select an output from previous steps to the selected attachments value. At the bottom is a button to Add an action.
      2. Next add Parse the JSON element: 
        A screenshot of the Parse the content step configuration in Microsoft Power Automate. The Apply to each setting is configured to use attachments from the previous step. In the Parse the content settings, the Content field is set to content, and the Schema field displays a partially visible JSON schema defining types and properties, including nested content and schema objects. A Generate from sample button is also visible at the bottom.
        Using the following schema:

        {
            "type": "object",
            "items": {
                "type": "object",
                "properties": {
                    "content": {
                        "type": "object",
                        "properties": {
                            "schema": {
                                "type": "string"
                            },
                            "version": {
                                "type": "string"
                            },
                            "type": {
                                "type": "string"
                            },
                            "body": {
                                "type": "array",
                                "items": {
                                    "type": "object",
                                    "properties": {
                                        "type": {
                                            "type": "string"
                                        },
                                        "text": {
                                            "type": "string"
                                        },
                                        "style": {
                                            "type": "string"
                                        },
                                        "weight": {
                                            "type": "string"
                                        },
                                        "size": {
                                            "type": "string"
                                        },
                                        "wrap": {
                                            "type": "boolean"
                                        }
                                    },
                                    "required": [
                                        "type",
                                        "text",
                                        "style",
                                        "weight",
                                        "size",
                                        "wrap"
                                    ]
                                }
                            },
                            "actions": {
                                "type": "array",
                                "items": {
                                    "type": "object",
                                    "properties": {
                                        "type": {
                                            "type": "string"
                                        },
                                        "title": {
                                            "type": "string"
                                        },
                                        "url": {
                                            "type": "string"
                                        }
                                    },
                                    "required": [
                                        "type",
                                        "title",
                                        "url"
                                    ]
                                }
                            }
                        }
                    },
                    "contentType": {
                        "type": "string"
                    }
                },
                "required": [
                    "content",
                    "contentType"
                ]
            }
        }
      3. Add a second Parse a JSON element: 

        Using Body as a content and following schema: 

        {
            "type": "object",
            "properties": {
                "body": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "type": {
                                "type": "string"
                            },
                            "text": {
                                "type": "string"
                            },
                            "style": {
                                "type": "string"
                            },
                            "weight": {
                                "type": "string"
                            },
                            "size": {
                                "type": "string"
                            },
                            "wrap": {
                                "type": "boolean"
                            }
                        },
                        "required": [
                            "type",
                            "text",
                            "style",
                            "weight",
                            "size",
                            "wrap"
                        ]
                    }
                }
            }
        }
      4. After adding a second JSON parser, we need to add "Apply to each" 
        A screenshot of a Microsoft Power Automate workflow. The workflow starts with an Apply to each loop using attachments. It then performs actions Parse the content and Parse the Body. A second Apply to each 2 loop follows, using body, and contains two Append to string variable actions. Finally, there's a Parse JSON action and another Apply to each 3 loop. Plus buttons to add actions are visible below the second and third Apply to each loops. A red arrow points to the Apply to each 2 block.
        The "body" from a previous action should be selected as output from previous steps
      5. WIthin this loop we will create a message by appending a variable "bodyText" with the "text" variable created previously in JSON parser action and "Newline" variable: 
        A screenshot of Microsoft Power Automate showing two Apply to each loops. The first loop parses email attachments. The second loop appends the parsed text and a newline character to a string variable named bodyText.


      6. Next we will add another Parse JSON action, using "Body" as a content: 
        Screenshot of the Microsoft Power Automate designer canvas showing the Parse JSON action. This action parses JSON content from the Body variable. The schema is displayed in the right panel. Below the schema section is the Generate from sample button.
        And following schema: 

        {
            "type": "object",
            "properties": {
                "actions": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "type": {
                                "type": "string"
                            },
                            "title": {
                                "type": "string"
                            },
                            "url": {
                                "type": "string"
                            }
                        },
                        "required": [
                            "type",
                            "title",
                            "url"
                        ]
                    }
                }
            }
        }
      7. Add a new Apply to each element that will loop through "actions" and create link:
         

      8. Append the "bodyText" variable: 
      9. Append the "Urlvar" variable: 
        Part of a Power Automate flow configuration showing the Append to string variable 4 action. The Name field is set to Urlvar and the Value field is set to the url dynamic content. This action is within an Apply to each 3 loop.
    5. We have completed the main Apply to each loop. Now it is time to send the message to the private channel using "Post message in a chat or a channel: 
      The Post message in a chat or channel action configuration in Power Automate. The message is configured to be posted as a user in the Private_Channel channel of a specific team (name redacted). The message content includes the bodyText variable, a line break, and a link labeled View Case that points to the Urlvar variable. The subject is set to Jira Alert.
      Note that the message will be posted as User who is the owner the MS Teams workflow. 
最終更新日: 2025 年 2 月 27 日

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

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