# Nexthink REST APIを使用したチャットボットの統合

統合なしでは、チャットボットはデバイスまたはユーザー情報を取得できません。 これにより、不完全な応答、従業員の不満、不必要なサービス デスクへのエスカレーションが発生します。

Nexthink APIを統合することにより、あなたのチャットボットは次のことができます:

* データ駆動型のチャットボット応答を提供する
* NQLクエリを使用してリアルタイムのデバイスと従業員のコンテキストを取得する
* 会話内でリアルタイムに問題を診断する
* 問題を即座に修正するための関連アクションをトリガーする

## Nexthink API機能を使用したチャットボット統合はどのように機能しますか? <a href="#integratingchatbotswithnexthink-chatbotintegrationflow" id="integratingchatbotswithnexthink-chatbotintegrationflow"></a>

Nexthinkのチャットボット-APIの統合は、次の構造に従います:

* チャットボットシステムは、会話の内容やロジックを含め、従業員との対話を制御します。
* Nexthinkはチャットボットが会話中に呼び出すAPIを提供します:
  * NQL API - Nexthink からコンテキスト関連データを取得します。
  * リモートアクションAPI - 該当する場合、修復のリモートアクションをトリガーします。

{% hint style="info" %}
オプションで、[データエクスポーター](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/data-exporters.md)と[Webhook](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/webhooks.md)を使用して大量のデータをエクスポートするNexthinkの**アウトバウンドコネクター**を設定してください。 エクスポートされたイベントデータを使用して、プロアクティブなチャットボット会話をトリガーします。
{% endhint %}

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

### Nexthink API技術を使用したチャットボットフロー

以下に、Nexthink APIを介して問題解決を達成するタスクを含むチャットボットフローを示します。

| 必要なタスクまたはステップ - チャットボット                                      | API統合アプローチ                                                                                                                                                                                                                                                                                                      |
| ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <ol><li><strong>通信を認証する</strong></li></ol>                   | **APIクレデンシャル** - APIを介してトークンを収集します。                                                                                                                                                                                                                                                                             |
| <ol start="2"><li><strong>従業員またはデバイスを特定する</strong></li></ol> | <p><strong>NQL API</strong> - 特定のユーザー名またはデバイス識別子データを取得します。</p><p><br>(オプション) <strong>データエクスポート-</strong> 必要なデータ（ユーザー/デバイス名や最後に確認した日付など）をエクスポートして、チャットボットと統合されたCMDBシステムを定期的に強化します。</p>                                                                                                                           |
| <ol start="3"><li><strong>ユーザーデバイスを診断</strong></li></ol>     | **NQL API** - 従業員デバイス情報（デバイスの健康状態、アプリケーションメトリクスなど）を取得して、フォローする修復アクションを絞り込みます。                                                                                                                                                                                                                                   |
| <ol start="4"><li><strong>デバイスの問題を修正</strong></li></ol>      | **リモートアクションAPI** - 診断に基づいて目標デバイスに修復アクションをトリガーするか、ユーザーの要求に応じてトリガーします。                                                                                                                                                                                                                                            |
| <ol start="5"><li><strong>フォローアップと修正の確認</strong></li></ol>   | **NQL API** - リモートアクション実行の結果を取得します。                                                                                                                                                                                                                                                                             |
| <ol start="6"><li><strong>問題のプロアクティブな識別</strong></li></ol>   | <p><a href="/pages/N3zXGk4jt3sLPHSNnmmB">データエクスポーター</a>（オプション） - 問題の影響を受ける可能性のある全ユーザーおよびデバイスをデータレイクのようなソリューションへエクスポートします。<br>これにより、従業員へのプロアクティブな問題のコミュニケーションが可能になります。</p><p><br><a href="/pages/QwBLP35f5O536AeFOfnR">Webhook</a>（オプション）—特定のイベントまたはアラートがトリガーされたときに通知を送り、チャットボットが影響を受けた従業員を積極的に特定するのを可能にします。</p> |

***

## チャットボット統合をサポートするためのNexthink API機能の構成 <a href="#integratingchatbotswithnexthink-prerequisites" id="integratingchatbotswithnexthink-prerequisites"></a>

チャットボットのサービス層内でAPIコールを実装する前に、Nexthinkで次の予備設定を行ってください。詳しくは、Nexthinkの[管理者](https://docs.nexthink.com/platform/ja/configuring_nexthink/configuring-your-platform/administration/account-management/roles/#roles-administration)としての設定を確認してください。

{% stepper %}
{% step %}
**特定のチャットボット向けに API 連携を計画する**

1. あなたのAPI使用がNexthinkのAPI使用制限に準拠していることを確認してください。 詳細については、[Nexthink開発者ポータル](https://developer.nexthink.com)ドキュメントを参照してください。
2. チャットボットソリューションとNexthink間でユーザーをマッチさせる方法をマッピングします。
   * Nexthink Collectorは、ユーザー名、SID、およびUPN（有効化されている場合）を収集します。
   * [Microsoft Entra ID 用コネクター](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/inbound-connectors/connector-for-microsoft-entra-id-azure-ad.md)は、Nexthinkインスタンスで有効にされている場合、ユーザーのメールを含む追加のデータマッピングを提供します。
     {% endstep %}

{% step %}
**Nexthink で API 資格情報を設定する**

1. [APIクレデンシャル](https://developer.nexthink.com/docs/api/api-credentials)を設定して、チャットボットからあなたのNexthinkテナントとアウトバウンド接続（データエクスポーターおよびウェブフック）に対する呼び出しを保護してください。\
   以下の権限がAPIクレデンシャルで有効化されていることを確認してください:
   * **NQL API**
   * **Remote Actions API**
2. 外部統合を利用する予定がある場合は、オプションで[コネクター資格情報](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/connector-credentials.md)を設定してください。

<figure><img src="/files/ZGYOEXrgYLJQXY5LGMWI" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**API 呼び出しのために、コンテキストデータ取得および是正アクション用の Nexthink コンテンツを作成する**

1. [NQLクエリを作成](/platform/ja/solutions/chatbots/integrating-chatbots-with-nexthink/chatbot-use-cases.md#creating-nql-api-queries)して、チャットボットからの**NQL API**呼び出しを定義します。 通常、要求されるクエリには以下が含まれます:
   * 特定のユーザーのデバイスおよび基本情報を取得するためのクエリ。
   * 特定のユーザーまたはデバイスのためのアドホック診断情報を取得するためのクエリ。
   * リモートアクションのステータスと出力を取得するためのクエリ。
2. **API**トリガー用に構成されたリモートアクションを作成します。 代替手段として、使用および適応できるNexthinkライブラリからプリコンフィグされた多数のリモートアクションをインストールします。
   {% endstep %}
   {% endstepper %}

***

## プリビルトコンテンツを使用して、チャットボットのサービスレイヤー内でREST APIコールを実装します

上記に列挙されたすべての必要なNexthinkのAPI機能を構成した後、[エンドツーエンドのユースケース](/platform/ja/solutions/chatbots/integrating-chatbots-with-nexthink/chatbot-use-cases.md#step-3-implement-api-calls-within-the-chatbots-service-layer)で詳述されたように、チャットボットのサービスレイヤー内にREST APIコールを実装します。

開始するために、以下にサンプルクエリとあらかじめ作成されたコンテンツを用意しました。チャットボットのオーケストレーションとロジックを設定する際にこれを使用および適応させてください。

{% hint style="info" %}
これらの例をチャットボット設計に似た方式で実装し、デバイス名を事前に特定していることを前提として、参照されたユースケースに基づいた設計を採用します。
{% endhint %}

### チャットボットタスクのための一般的なNQLクエリのサンプル <a href="#chatbotusecases-generalqueries" id="chatbotusecases-generalqueries"></a>

REST APIを使用してチャットボットの編成とロジックを設定する一環として、Nexthinkとのすべてのチャットボット統合で役立つ、次の2つの基本タスクを実行するための一般的なクエリを設定する必要があります:

<details>

<summary>ユーザーのデバイスを取得するためのNQLクエリ</summary>

クエリID: #get\_device\_basic\_infos - `username`に基づくマッチング

```
devices during past 7d
| with session.events past 7d
| where user.name == $username
| list collector.uid, device.name, 
  operating_system.platform, operating_system.name, 
  hardware.type, hardware.manufacturer, last_seen
| sort last_seen desc
```

\| where user.name == $username\`のwhere節を代替アプローチで使用するために調整することができます。例えば、

* ユーザーUPNを知っている場合: `| where user.upn == $upn`（CollectorレベルでUPNを有効化する必要があります）
* ユーザーメールアドレスを知っている場合: `| where user.ad.email_address == $email`（Azure ADコネクタを有効にしてメールフィールドを同期する必要があります）
* デバイス名を知っている場合: `| where device.name == $device_name`

タイムフレームを調整したい場合は、ユーザーがアクティブであったデバイスを考慮する期間を7日以外に変更できます。

両方の `過去7d` 節を希望のタイムフレームに置き換え、Nexthinkテナントの最大データ保持期間を超えないようにします。

</details>

<details>

<summary>リメディエーションリモートアクションのステータスと出力を取得するためのNQLクエリ</summary>

クエリID: #get\_remote\_action\_result

```
remote_action.executions past 24h
| where request_id == $request_id
| list request_id, device.name, remote_action.name, 
  status, status_details, outputs
```

</details>

### 一般的な問題に対応するためのチャットボットのREST APIコールを実装するためのプリビルトコンテンツ <a href="#chatbotusecases-microsoftoutlookissues" id="chatbotusecases-microsoftoutlookissues"></a>

プリビルトコンテンツ—診断、リモートアクション、および修復ロジックを用いるNQLクエリを含む—を使用して、以下の一般的な問題を診断し、解決し、修正が確認されたかどうかを構成するチャットボット統合を設定します:

<details>

<summary><strong>Microsoft Outlook</strong>の問題への対応</summary>

従業員のMicrosoft Outlookの不具合を引き起こす問題を診断します。

<table><thead><tr><th width="170">タイプ</th><th>コンテンツ</th></tr></thead><tbody><tr><td>プラットフォーム</td><td>Microsoft Windows</td></tr><tr><td>データ収集リモートアクション</td><td><p>データ収集リモートアクションのスケジュール:</p><ul><li>Microsoft Outlookのオンライン取得</li><li>Microsoft Outlookプラグインのクラッシュ詳細を取得</li></ul></td></tr><tr><td>NQL クエリー</td><td><p>クエリID: #diagnose_outlook_issues</p><pre><code>devices
| where device.name == $device_name
| include package.installed_packages
| where package.name in ["Microsoft Office", "Microsoft 365"]
| where package.version != "16.*"
| compute outdated_office_packages = package.name.count()
| list collector.uid, device.name,
  remote_action.get_outlook_plugin_crash_details_windows.execution.outputs.CrashedPluginList,
  remote_action.get_outlook_online_windows.execution.outputs.IsOnline,
  remote_action.get_outlook_online_windows.execution.status,
  boot.days_since_last_full_boot, outdated_office_packages
</code></pre></td></tr><tr><td>リメディエーションリスト</td><td><ol><li><strong>IF</strong> <code>remote_action.get_outlook_online_windows.execution.outputs.IsOnline</code> = <code>"No"</code> および <code>remote_action.get_outlook_online_windows.execution.status</code> = <code>"success"</code><br><strong>THEN</strong> 修復リモートアクション <strong>Outlookをオンラインにする</strong>を実行</li><li><strong>IF</strong> <code>remote_action.get_outlook_plugin_crash_details_windows.execution.outputs.CrashedPluginList</code> != <code>"["-"]"</code><br><strong>THEN</strong> 修復リモートアクション <strong>Outlookプラグインを設定する</strong>を実行</li><li><strong>IF</strong> <code>device.boot.days_since_last_full_boot</code> > <code>10</code><br><strong>THEN</strong> 従業員にマシンの再起動を推奨します。</li><li><strong>IF</strong> <code>outdated_office_packages</code> = <code>"1"</code><br><strong>THEN</strong> 修復リモートアクション <strong>Office 365の修復</strong>を実行</li><li>一般的な修復方法: 修復リモートアクション <strong>Outlook OSTの問題を修理する</strong>を実行</li></ol></td></tr></tbody></table>

</details>

<details>

<summary>Microsoft OneDriveの問題に対処</summary>

Microsoft OneDriveに関連する問題を診断し、問題が検出された場合にOneDriveを修復します。

<table><thead><tr><th width="169">タイプ</th><th>コンテンツ</th></tr></thead><tbody><tr><td>プラットフォーム</td><td>Microsoft Windows</td></tr><tr><td>データ収集リモートアクション</td><td><p>データ収集リモートアクションのスケジュール:</p><ul><li>OneDriveのステータスを取得</li></ul></td></tr><tr><td>NQL クエリー</td><td><p>クエリID: #diagnose_onedrive_issues</p><pre><code>devices
| where device.name == $device_name
| list collector.uid, device.name,
  remote_action.get_onedrive_status.execution.outputs.OneDriveStatus
</code></pre></td></tr><tr><td>修復のリスト</td><td><ol><li><p><strong>IF</strong> <code>remote_action.get_onedrive_status.execution.outputs.OneDriveStatus</code>が次のいずれかを含む場合:</p><ol><li><code>OneDriveはインストールされていません</code></li><li><code>OneDriveはインストールされているが実行されていません</code></li><li><code>OneDriveの環境変数がありません</code></li><li><code>OneDriveフォルダが存在しない</code></li></ol></li></ol><p><strong>THEN</strong> 修復リモートアクション <strong>OneDriveを修理する</strong>を実行</p></td></tr></tbody></table>

</details>

<details>

<summary>PCの速度問題に対処</summary>

エンドポイントでスローダウンを引き起こす典型的な問題の診断を行います。

<table><thead><tr><th width="170">タイプ</th><th>コンテンツ</th></tr></thead><tbody><tr><td>プラットフォーム</td><td>Microsoft Windows</td></tr><tr><td>データ収集リモートアクション</td><td><p>データ収集リモートアクションのスケジュール:</p><ul><li>GPOスタートアップの影響を取得</li><li>スタートアップの影響を取得</li></ul></td></tr><tr><td>NQL クエリー</td><td><p>クエリID: #diagnose_slow_pc_issues</p><pre><code>devices during past 7d 
| where name == $device_name
| include device_performance.events during past 24h
| compute free_space = system_drive_free_space.avg() / 1000000000
| include package.installed_packages
| where package.name in ["*Microsoft Office*", "*Microsoft 365*"]
| where package.version != "16.*"
| compute outdated_office_packages = package.name.count()
| list collector.uid, device.name, free_space,
  boot.days_since_last_full_boot,
  outdated_office_packages,
  remote_action.get_startup_impact_windows.execution.outputs.HighImpactCount,
  remote_action.get_gpo_startup_impact_windows.execution.outputs.UserGpoAppliedTimeInSeconds,
  remote_action.get_gpo_startup_impact_windows.execution.outputs.UserGpoDCDiscoveryInSeconds
</code></pre></td></tr><tr><td>修復のリスト</td><td><ol><li><strong>IF</strong> <code>device.boot.days_since_last_full_boot</code> > <code>10</code><br><strong>THEN</strong> 従業員にマシンの再起動を推奨します。</li><li><strong>IF</strong> <code>free_space_GB</code> &#x3C;= <code>6</code><br><strong>THEN</strong> リモートアクション修復を実行 <strong>ディスククリーンアップ</strong></li><li><strong>IF</strong> <code>remote_action.get_startup_impact_windows.execution.outputs.HighImpactCount</code> > 0<br><strong>THEN</strong> 修復リモートアクション <strong>スタートアップメニューからのアプリケーションを無効化する</strong>を実行し、<code>remote_action.get_startup_impact_windows.execution.outputs.HighImpactApplications</code>の値を使用して高影響のアプリケーションを無効化します</li><li><strong>IF</strong> <code>remote_action.get_gpo_startup_impact_windows.execution.outputs.UserGpoAppliedTimeInSeconds</code> + <code>remote_action.get_gpo_startup_impact_windows.execution.outputs.UserGpoDCDiscoveryInSeconds</code> > 10<br><strong>THEN</strong> 修復リモートアクション <strong>グループポリシー設定を更新する</strong>を実行します</li><li><strong>IF</strong> <code>outdated_office_packages</code> = <code>"1"</code><br><strong>THEN</strong> 修復リモートアクション <strong>Office 365の修復</strong>を実行</li></ol></td></tr></tbody></table>

</details>

{% hint style="warning" %}
上記のすべてのリモートアクションは[Nexthinkライブラリ](/platform/ja/user-guide/nexthink-library.md)からインストールされ、事前の設定が必要です:

* データ収集リモートアクションは、アクティブな**スケジュール**タイプのトリガーと、必要な頻度に応じて毎時または毎日の収集スケジュールを設定している必要があります。
* リメディエーションリモートアクションはアクティブな**API**タイプのトリガーを持っている必要があります。
  {% endhint %}

***

関連トピック

* [ユースケース: チャットボットによるディスク問題の改善](/platform/ja/solutions/chatbots/integrating-chatbots-with-nexthink/chatbot-use-cases.md)
* [ワークフローの作成](/platform/ja/user-guide/workflows/creating-workflows.md#optionally-make-the-workflow-available-in-nexthink-spark)


---

# 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/solutions/chatbots/integrating-chatbots-with-nexthink.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.
