# AmplifyからServiceNowへの更新

このページでは、[Webhooks](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/webhooks.md)を使用してServiceNowのチケットログを自動更新する方法を、[Amplify](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/deploying-nexthink-in-non-vdi-environment/configure-amplify.md)から実行されるリモートアクションやワークフローを通じて説明します。

構成に基づいて、自動更新は次の場合に発生します。

* リモートアクションやワークフローがトリガーされた場合。
* リモートアクションやワークフローが完了した場合。

{% hint style="info" %}
このページのコードサンプルは、次の方法でServiceNowのやり取りにも適用できます:

Webhookの**NQL条件**で`external_source== "SNOW-Incident"`を`external_source== "SNOW-Interaction"`に置き換えます。

Webhookの**リソース**フィールドで`/table/incident/`を`/table/interaction/`に置き換えます。
{% endhint %}

## ServiceNow用のコネクター認証情報を構成する

[コネクター認証情報](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/connector-credentials.md)の構成ページから:

1. **HTTPS**オプションを**プロトコル**のドロップダウンから選択します。
2. インスタンスのURLルート`https://<instancename>.service-now.com/`を**URLアドレス**フィールドに貼り付けます。
   * 他のURL例については[connector credential](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/connector-credentials.md#connectorcredentials-connectorcredentialsforhttpshttpsprotocol)文書を参照してください。

```
https://XXXXXXXXXX.service-now.com/
```

3. **OAuth 2.0 - クライアント認証情報**オプションを**認証**ドロップダウンから選択します
   * **アクセストークンURL**、**クライアントID**、**クライアントシークレット**、**スコープ**フィールドを[connector credential](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/connector-credentials.md#connectorcredentials-supportedauthorizationmechanismsauthorizationtype)の説明に従って記入します。
4. 認証情報を**保存**します。

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

## Webhookの構成

次のセクションでは、ServiceNowを更新するための2つのシナリオについて詳しく説明します。 各シナリオの手順は非常に似ており、リモートアクションとワークフローのNQL条件とペイロードがシナリオごとに異なります。

### リモートアクションやワークフローがトリガーされたときのServiceNow更新

NexthinkでリモートアクションやワークフローがトリガーされたときにServiceNowのインシデントチケットログを自動的に更新するWebhookを設定します。

最初にWebhook用の[コネクター認証情報](#updatingservicenowfromamplify-configuringwebhookstoupdateservicenowwhenaremoteactionistriggered)をセットアップしてください。

1. [Webhook構成ページ](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/webhooks/managing-webhooks.md)から、次の**NQL条件**を挿入します。 より多くの例については[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#configuringwebhooknqlconditions-validnqlconditionsexamplesforalert-relatedwebhooksnqlconditionexampl)文書を参照してください。
   * NQL条件を入力した後、システムは**ペイロード**の[許可されるプレースホルダー](/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-usingdatamodelvariablesasplaceholdersinthepayloa)をリストします。

<table data-header-hidden><thead><tr><th width="185"></th><th></th></tr></thead><tbody><tr><td>リモートアクションの<br>NQL条件</td><td><pre><code>remote_action.executions
| where internal_source == "Amplify" 
  And external_reference != "undefined" 
  And external_source == "SNOW-Incident" 
  And status == in_progress 
  and remote_action.nql_id != "undefined"
| list 
  remote_action.name , 
  remote_action.execution.request_time, 
  remote_action.execution.account_name, 
  remote_action.execution.external_reference
</code></pre></td></tr><tr><td>ワークフローの<br>NQL条件</td><td><pre><code>workflow.executions
| where internal_source == "Amplify" 
  And external_reference != "undefined" 
  And external_source == "SNOW-Incident" 
  And device.name != null 
  And user.name != null
  And outcome == null
  And status == in_progress 
  and workflow.nql_id != "undefined"
| list 
  workflow.name , 
  workflow.execution.request_time,  
  workflow.execution.external_reference
</code></pre></td></tr></tbody></table>

{% hint style="info" %}
ワークフローとリモートアクションの処理中に、複数のイベントが送信され、詳細とともに元のイベントが更新されます。 上記のクエリと使用される条件により、最も完全なイベントのみがServiceNowを更新するために使用されます。
{% endhint %}

2. このWebhookに対して、以前に設定した[コネクタの資格情報](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/connector-credentials.md)を選択してください。
3. **Method**のドロップダウンからPATCHオプションを選択してください。
4. **Resource**フィールドに次のAPIを挿入してください。

<table data-header-hidden><thead><tr><th width="186"></th><th></th></tr></thead><tbody><tr><td>リモートアクションのためのリソースAPI</td><td><pre><code>api/now/v1/table/incident/{{remote_action.execution.external_reference}}
</code></pre></td></tr><tr><td>ワークフローのためのリソースAPI</td><td><pre><code>api/now/v1/table/incident/{{workflow.execution.external_reference}}
</code></pre></td></tr></tbody></table>

`{{remote_action.execution.external_reference}}`と`{{workflow.execution.external_reference}}`は、Amplify拡張機能からリモートアクションまたはワークフローがトリガーされたときに自動的にServiceNowのチケット参照で埋められるプレースホルダーです。

詳しくは、このページの一番下にある[F.A.Q](#updatingservicenowfromamplify-f.a.q)セクションを参照してください。

5. **Payload**を挿入し、以下のメッセージ例を使用してください：

<table data-header-hidden><thead><tr><th width="186"></th><th></th></tr></thead><tbody><tr><td>リモートアクションのためのペイロード</td><td><pre><code>{"work_notes": "このチケットのためのリモートアクション{{remote_action.remote_action.name}}が、Amplifyユーザー{{remote_action.execution.account_name}}から{{remote_action.execution.request_time}}にトリガーされました"}
</code></pre></td></tr><tr><td>ワークフローのためのペイロード</td><td><pre><code>{"work_notes": "このチケットのためのワークフロー{{workflow.workflow.name}}が、Amplifyから{{workflow.execution.request_time}}にトリガーされました"}
</code></pre></td></tr></tbody></table>

6. 初めての設定の際には、テストせずに**webhookを保存**し、[Amplify](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/deploying-nexthink-in-non-vdi-environment/configure-amplify.md#amplify-recordingremoteactionsinathird-partyitsupporttool-servicenowamplifyservicenow)の文書を参照して、ServiceNowからAmplifyでリモートアクションやワークフローを実行し、webhookが正しく動作するか確認してください。
   * **Send test**は、AmplifyのリモートアクションまたはワークフローがServiceNowでトリガーされ、**Resource**のプレースホルダー`{{....}}`のインシデント参照値を生成するまで、Webhookを正常にテストすることはできません。
   * ServiceNow から手動で `remote_action.execution.external_reference` または `workflow.execution.external_reference` の値を取得し、Webhook の設定をテストするには、[F.A.Q](#how-do-i-manually-retrieve-the-servicenow-ticket-remote_action.execution.external_reference-value-to) セクションを参照してください。

{% hint style="info" %}
NexthinkインスタンスとWebアプリケーションを統合し、Registry経由で設定の詳細を展開するためのAmplifyの設定方法については、[Amplifyのインストールと設定ガイド](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/deploying-nexthink-in-non-vdi-environment/configure-amplify/installation-and-configuration.md)を参照してください。
{% endhint %}

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

### リモートアクションまたはワークフローが完了した時にServiceNowを更新するためのWebhookを設定します。

Nexthink で Webhook を設定し、リモートアクションまたはワークフローの完了結果の詳細で ServiceNow のインシデントチケットログを自動的に更新します。

Webhookのために[コネクタの資格情報](#updatingservicenowfromamplify-configuringwebhookstoupdateservicenowwhenaremoteactionistriggered)を最初に設定しておくことを忘れないでください。

1. [Webhook設定ページ](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/webhooks/managing-webhooks.md)から、以下の**NQL条件**を挿入してください。 Webhook NQL 条件の設定については、[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#configuringwebhooknqlconditions-validnqlconditionsexamplesforalert-relatedwebhooksnqlconditionexampl) のドキュメントを参照してください。
   * NQL条件を入力すると、システムは**Payload**の[許可されたプレースホルダー](/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-usingdatamodelvariablesasplaceholdersinthepayloa)をリストアップします。

<table data-header-hidden><thead><tr><th width="194"></th><th></th></tr></thead><tbody><tr><td>リモートアクションのためのNQL条件</td><td><pre><code>remote_action.executions
| where internal_source == "Amplify" 
  And external_reference != "undefined" 
  And external_source == "SNOW-Incident" 
  And status in [failure, success , expired] 
  and remote_action.nql_id != "undefined"
| list remote_action.name , 
  remote_action.execution.request_time, 
  remote_action.execution.time, 
  remote_action.execution.status, 
  remote_action.execution.status_details, 
  remote_action.execution.inputs, 
  remote_action.execution.outputs, 
  remote_action.execution.account_name, 
  remote_action.execution.external_reference
</code></pre></td></tr><tr><td>ワークフローのためのNQL条件</td><td><pre><code>
workflow.executions
| where internal_source == "Amplify"
 And external_reference != "undefined" 
 And external_source == "SNOW-Incident" 
 And status in [failure, success, expired, cancelled] 
 And workflow.nql_id != "undefined"
| list workflow.name ,
 workflow.execution.request_time, 
 workflow.execution.time, 
 workflow.execution.status, 
 workflow.execution.status_details, 
 workflow.execution.inputs, 
 workflow.execution.outcome, 
 workflow.execution.external_reference
</code></pre></td></tr></tbody></table>

2. このWebhookに対して、以前に設定した[コネクタの資格情報](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/connector-credentials.md)を選択してください。
3. **Method**のドロップダウンからPATCHオプションを選択してください。
4. **Resource**フィールドに次のAPIを挿入してください。

<table data-header-hidden><thead><tr><th width="186"></th><th></th></tr></thead><tbody><tr><td>リモートアクションのためのリソースAPI</td><td><pre><code>api/now/v1/table/incident/{{remote_action.execution.external_reference}}
</code></pre></td></tr><tr><td>ワークフローのためのリソースAPI</td><td><pre><code>api/now/v1/table/incident/{{workflow.execution.external_reference}}
</code></pre></td></tr></tbody></table>

`{{remote_action.execution.external_reference}}`と`{{workflow.execution.external_reference}}`は、Amplify拡張機能からリモートアクションまたはワークフローがトリガーされたときに自動的にServiceNowのチケット参照で埋められるプレースホルダーです。

詳しくは、このページの一番下にある[F.A.Q](#updatingservicenowfromamplify-f.a.q)セクションを参照してください。

5. **Payload**を挿入し、以下のメッセージ例を使用してください：

<table data-header-hidden><thead><tr><th width="186"></th><th></th></tr></thead><tbody><tr><td>リモートアクションのためのペイロード</td><td><pre><code>{"work_notes":"Amplifyユーザー{{remote_action.execution.account_name}}によってこのチケットのためにトリガーされたリモートアクション{{remote_action.remote_action.name}}のステータスは以下の通りです。\nリクエスト時間：{{remote_action.execution.request_time}} \n実行時間：{{remote_action.execution.time}} \nステータス：{{remote_action.execution.status}} \nステータス詳細：{{remote_action.execution.status_details}} \n入力：{{remote_action.execution.inputs.as(format = text)}} \n出力：{{remote_action.execution.outputs.as(format = text)}}"}
</code></pre></td></tr><tr><td>ワークフローのためのペイロード</td><td><pre><code>{ "work_notes": "Amplifyからこのチケットのためにトリガーされたワークフロー{{workflow.workflow.name}}のステータスは以下の通りです。リクエスト時間：{{workflow.execution.request_time}} 実行時間：{{workflow.execution.time}} ステータス：{{workflow.execution.status}} ステータス詳細：{{workflow.execution.status_details}} 入力：{{workflow.execution.inputs}} 結果：{{workflow.execution.outcome"}}}
</code></pre></td></tr></tbody></table>

6. 初めての設定の際には、テストせずに**webhookを保存**し、[Amplify](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/deploying-nexthink-in-non-vdi-environment/configure-amplify.md#amplify-recordingremoteactionsinathird-partyitsupporttool-servicenowamplifyservicenow)の文書を参照して、ServiceNowからAmplifyにリモートアクションを実行し、webhookが正しく動作するか確認してください：
   * **Send test**は、ServiceNowでAmplifyからのリモートアクションをトリガーするまで、Webhookを正常にテストすることはできません。このとき、**Resource**プレースホルダー`{{...}}`のインシデント参照値が生成されます。
   * ServiceNowから手動で`remote_action.execution.external_reference`または`workflow.execution.external_reference`の値を取得し、Webhook設定をテストするには、[F.A.Q](#how-do-i-manually-retrieve-the-servicenow-ticket-remote_action.execution.external_reference-value-to)セクションを参照してください。

{% hint style="info" %}
NexthinkインスタンスとWebアプリケーションを統合し、Registryを通じて設定の詳細を展開する方法については、[Amplifyのインストールと設定ガイド](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/deploying-nexthink-in-non-vdi-environment/configure-amplify/installation-and-configuration.md)を参照してください。
{% endhint %}

***

## F.A.Q

#### ServiceNowでAmplifyがインシデントまたは対話ログを更新しているかどうかを確認するにはどうすればよいですか？

[Amplify](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/deploying-nexthink-in-non-vdi-environment/configure-amplify.md)の文書は、サービスNowログにAmplify拡張を使用してリモートアクションやワークフローを登録する方法を説明しています。 つまり、このページに記載されているWebhook設定に従った後のことです。

#### **Resource**フィールド内の`{{remote_action.execution.external_reference}}`と`{{workflow.execution.external_reference}}`プレースホルダーの値は何ですか？

Amplify Webhookのプロセスは、ServiceNowの提供する一連の指定されたURLを読み込んで、チケットの`sys_id`とタイプ（インシデントまたは対話）を見つけるために照合することで、ServiceNow URLから`external_reference`値を取得することにあります。

次に、Amplifyはこの`external_reference`値を`remote_action`または`workflow`情報と共にNexthinkプラットフォームに送信し、Webhookはこれらの値を使用してWebhookの**Resource**プレースホルダー（例：`{{remote_action.execution.external_reference}}`）を置き換えます。

#### Webhook設定をテストするためのServiceNow `remote_action.execution.external_reference`値の手動取得方法は？

ServiceNowのブラウザページからAmplifyでリモートアクションを実行した後：

1. ServiceNowのインシデントまたは対話URLから`external_reference`を取得します。

* ワークスペースビューでのURL例：

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

* クラシックビューでのURL例：

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

Nexthinkの[Webhook設定](#updatingservicenowfromamplify-configuringwebhookstoupdateservicenowwhenaremoteactionistriggered-1)ページから：

2. ServiceNow URLから手動で取得した`external_reference`を使って、**Resource**プレースホルダー`{{remote_action.execution.external_reference}}`を置き換えます。 たとえば：

```
api/now/v1/table/incident/32dd789083xxxxxxxxxxxxxxxxxxxxx
```

3. **Webhook設定**をチェックするためにテストを送信してください。 テストが成功したことを確認した後、正しいプレースホルダーで**Resource**を置き換えてWebhookを保存します。

```
api/now/v1/table/incident/{{remote_action.execution.external_reference}}
```

#### NexthinkプラットフォームでServiceNowのインシデントまたは対話`sys_id`を確認する方法は？

このページに記載されているWebhook設定に従い、ServiceNowでAmplify拡張機能を使用してリモートアクションを実行した後、Nexthinkのインベスティゲーションページで対応するNQLクエリを実行してチケット`sys_id`を取得します。

**External reference**の下で`sys_id`、**External source**の下でチケットタイプ（`external_source== "SNOW-Incident"`または`external_source== "SNOW-Interaction"`）を見つけます。

<figure><img src="/files/FkHOXhQmlvMELoYtaZMd" alt="Checking ServiceNow incident or interaction ID in the Nexthink platform."><figcaption></figcaption></figure>

***

関連トピック

* [Amplify](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/deploying-nexthink-in-non-vdi-environment/configure-amplify.md)
* [ServiceNowエージェントワークスペース用Amplifyの設定](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/deploying-nexthink-in-non-vdi-environment/configure-amplify/installation-and-configuration/integrating-amplify-with-web-applications/configuring-amplify-for-servicenow-agent-workspace.md)
* [ServiceNowオペレーションズワークスペース用Amplifyの設定](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/deploying-nexthink-in-non-vdi-environment/configure-amplify/installation-and-configuration/integrating-amplify-with-web-applications/configuring-amplify-for-servicenow-operations-workspace.md)
* [コネクタ資格情報](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/connector-credentials.md)
* [ServiceNow のインシデント作成](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/webhooks/webhook-use-cases-setup/creating-an-incident-in-servicenow.md)
* [Amplifyのインストールと設定](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/deploying-nexthink-in-non-vdi-environment/configure-amplify/installation-and-configuration.md)
* [Webhookの管理](/platform/ja/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/webhooks/managing-webhooks.md)
* [Webhookフィールドの設定: Method、Resource、およびPayload](/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)
* [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)


---

# 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/updating-servicenow-from-amplify.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.
