# MS Teamsチャンネルへのメッセージ投稿

{% hint style="warning" %}
このドキュメントには外部ソースへの参照があります。 Nexthinkは、サードパーティのドキュメントまたは外部の更新の精度を制御しないため、不整合が発生する可能性があります。

エラーや不整合がある場合は、[Nexthinkサポート](https://support.nexthink.com/)に報告してください。
{% endhint %}

このドキュメントでは、Webhookを使用してMS Teamsのチャンネルにメッセージを投稿する方法を示します。

## MS Teams <a href="#postingamessagetoanmsteamschannel-inmsteamsmsteamsconnector" id="postingamessagetoanmsteamschannel-inmsteamsmsteamsconnector"></a>

MS Teamsのチャンネルを新しく作成した後にMicrosoft Power Automateを使用して新しいワークフローを構成してください。

1. 作成したチャンネルの3つのドットをクリックし、**Workflows** を選択します。
2. ポップアップから、Webhookリクエストが受信されたときにチャンネルに投稿するオプションを検索して選択してください。 下記の画像を参照してください。

<div align="left"><figure><img src="/files/XYZhiwzuGd0FdvDAPdsu" alt="" width="375"><figcaption></figcaption></figure></div>

3. ワークフローの名前を指定し、ワークフロー接続を定義してください。
   * Nexthink Webhookを使用して通知するMS Teamsのチャンネルを定義します。
4. 新しいワークフローを作成するには、**Add Workflow** ボタンを選択します。
5. 将来の参考のためにURLをコピーしてください。 これは、NexthinkのWebインターフェースで[コネクター認証情報](#postingamessagetoanmsteamschannel-configuringaconnectorcredentialformsteam)と[Webhook設定](#postingamessagetoanmsteamschannel-configuringawebhookformschannel)のためです。 下記の画像を参照してください。
   * NoAuthの例: `https://defaultXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.XX.environment.api.powerplatform.com:443/powerautomate/automations/direct/workflows/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/triggers/manual/paths/invoke?api-version=1&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`
   * OAuth2の例: `https://defaultXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.XX.environment.api.powerplatform.com:443/powerautomate/automations/direct/workflows/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/triggers/manual/paths/invoke?api-version=1&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0`

{% hint style="info" %}
OAuth2メソッドを使用する場合、URLから`sig`パラメーターを削除し、URLがエンコードされていないことを確認してください。
{% endhint %}

6. **Manage your Workflow** を選択します。

* 適切な**権限**が設定されていることを確認してください。
  * **NoAuth**の場合: **Anyone**に設定します。
  * **OAuth2**の場合: 最初にワークフローを保存した後に、**Any user in my tenant**に設定します。
* **出力**フォーマットが**添付ファイル**に設定されていることを確認してください。
* **アダプティブカード**が**コンテンツ**に定義されていることを確認してください。
* プライベートチームチャンネルの場合、ドロップダウンを使用して**Post as: User**に設定します。 それ以外の場合、**Flow Bot** を選択できます。

{% hint style="warning" %}
URLをNexthinkでのWebhook設定に貼り付ける前に、Power Automatorからデコードする必要があります。
{% endhint %}

<div align="left"><figure><img src="/files/Y84xsjogvJS6TedR7VZK" alt="" width="563"><figcaption></figcaption></figure></div>

<div align="left"><figure><img src="/files/LRX5vX6ixlD4JWOhRrlw" alt="" width="375"><figcaption></figcaption></figure></div>

## Entra ID <a href="#postingamessagetoanmsteamschannel-innexthink" id="postingamessagetoanmsteamschannel-innexthink"></a>

{% hint style="info" %}
コネクタ認証情報にOAuth 2.0を必要としない場合は、[Nexthink](#postingamessagetoanmsteamschannel-innexthink-1)セクションにジャンプしてください。
{% endhint %}

Microsoft Entra IDで下記の手順を追います:

1. Entra IDインスタンスにアクセスして新しいアプリケーションを登録します。
   * **Manage** > **App registrations** > **New registration**
2. アプリケーションの名前を指定し、サポートされるアカウントタイプを定義します。
3. アプリケーションを**登録**し、Nexthinkで認証情報の設定時に将来的に参照するためにアプリケーションIDをコピーしてください。
4. 新しい**クライアントシークレット**をクリックして有効期限を設定します。
5. Nexthinkで認証情報を設定する際に将来的に参照するために、シークレットの**値**（IDではなく）をコピーしてください。
   * シークレットの**値**は作成後にのみコピーできます。
6. **API パーミッション**タブに移動し、**サインインしたユーザーとしてのMicrosoft Flowにアクセスする**権限を追加します。
7. ちょうど登録したアプリの概要ページに戻り、**エンドポイント**タブに移動します。
8. NexthinkでWebhookを設定する際に将来参照するために\*\*OAuth 2.0トークンエンドポイント（v2）\*\*を保存してください。

## Nexthink <a href="#postingamessagetoanmsteamschannel-innexthink" id="postingamessagetoanmsteamschannel-innexthink"></a>

NexthinkのWebインターフェースから:

* MS TeamへのアウトゴーイングWebhookのためのコネクタ認証情報を設定する
  * [認証なし: **No Auth (None)**](#postingamessagetoanmsteamschannel-configuringaconnectorcredentialformsteam)
  * [**OAuth 2.0** 認証を使用する](#postingamessagetoanmsteamschannel-configuringaconnectorcredentialformsteam-1)
* [MSチャンネルにメッセージを投稿するためのWebhookを設定してテストする](#postingamessagetoanmsteamschannel-configuringawebhookformschannel)

### 認証なしでMS Teamのためのコネクタ認証情報を設定する <a href="#postingamessagetoanmsteamschannel-configuringaconnectorcredentialformsteam" id="postingamessagetoanmsteamschannel-configuringaconnectorcredentialformsteam"></a>

[コネクタ認証情報](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/connector-credentials.md)設定ページから、MS Teamsに設定した受信Webhookの情報を使用してフィールドを記入する:

1. **プロトコル**ドロップダウンから**HTTPS**オプションを選択してください。
2. [MS Teams](#postingamessagetoanmsteamschannel-inmsteamsmsteamsconnector)からのURLからルート`https://xxxxx.your-instance.logic.azure.com:443`を**URLアドレス**フィールドに貼り付けてください。
3. **承認** ドロップダウンから **No Auth (None)** オプションを選択してください。
4. **認証情報**を保存してください。

### 認証付きでMS Teamのためのコネクタ認証情報を設定する <a href="#postingamessagetoanmsteamschannel-configuringaconnectorcredentialformsteam" id="postingamessagetoanmsteamschannel-configuringaconnectorcredentialformsteam"></a>

[コネクタ認証情報](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/connector-credentials.md)設定ページから、MS Teamsに設定した受信Webhookの情報を使用してフィールドを記入する:

1. **プロトコル**ドロップダウンから**HTTPS**オプションを選択してください。
2. [MS Teams](#postingamessagetoanmsteamschannel-inmsteamsmsteamsconnector)からのURLからルート`https://xxxxx.your-instance.logic.azure.com:443`を**URLアドレス**フィールドに貼り付けてください。
3. **承認** ドロップダウンから**OAuth 2.0 - クライアントクレデンシャル**オプションを選択してください。
4. [Entra ID アプリケーション登録](#postingamessagetoanmsteamschannel-innexthink)の値を使用して、**アクセストークンURL**、**クライアントID**、および**クライアントシークレット**を入力してください。
5. **認証情報**を保存してください。

{% hint style="warning" %}
リソースURLのデフォルト`/.default`を末尾に持つトークンを要求するとき、ダブルスラッシュ`//`の使用が必須です。 例えば: `https://service.flow.microsoft.com//.default.`

詳細に関しては、トレーリングスラッシュとデフォルトについて[Microsoft ](https://learn.microsoft.com/en-us/entra/identity-platform/scopes-oidc#trailing-slash-and-default)ドキュメントを参照してください。

Nexthinkは、サードパーティのドキュメントまたは外部の更新による不整合の精度を制御しません。
{% endhint %}

### MSチャンネルのWebhook設定 <a href="#postingamessagetoanmsteamschannel-configuringawebhookformschannel" id="postingamessagetoanmsteamschannel-configuringawebhookformschannel"></a>

[Webhook設定ページ](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/webhooks/managing-webhooks.md)から、MS Teamsで作成した接続と、Nexthinkで定義されたコネクタ認証情報の情報を使用してフィールドを記入します。

1. [Webhook NQL条件の設定](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/webhooks/managing-webhooks/configuring-webhook-nql-conditions.md)ドキュメントに従い、**NQL 条件**を入力します。 以下のクエリを参照してください。
   * NQL条件を入力した後、システムはペイロードの**許可されたプレースホルダー**をリストします。

```
alert.alerts
| where monitor.tags contains "web-applications"
| where alert.context contains "*Salesforce*" or alert.context contains "*Microsoft*"
| list alert.monitor.name, alert.status, monitor.tags, alert.context, trigger_time, recovery_time, alert.monitor.thresholds, monitor.priority, alert.trigger_values, alert.trigger_reference_value, alert.recovery_values, alert.context, device_view_link , issue_view_link
```

2. ケースによっては、認証付きか[認証なし](#postingamessagetoanmsteamschannel-configuringaconnectorcredentialformsteam)かをMS Teamのために構成されたコネクタ認証情報を**認証情報**ドロップダウンから選択します。
3. **メソッド**ドロップダウンから**POST**を選択します。
4. [MS Teams構成](#postingamessagetoanmsteamschannel-inmsteamsmsteamsconnector)からルートURLアドレスを削除して、URLエンドポイントを**リソース**フィールドに貼り付けます。 例えば: `/workflows/XXXXXXXXXXXXXXXXXXX/triggers/manual/paths/invoke?api-version=?????&sp=/triggers/manual/run&sv=1.0&sig=XXXXXXXXXXXXXXX`

{% hint style="warning" %}
URLがエンコードされていないことを確認してください。
{% endhint %}

5. 送信したいメッセージを**ペイロード**に追加します。 以下の例を参照してください。

* 以下のペイロード例では、[Alertデータモデル変数の特別なプレースホルダー](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/webhooks/managing-webhooks/configuring-webhook-fields_-method-resource-and-payload.md#configuringwebhookfields-method-resource-andpayload-specialplaceholdersforalertsdatamodelvariablesal)が使用さています。

```
{
  "type": "message",
  "attachments": [{
      "contentType": "application/vnd.microsoft.card.adaptive",
      "content": {
        "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
        "type": "AdaptiveCard",
        "version": "1.0",
        "msteams": {
          "width": "Full"
        },
        "body": [{
            "type": "TextBlock",
            "text": "Nexthink Alert",
            "id": "Title",
            "spacing": "Medium",
            "horizontalAlignment": "Center",
            "size": "ExtraLarge",
            "weight": "Bolder",
            "color": "Accent"
          }, {
            "type": "Container",
            "items": [{
                "type": "TextBlock",
                "text": "{{alert.alert.context.application.name}},{{alert.monitor.name}}",
                "wrap": true,
                "color": "Default",
                "size": "Medium"
              }
            ],
            "style": "emphasis"
          }, {
            "type": "FactSet",
            "facts": [{
                "title": "Assigned to",
                "value": "Infrastructure Team"
              }, {
                "title": "Triggered on: ",
                "value": "{{alert.alert.trigger_time}}"
              }, {
                "title": "Application Name",
                "value": "{{alert.alert.context.application.name}}"
              },
            ]
          }, {
            "type": "TextBlock",
            "text": "Condition breached:",
            "wrap": true
          }, {
            "type": "Table",
            "columns": [{
                "width": 1
              }, {
                "width": 1
              }, {
                "width": 1
              }, {
                "width": 1
              }
            ],
            "rows": [{
                "type": "TableRow",
                "cells": [{
                    "type": "TableCell",
                    "items": [{
                        "type": "TextBlock",
                        "text": "Metric name",
                        "wrap": true
                      }
                    ]
                  }, {
                    "type": "TableCell",
                    "items": [{
                        "type": "TextBlock",
                        "text": "Threshold",
                        "wrap": true
                      }
                    ]
                  }, {
                    "type": "TableCell",
                    "items": [{
                        "type": "TextBlock",
                        "text": "Metric value",
                        "wrap": true
                      }
                    ]
                  }, {
                    "type": "TableCell",
                    "items": [{
                        "type": "TextBlock",
                        "text": "Baseline Value",
                        "wrap": true
                      }
                    ]
                  }
                ]
              }, {
                "type": "TableRow",
                "cells": [{
                    "type": "TableCell",
                    "items": [{
                        "type": "TextBlock",
                        "text": "{{alert.alert.trigger_values[0].alias}}",
                        "wrap": true
                      }
                    ]
                  }, {
                    "type": "TableCell",
                    "items": [{
                        "type": "TextBlock",
                        "text": "{{alert.monitor.thresholds[0].value}}",
                        "wrap": true
                      }
                    ]
                  }, {
                    "type": "TableCell",
                    "items": [{
                        "type": "TextBlock",
                        "text": "{{alert.alert.trigger_values[0].value}}",
                        "wrap": true
                      }
                    ]
                  }, {
                    "type": "TableCell",
                    "items": [{
                        "type": "TextBlock",
                        "text": "{{alert.alert.trigger_reference_value}}",
                        "wrap": true
                      }
                    ]
                  }
                ]
              }, {
                "type": "TableRow",
                "cells": [{
                    "type": "TableCell",
                    "items": [{
                        "type": "TextBlock",
                        "text": "{{alert.alert.trigger_values[1].alias}}",
                        "wrap": true
                      }
                    ]
                  }, {
                    "type": "TableCell",
                    "items": [{
                        "type": "TextBlock",
                        "text": "{{alert.monitor.thresholds[1].value}}",
                        "wrap": true
                      }
                    ]
                  }, {
                    "type": "TableCell",
                    "items": [{
                        "type": "TextBlock",
                        "text": "{{alert.alert.trigger_values[1].value}}",
                        "wrap": true
                      }
                    ]
                  }, {
                    "type": "TableCell",
                    "items": [{
                        "type": "TextBlock",
                        "text": "",
                        "wrap": true
                      }
                    ]
                  }
                ]
              }
            ],
            "showGridLines": false
          }, {
            "type": "ActionSet",
            "actions": [{
                "type": "Action.OpenUrl",
                "title": "View in Nexthink",
                "URL": "{{alert.alert.issue_view_link}}"
              }
            ]
          }
        ]
      }
    }
  ]
}
```

5. MS Teamsにメッセージがプッシュされていることを確認するために **送信テスト** を行ってください。

<figure><img src="/files/EadqZo017I8XIuA7TPrr" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.nexthink.com/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/webhooks/webhook-use-cases-setup/posting-a-message-to-an-ms-teams-channel.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
