# Microsoft Dynamics

## Overview <a href="#overview" id="overview"></a>

The Dynamics Integration connects IFS Loops to your Microsoft Dynamics environment to pull tickets, customer details, and knowledge articles. It uses OAuth authentication via an Azure app registration, with credentials generated in the Azure Portal and entered during setup in IFS Loops.

### Prerequisites <a href="#prerequisites" id="prerequisites"></a>

* Before adding the Dynamics integration in IFS Loops, you must create an OAuth application in the Microsoft Azure Portal.&#x20;
  * The Client ID and Client Secret generated from this step will be required while adding the integration.

## Setup instructions

### Create OAuth App in Azure

{% stepper %}
{% step %}
Go to the Microsoft Azure Portal and sign in using a tenant admin account.
{% endstep %}

{% step %}
From the home page, click **App registrations**, then click **New registration**.
{% endstep %}

{% step %}
Fill in the following details:

1. **Name** — Enter an application name.
2. **Supported account type** — Select **Multiple Entra ID tenants** and allow all tenants.
3. **Redirect URL** — Select platform as **Web**. Based on your cluster, enter the appropriate redirect URL:
   * **Prod US:** <https://app.prod1.theloops.ai/v1/oauth/callback>
   * **Prod EU:** <https://app.eu.prod1.theloops.ai/v1/oauth/callback>
   * **IFS US:** <https://app.ifs-us.theloops.ai/v1/oauth/callback>
   * **IFS EU:** <https://app.ifs-eu.theloops.ai/v1/oauth/callback>
   * **Preprod:** <https://app.preprod.theloops.ai/v1/oauth/callback>
     {% endstep %}

{% step %}
Click **Register**.
{% endstep %}
{% endstepper %}

#### Add API Permissions

{% stepper %}
{% step %}
Go to **API Permissions**.
{% endstep %}

{% step %}
Click **Add a permission**.
{% endstep %}

{% step %}
Select **Dynamics CRM**.
{% endstep %}

{% step %}
Choose **Delegated Permission → user\_impersonation** and click **Add permissions**.
{% endstep %}
{% endstepper %}

#### Grant Admin Consent

{% stepper %}
{% step %}
Click **Grant admin consent** and ensure the status shows **Granted**.
{% endstep %}
{% endstepper %}

#### Create Client Secret

{% stepper %}
{% step %}
Go to **Certificates & secrets**.
{% endstep %}

{% step %}
Click **New client secret**.
{% endstep %}

{% step %}
Add a **Description** and **Expiry date** (as per your preference).
{% endstep %}

{% step %}
Click **Add**.
{% endstep %}

{% step %}
Copy the **Client Secret Value** (shown only once).
{% endstep %}
{% endstepper %}

{% hint style="info" %}
Once the client secret expires, you will need to repeat this step to generate a new client secret and update it in the IFS Loops integration authentication page.
{% endhint %}

#### Add Dynamics Integration in IFS Loops

{% stepper %}
{% step %}
Log in to the IFS Loops platform using your credentials.
{% endstep %}

{% step %}
Navigate to the **Connectors** section from the sidebar.
{% endstep %}

{% step %}
Click on the **Add Integration** button.
{% endstep %}

{% step %}
Choose **Dynamics** from the list.
{% endstep %}

{% step %}
Enter a unique Integration Name and select the required capability:

1. **Helpdesk** — To pull ticket details.
2. **CRM** — To pull customer details.
3. **Content Management** — To pull knowledge articles.
   {% endstep %}

{% step %}
Click on the **Next** button.
{% endstep %}

{% step %}
Enter the following authentication details:

1. **Domain** — From the Dynamics URL, extract the domain.&#x20;
   1. For example, from `https://orgb713773c.crm.dynamics.com`, enter `orgb713773c.crm`.
2. **Client ID and Client Secret** — Enter the Client ID and Client Secret copied from Azure (Section 1).
3. **App ID** — Extract the App ID from the Dynamics URL when you are logged into Dynamics.&#x20;
   1. For example, from `https://orgb713773c.crm8.dynamics.com/main.aspx?appid=3f82b518-7c43-f011-877a-002248d64834&...`, the App ID is `3f82b518-7c43-f011-877a-002248d64834`.
      {% endstep %}

{% step %}
Click on the **Connect** button.
{% endstep %}

{% step %}
A login screen will appear. Sign in using a **tenant admin account** and grant the required permissions.
{% endstep %}

{% step %}
On success, you will see a popup: **"Integration Configured Successfully"**
{% endstep %}
{% endstepper %}

#### Setup Webhook

*Webhook setup is required to receive live updates (such as case creation, updates, and comments) from Dynamics in IFS Loops. This setup is applicable only for the **Helpdesk** capability.*

{% stepper %}
{% step %}
If you have not installed the Plugin Registration Tool, download it using PowerShell.

1. Open **PowerShell**.
2. Run the following script:

```powershell
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$sourceNugetExe = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
$targetNugetExe = ".\nuget.exe"
Remove-Item .\Tools -Force -Recurse -ErrorAction Ignore
Invoke-WebRequest $sourceNugetExe -OutFile $targetNugetExe
Set-Alias nuget $targetNugetExe -Scope Global -Verbose

# Download Plugin Registration Tool
./nuget install Microsoft.CrmSdk.XrmTooling.PluginRegistrationTool -O .\Tools
md .\Tools\PluginRegistration
$prtFolder = Get-ChildItem ./Tools | Where-Object {$_.Name -match 'Microsoft.CrmSdk.XrmTooling.PluginRegistrationTool.'}
move .\Tools\$prtFolder\tools\*.* .\Tools\PluginRegistration
Remove-Item .\Tools\$prtFolder -Force -Recurse
```

{% endstep %}

{% step %}
After execution, the tool will be available in the same directory where you ran the script.
{% endstep %}
{% endstepper %}

#### Open Plugin Registration Tool

{% stepper %}
{% step %}
Navigate to the directory path and open the **PluginRegistration** folder.
{% endstep %}

{% step %}
Open the **PluginRegistration** application.
{% endstep %}

{% step %}
Click on **Create New Connection**.
{% endstep %}

{% step %}
Sign in using admin credentials.
{% endstep %}
{% endstepper %}

#### Register Webhook

{% stepper %}
{% step %}
Click on **Register → Register New Webhook**.
{% endstep %}

{% step %}
Enter the following details:

1. **Name** — Any meaningful name.
2. **Endpoint URL** — Copy from the IFS Loops Dynamics integration configuration page.
   {% endstep %}

{% step %}
Under **HTTP Headers**, add:

* **Key:** `client`
* **Value:** `theLoops`
* *Header keys and values are case-sensitive. Ensure they are entered exactly as shown.*
  {% endstep %}

{% step %}
Click **Save**.
{% endstep %}
{% endstepper %}

#### Register Step for Case Creation

{% stepper %}
{% step %}
Right-click on the created webhook → **Register New Step**.
{% endstep %}

{% step %}
Enter:

1. **Message:** Create
2. **Primary Entity:** incident
3. **Execution Mode:** Asynchronous
   {% endstep %}

{% step %}
Click **Register New Step**.
{% endstep %}
{% endstepper %}

#### Register Step for Case Update

{% stepper %}
{% step %}
Right-click on the created webhook → **Register New Step**.
{% endstep %}

{% step %}
Enter:

1. **Message:** Update
2. **Primary Entity:** incident
3. **Execution Mode:** Asynchronous
   {% endstep %}

{% step %}
Click **Register New Step**.
{% endstep %}
{% endstepper %}

#### Register Step for Annotation Creation

{% stepper %}
{% step %}
Right-click on the created webhook → **Register New Step**.
{% endstep %}

{% step %}
Enter:

1. **Message:** Create
2. **Primary Entity:** annotation
3. **Execution Mode:** Asynchronous
   {% endstep %}

{% step %}
Click **Register New Step**.
{% endstep %}
{% endstepper %}

#### Register Step for Annotation Update

{% stepper %}
{% step %}
Right-click on the created webhook → **Register New Step**.
{% endstep %}

{% step %}
Enter:

1. **Message:** Update
2. **Primary Entity:** annotation
3. **Execution Mode:** Asynchronous
   {% endstep %}

{% step %}
Click **Register New Step.**
{% endstep %}
{% endstepper %}

#### Verify Setup

{% stepper %}
{% step %}
Ensure all steps are successfully registered under the webhook.
{% endstep %}

{% step %}
Final setup should show all created steps linked to the webhook.
{% endstep %}
{% endstepper %}

### Use the Dynamics Integration in IFS Loops

*Once the integration is added, follow the steps below:*

{% stepper %}
{% step %}
Go to your **Dynamics integration**.
{% endstep %}

{% step %}
Navigate to the **Jobs / Data Ingestion** tab.
{% endstep %}

{% step %}
If the capability is Helpdesk or CRM, select a date range to pull the data. For Content Management, a date range is not required.
{% endstep %}

{% step %}
Select **Ingress Type** as **Full Ingress**.
{% endstep %}

{% step %}
Click on **Start Ingress.**
{% endstep %}

{% step %}
After a few minutes, check the **job status** to confirm it is successful.
{% endstep %}
{% endstepper %}

#### Regenerate Token

{% stepper %}
{% step %}
Go to your **Dynamics integration**. Click on the **Edit** button.
{% endstep %}

{% step %}
Navigate to the **Authentication** tab.
{% endstep %}

{% step %}
Click on the **Regenerate Token** button.
{% endstep %}

{% step %}
A login screen will appear. Log in using your credentials.
{% endstep %}

{% step %}
On success, you will see a popup: **"Integration updated successfully".**
{% endstep %}
{% endstepper %}


---

# 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://kb.theloops.io/agenticstudio/integrations/microsoft-dynamics.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.
