> For the complete documentation index, see [llms.txt](https://docs.nexthink.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nexthink.com/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/integrating-spark-with-existing-agents/connecting-spark-to-copilot-studio-agent.md).

# Connecting Spark to Copilot Studio agent

{% hint style="warning" %}
This documentation references external sources. Nexthink does not have control over the accuracy of third-party documentation, nor any external updates or changes that might create inconsistencies with the information presented on this page. Please report any errors or inconsistencies to [Nexthink Support](https://support.nexthink.com/).
{% endhint %}

Connect your Microsoft Copilot Studio agent to Nexthink Spark, so employees can get their IT problems resolved by Spark without leaving the Copilot Studio agent they already use.

The integration uses the **Nexthink Spark Bridge** solution, which includes a Copilot Studio topic (**Ask Spark**), Power Automate flows and Dataverse tables.

This guide explains how the integration works, then walks you through preparing the accounts and secrets, downloading and importing the solution, connecting its components, adding Spark to your agent, giving your agent the right instructions, and testing the result in your own Microsoft tenant.

{% hint style="warning" %}
This is a reference integration. You deploy and operate it in your own Microsoft tenant; Nexthink does not host or operate any part of it. Review it against security, licensing and governance requirements before rolling it out. You are free to adapt and improve it in any way that suits your organization.
{% endhint %}

***

## How it works

When an employee asks a question, your agent sends it to Spark. Spark doesn't answer straight away: it works on the question, then sends its answer back to your tenant a few seconds later. The bridge waits for that answer and shows it to the employee.

Power Automate flows expose a webhook that Spark calls when its answer is ready. The **Wait for reply** flow pauses until that happens, then picks up the answer and returns it to the user.

```mermaid
flowchart LR
    subgraph Tenant["CUSTOMER MICROSOFT TENANT"]
        TenantPadL[" "]
        Employee["<b>Employee</b><br/>Teams or web chat"]
        subgraph Env["Power Platform environment"]
        EnvPadL[" "]
            Agent["<b>Your Copilot Studio agent</b>"]
            Bridge["<b>Nexthink Spark Bridge</b><br/>Power Platform solution<br/>in your environment"]
        EnvPadR[" "]
        end
        TenantPadR[" "]
    end

    subgraph Nexthink["NEXTHINK"]
        Spark["<b>Nexthink Spark</b>"]
    end
    TenantPadL --- Env
    Employee -- "asks" --> Agent
    Agent -- "answers" --> Employee
    Agent <--> Bridge
    Bridge -- "asks" --> Spark
    Spark -- "answers" --> Bridge
    
    classDef person fill:#ffffff,stroke:#8c8c8c,color:#1f2937,stroke-width:1px
    classDef box fill:#ffffff,stroke:#4a78b5,color:#1f2937,stroke-width:1.5px
    classDef box_b fill:#3194F7,color:white
    classDef nx fill:#EEF3F7,color:#1f2937

    classDef spacer fill:none,stroke:none,color:none

    class Employee person
    class Agent box
    class Bridge box_b
    class Spark nx
    class TenantPadL,TenantPadR,EnvPadL,EnvPadR spacer

    style Tenant fill:#e9f1fb,stroke:#8fb0d9,stroke-width:1px,color:#1f3b5c
    style Env fill:#f3f8fe,stroke:#7d9cc4,stroke-dasharray:6 4,color:#2b5a8f
    style Nexthink fill:#1046A8,color:#fff

    linkStyle default stroke:#555555,stroke-width:1.2px
    linkStyle 0 stroke:none
```

{% hint style="info" %}
Employees can send text and one PNG or JPG screenshot per message. Answers are text only.
{% endhint %}

## Nexthink Spark Bridge components

The table below lists all Nexthink Spark Bridge components and explains their role in the integration workflow.

| Component       | Type        | Started by                | What it does                                                                                                                                                                                                                                                  |
| --------------- | ----------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Ask Spark       | Agent topic | Your Copilot Studio agent | Calls **Send message** to send the employee's question to Spark, then calls **Wait for reply** to get the answer, and shows it to the employee. Spark can take a while to answer, so it calls **Wait for reply** up to 4 times (configurable), then gives up. |
| Send message    | Agent flow  | Ask Spark                 | Sends the question to Spark, along with the **Receive reply** webhook URL so Spark knows where to send its answer.                                                                                                                                            |
| Wait for reply  | Agent flow  | Ask Spark                 | Calls **Register waiter**, then waits up to 70 seconds for **Receive reply** to say the answer has arrived. Passes the answer back to **Ask Spark**. If there's no answer yet, **Ask Spark** calls this flow again.                                           |
| Register waiter | Cloud flow  | Wait for reply            | Saves a one-time webhook URL for **Wait for reply**. **Receive reply** calls this URL to tell **Wait for reply** the answer has arrived.                                                                                                                      |
| Receive reply   | Cloud flow  | Spark                     | Called by Spark through its webhook URL. Saves the answer, then calls the one-time webhook URL saved by **Register waiter** to tell **Wait for reply** it's ready.                                                                                            |

## Prerequisites

### From Nexthink

* A Nexthink license that includes Spark.
* Admin access to Nexthink Infinity, to create API credentials and third party credentials.
* Download the **Nexthink Spark Bridge** package from [Nexthink Infinity Release Notes > Downloads](https://edocs.nexthink.com/nexthink-infinity/infinity-release-notes#nexthink-microsoft-365-apps). Save it somewhere you can reach from your browser. Don't unzip it. You will upload the .zip file as is.

### From Microsoft

* A Power Platform environment with Dataverse, where you have the System Administrator role.
* An existing standard harness agent in Copilot Studio (created as **Agent (Standard)**). The Nexthink Spark Bridge needs a standard agent because it runs as a topic.
* The agent signs employees in with Microsoft (**Settings** > **Security** > **Authentication** > **Authenticate with Microsoft**), so the bridge knows who is sending messages.
* Permission to create app registrations in Microsoft Entra ID.
* An Azure subscription with permission to create an Azure Key Vault and assign roles on it (for example, Owner or User Access Administrator).
* Your data policy must allow these four connectors in the same group: HTTP, HTTP Request, HTTP Webhook, and Microsoft Dataverse.
* Premium licenses for the two cloud flows (Register waiter and Receive reply), which use the HTTP, HTTP Request, and Dataverse premium connectors.

## Integration procedure

The following section outlines the integration procedure using Nexthink Spark Bridge. Note that this solution is a starting point, which you can adapt as needed.

Record the values marked as needed in later steps securely.

### Step 1: Prepare the accounts and secrets

#### Create the Spark API credential in Nexthink Infinity

1. In Nexthink Infinity, go to **Administration** > **API credentials** > **New OAuth client credentials**.
2. Give it a name and select the **Spark API** permission. Save.
3. Copy the **client ID** and **client secret**. They're shown only once.
4. Note your **token URL**. It isn't shown with the credentials; it follows this format, using your instance name and region: `https://[instance]-login.[region].nexthink.cloud/oauth2/default/v1/token`
5. Note your **Spark A2A Endpoint**: your Spark A2A address plus `/v1/message:send`, for example `https://[instance].api.[region].nexthink.cloud/api/spark/a2a/v1/message:send`

{% hint style="success" icon="pencil" %}
At the end of this step, make sure you have recorded the following information for use in the next steps:

* **Client ID** and **client secret** from your Nexthink Infinity API credentials
* **Token URL**
* **Spark A2A endpoint URL**
  {% endhint %}

#### Create the callback app registration in Entra ID

Spark uses this app to sign in when it sends answers back. It has no other permissions.

1. In the Azure portal, go to **Microsoft Entra ID** > **App registrations** > **New registration**. Name: `spark-bridge-callback`. Single tenant. No redirect URI.
2. Add a client secret. Note the **client ID**, the **secret** and your **tenant ID** (shown on the registration's Overview page).
3. Open the app under **Enterprise applications** (not App registrations). Note its **Object ID**. You enter it at import, and only this app can then send answers to your tenant.

#### Choose how the bridge signs in to Dataverse

| Option                            | Use it for       |
| --------------------------------- | ---------------- |
| A. App registration (recommended) | Production       |
| B. Your own account               | Quick tests only |

**Option A: app registration**

1. In **Microsoft Entra ID** > **App registrations**, create a registration, for example `spark-bridge-dataverse`. Choose single tenant, with no redirect URI. Add a client secret. Note the **client ID** and the **secret**.
2. In the Power Platform admin center, open your environment > **Settings** > **Users + permissions** > **Application users** > **+ New app user**. Pick that app and a security role that can read and write the two Spark Bridge tables. System Administrator works; a custom role is tighter.
3. At import ([#step-2-import-the-solution](#step-2-import-the-solution "mention")), create the Dataverse connection with **Authentication Type** `Service Principal`, and enter your tenant ID ([#create-the-callback-app-registration-entra-id](#create-the-callback-app-registration-entra-id "mention") ), the client ID and the client secret.

{% hint style="success" icon="pencil" %}
At the end of this step, make sure you have recorded the following information for use in the next steps:

* **Client ID** from the Dataverse app registration
* **Client secret** created for the Dataverse app registration
* **Tenant ID** from the Entra ID app registration, if you have not already recorded it
  {% endhint %}

**Option B: your own account**

At import ([#step-2-import-the-solution](#step-2-import-the-solution "mention")), create the Dataverse connection with **Authentication Type** `OAuth` and sign in with your own account. The flows stop working if your account loses access, so use this for quick tests only.

#### Store the Spark client secret in Key Vault

1. In Azure Key Vault, create a secret that holds the client secret from 1.1, for example `spark-bridge-kv`. The client ID isn't a secret, so it doesn't go in Key Vault.
2. In the vault's Azure subscription, go to **Resource providers** and register `Microsoft.PowerPlatform`.
3. Give Dataverse permission to read the secrets (for example, `spark-bridge-kv)`. Grant the **Key Vault Secrets User** role, which allows reading secret values and nothing else, to the identity that the Dataverse connection uses. Configure the following settings:
   * **Permission model:** Azure role-based access control. This is required. See [Azure RBAC guide for Key Vault](https://learn.microsoft.com/en-us/azure/key-vault/general/rbac-guide).
   * **Role:** Key Vault Secrets User. See [built-in roles](https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles/security#key-vault-secrets-user).
   * **Member:** the Dataverse enterprise application.
4. Note the **secret reference**. You enter it at import ( [#step-2-import-the-solution](#step-2-import-the-solution "mention") ). Format: `/subscriptions/{subscription ID}/resourceGroups/{resourcegroup}/providers/Microsoft.KeyVault/vaults/{vault name}/secrets/{secret name}`

{% hint style="success" icon="pencil" %}
At the end of this step, make sure you have recorded the following information for use in the next steps:

* The **secret reference** for the secret stored in Key Vault
  {% endhint %}

### Step 2: Import the solution

1. In *make.powerapps.com*, pick your environment and go to **Solutions** > **Import solution**.
2. Upload the `.zip` file you downloaded from [Nexthink Infinity Release Notes > Downloads](https://edocs.nexthink.com/nexthink-infinity/infinity-release-notes#nexthink-microsoft-365-apps).
3. For **Spark Bridge - Dataverse**, create or pick the connection from [#choose-how-the-bridge-signs-in-to-dataverse](#choose-how-the-bridge-signs-in-to-dataverse "mention") section.
4. On the **Import a solution** page, under **Environment Variables**, fill in the variables below, then click **Import**. Leave the other variables empty for now; you fill them in the next step ([#id-4.4-fill-in-the-remaining-environment-variables](#id-4.4-fill-in-the-remaining-environment-variables "mention"))

| Variable                   | Name                          | At import | What to enter                                                                                                                                                       |
| -------------------------- | ----------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Spark Client Id            | `ntx_SparkClientId`           | Required  | The client ID from step [#create-the-callback-app-registration-entra-id](#create-the-callback-app-registration-entra-id "mention"), as plain text                   |
| Spark Client Secret        | `ntx_SparkClientSecret`       | Required  | The Key Vault reference to the client secret, from step [#store-the-spark-client-secret-in-key-vault](#store-the-spark-client-secret-in-key-vault "mention").       |
| Token URL                  | `ntx_TokenURL`                | Required  | The token URL from step [#create-the-spark-api-credential-nexthink](#create-the-spark-api-credential-nexthink "mention")                                            |
| A2A endpoint               | `ntx_SparkA2AEndpoint`        | Required  | The endpoint from step [#create-the-spark-api-credential-nexthink](#create-the-spark-api-credential-nexthink "mention"), ending in `/v1/message:send`               |
| Callback allowed Object ID | `ntx_CallbackallowedObjectID` | Required  | The Object ID of `spark-bridge-callback` from step [#create-the-callback-app-registration-in-entra-id](#create-the-callback-app-registration-in-entra-id "mention") |

### Step 3: Connect the pieces

Continue in Power Apps, in the imported **Nexthink Spark Bridge** solution. In the following steps, prepare its cloud flows and collect the HTTP trigger URLs required later in the setup.

#### Enable Register waiter flow

1. Open the **Register waiter** flow and turn it on.
2. Copy the **HTTP URL** from its trigger. Keep this URL private. You enter it in step [#id-4.4-fill-in-the-remaining-environment-variables](#id-4.4-fill-in-the-remaining-environment-variables "mention").

{% hint style="success" icon="pencil" %}
At the end of this step, make sure you have recorded the following information for use in the next steps:

* The **HTTP URL** from the **Register waiter** flow trigger.
  {% endhint %}

#### Enable Receive reply flow

Receive reply only accepts calls signed in as `spark-bridge-callback`. It takes the allowed app from **Callback allowed Object ID**, which you entered at import, so there's nothing to type into the flow.

1. Open **Receive reply** and look at its trigger. "*Who can trigger the flow?*" should show **Specific users in my tenant**, using the **Callback allowed Object ID** variable.
2. Turn the flow on.
3. Copy the trigger's **HTTP URL** You enter it in step [#id-4.4-fill-in-the-remaining-environment-variables](#id-4.4-fill-in-the-remaining-environment-variables "mention").

{% hint style="warning" %}
If you change the Object ID later, update the variable, then turn Receive reply off and on. Check the trigger's HTTP URL afterwards and, if it changed, update it in the following steps:

* [#tell-nexthink-where-to-send-answers](#tell-nexthink-where-to-send-answers "mention")
* [#id-4.4-fill-in-the-remaining-environment-variables](#id-4.4-fill-in-the-remaining-environment-variables "mention")
  {% endhint %}

{% hint style="success" icon="pencil" %}
At the end of this step, make sure you have recorded the following information for use in the next steps:

* The **HTTP URL** from the **Receive reply** flow trigger.
  {% endhint %}

#### Tell Nexthink where to send answers

In Nexthink Infinity, go to **Administration** > **Third-party credentials** > **New credentials** and enter the fields below.

| Field                     | Value                                                                                                                                           |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| Name                      | For example: `Copilot Studio - Spark callback`                                                                                                  |
| Protocol                  | HTTPS                                                                                                                                           |
| URL                       | The URL from step [#check-that-receive-reply-is-protected](#check-that-receive-reply-is-protected "mention"), exactly the same                  |
| Authorization             | OAuth 2.0 client credentials                                                                                                                    |
| Access token URL          | `https://login.microsoftonline.com/{tenant ID}/oauth2/v2.0/token`                                                                               |
| Client ID and secret      | From `spark-bridge-callback` ([#create-the-callback-app-registration-in-entra-id](#create-the-callback-app-registration-in-entra-id "mention")) |
| Scope                     | `https://service.flow.microsoft.com//.default` (the double slash is correct)                                                                    |
| Authorization information | Pass in the Header                                                                                                                              |

{% hint style="warning" %}
Any changes to configurations from previous steps, due to credentials expiration, a new app registration, a changed URL, or a changed dependency, will prevent this integration from working properly. If this happen, update the configuration in every step where you entered it.
{% endhint %}

#### Fill in the remaining environment variables

In [#step-2-import-the-solution](#step-2-import-the-solution "mention"), you left the following variables empty. Fill them in now, in **Solutions** > **Default Solution** > **Environment variables**.

| Variable                              | Name                                    | Required | What to enter                                                                                                                                                     |
| ------------------------------------- | --------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Register waiter URL                   | `ntx_RegisterwaiterURL`                 | Yes      | The Register waiter HTTP URL you copied in [#enable-register-waiter-flow](#enable-register-waiter-flow "mention").                                                |
| Callback URL                          | `ntx_CallbackURL`                       | Yes      | The Receive reply HTTP URL you copied in [#enable-receive-reply-flow](#enable-receive-reply-flow "mention").                                                      |
| Message when Spark can't be reached   | `ntx_MessagewhenSparkcantbereached`     | No       | Default: "*I couldn't reach IT support right now. Please try again in a few minutes.*"                                                                            |
| Message when Spark takes too long     | `ntx_MessagewhenSparktakestoolong`      | No       | Default: "*This is taking longer than expected. Ask again in a few minutes and I'll pick up where we left off.*"                                                  |
| Message when attachment not supported | `ntx_MessagewhenAttachmentNotsupported` | No       | Default: "*Sorry, I can only open one screenshot at a time (PNG or JPG). Please send a single screenshot of the error or problem, or describe what's happening.*" |

#### Turn all components on

Turn all four flows off and on again, so they pick up the values.

### Step 4: Add Spark to your agent

Open Copilot Studio, add Spark to your agent following these steps:

#### Configure Agent settings

1. Open your existing standard agent in the same environment.
2. Go to **Settings** > **Generative AI** and turn orchestration on.

#### Check the Ask Spark topic

Because the solution is in the same environment, the **Ask Spark** topic appears automatically in your agent's topics. You don't need to add the flows as tools: the topic calls them itself.

1. Open **Topics** > **Ask Spark**.
2. Check that the **Send message** and **Wait for reply** steps show no errors. If either says “not found,” make sure the flow is turned on, then select it again in that step.

### Step 5: Add the instructions to your agent

Your agent decides which messages go to the Ask Spark topic, based on its instructions. The topic cannot pass instructions to the agent, so you must provide them. Without these instructions, IT issues might not reach Spark, because the agent answers them itself.

The section below is an example to start from. Adapt it to your agent and organization, then test ( [#step-6-test-it](#step-6-test-it "mention") ). In your agent, open **Overview** > **Instructions** and add the section. If the agent already has instructions, add the section to them. Do not replace the existing instructions.

<details>

<summary>Example instructions</summary>

**Employee support requests (Nexthink Spark)**

Send every work-related support message to the Ask Spark topic. This includes IT issues on the employee's own device (slow or crashing apps, hardware, network, VPN, Wi-Fi, sign-in or MFA), how-to questions about work tools such as Outlook, Teams, printers or the software catalog, and workplace requests such as company policies, equipment, software or access, security badges and time-off procedures. Also send a screenshot of an IT problem (one PNG or JPG), with or without text.

Also send every follow-up message in an ongoing Spark conversation to the Ask Spark topic, even if it's short or doesn't mention IT. For example: "can you do it for me", "yes", "no", "that didn't work", "try something else", "it's my work laptop".

If a message might be work-related, send it to the Ask Spark topic. Spark decides what it can help with, so don't turn down work-related requests yourself.

**Not for Spark**

Don't send messages that have nothing to do with work to the Ask Spark topic. For example: the weather, news, sports, general knowledge, jokes, personal questions, greetings or small talk. Handle these yourself or say that you can help with IT and workplace questions.

A short reply is still a follow-up if Spark's last message asked a question. Send it to the Ask Spark topic, even if it looks like small talk.

**Don't**

* Don't answer IT or workplace questions or follow-ups yourself, and don't use general knowledge for them.
* Don't ask your own clarifying questions before sending a message to Spark. Spark asks if it needs more details.
* Don't write any message of your own before or after the Ask Spark topic, including greetings, sympathy or acknowledgements.
* Don't rephrase, summarize or add to Spark's answers. Show them exactly as they are.
* Don't call the Send message or Wait for reply tools directly. Only the Ask Spark topic uses them.

</details>

### Step 6: Test it

1. **Ask an IT question.** In your agent's test pane, sign in and ask something like "*My laptop is slow.*" Spark should answer within a few seconds to a minute.
2. **Keep the conversation going.** Answer Spark's questions and ask follow-ups until Spark gives its final answer.
3. **Ask about the weather in the middle.** For example, "*What's the weather today*?" Your agent should handle this question itself; it shouldn't send it to Spark.
4. **Check the conversation in Nexthink Infinity.** Open [**Spark > All conversations**](https://docs.nexthink.com/user-guide/spark/working-with-spark/monitoring-spark/monitoring-conversations.md) and find the conversation. Your IT questions and Spark's answers should be there; the weather question shouldn't.

If an IT question doesn't show up in **All conversations**, check your agent's instructions ([#step-5-add-the-instructions-to-your-agent](#step-5-add-the-instructions-to-your-agent "mention")) and the flow run history in Power Automate.

When the tests pass, publish the agent and add it to Teams or your other channels.

***

## Updating the Nexthink Spark Bridge solution

To update, download the new version from [Nexthink Infinity Release Notes > Downloads](https://edocs.nexthink.com/nexthink-infinity/infinity-release-notes#nexthink-microsoft-365-apps). Before importing it to Power Apps, note your flow and topic settings. Importing the new version overwrites the old one. Your agent's instructions aren't affected.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.nexthink.com/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/integrating-spark-with-existing-agents/connecting-spark-to-copilot-studio-agent.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
