Microsoft Dynamics 365: Maintain Contacts and Accounts


Microsoft Dynamics 365 in cooperation with the Cognigy Extension provides the maintenance of Contacts and Accounts. This tutorial will explain how to integrate an organization's Dynamics instance to a Cognigy.AI virtual agent and create and retrieve an entity in Dynamics 365.

   Watch Cognigy Showcase "Voice-enabled Salesforce CRM with Conversational AI"

Table of Contents

  1. Install the Microsoft Dynamics Extension
  2. Create a Microsoft Online Connection
  3. Get an Access Token - Authenticate the user
  4. Search for Contacts or Accounts
  5. Retrieve an Entity by Primary Key
  6. Create a new Contact

Install the Microsoft Dynamics Extension

The first step is to install the required integration. In this case, a so-called Extension is installed to Cognigy.AI. Thus, navigate to the Extensions Marketplace inside of the Virtual Agent and add the Microsoft Dynamics Extension by clicking on the Install button. Now follow this installation guide and upload the Extension to Cognigy, where it will be displayed as the following:


Congrats! The installation of the Extension is finished!

Create a Microsoft Online Connection

In this step, a so-called Connection will be created. If one, in Cognigy.AI, clicks on the previously uploaded Extension, the following details can be observed:


The red-marked part in the above figure shows, that there are two Connections required. Therefore, both need to be created and filled with the Dynamics 365 instance information. In order to do so, one initial Dynamics Flow Node needs to be added to a Flow:

  1. Create a new Flow in Cognigy.AI
  2. Inside of the Flow Chart, click on + and navigate to the Microsoft Dynamics Extension:


  3. Add the Get Access Token Flow Node by clicking on it:


  4. In order to edit the Flow Node and create the Connection, please click on it. An Edit Node menu will be opened on the right side of the screen:


  5. Right next to the Connection field (the first one at the top), one needs to click on the + button. The Connection menu will be opened at the center of the screen:

  6. Insert the related Microsoft Online log-in credentials/information of the organization to the fields.
    1. clientId
      1. The Client ID of the Microsoft Dynamics 365 application
    2. clientSecret
      1. The Client Secret of this Dynamics 365 application. It could be the case that an administrator within your organization needs to provide this.
    3. tenantId
      1. The ID of your Microsoft tenant.
      2. How to find the ID
        1. Go to
        2. Click on Azure Active Directory
        3. Click Properties under the Manage section
        4. Your tenant is the Directory ID.
    4. scope
      1. The defined scope of the application in Azure.
      2. Example:
  7. Click on the Create button

Get an Access Token - Authenticate the user

This recently created Connection is required in order to get an access token for the current chat conversation. Without this token, none of the upcoming Dynamics functionalities could be used. Therefore, please test the Get Access Token Flow Node and check if the so-called "Bearer" token information is stored in the Context:


If the Connection is correct, the required access token is stored in the Context. By default, the location Context -> Microsoft -> Auth -> Access Token which can be extracted by using the following CognigyScript:


If the Context location was not customized, one doesn't need to do anything else as all upcoming Extension Nodes use this above Context location by default as well.

Create a Dynamics 365 Connection

After authenticating the chat conversation with the previous step, the missing Dynamics 365 Connection can be created. The only value, that needs to be provided in this case, is the organization URI. This information is necessary in order to call the right Dynamics 365 instance and fetch the data.

  1. Next, to the Get Access Token Flow Node, add any other Microsoft Dynamics Extension Node. For instance, Search Entity:


  2. Such as we did before, please click on the Node in order to open the Edit menu:


  3. At the top, one can create a new Connection by clicking on the next to the Connection field:
  4. Please fill in the organization URI, such as
  5. Click on the Create button.

Search for Contacts or Accounts

The same Search Entity Flow Node can be used for retrieving entity information based on,

  • defined Return Values,
    • A list of entity fields that should be returned and stored
  • Search Filter 
    • Which entity field should be used for searching
  • and a Search Value
    • The value that will be used together with the filter

while this example entity is stored as a Contact in Dynamics 365:


In step 2 of the previous chapter, the used Edit menu is displayed. By default, the contact ID, first name, and last name are returned while the mobile phone number is used for filtering all given contacts -- in this default case. As an example, the possible chat conversation could look like the following:


Please notice that any entity field of a contact or account could be used for filtering or defining the list of returned values. In some cases, it could make sense to use the email address as a filter or expand the list of return values.

Retrieve an Entity by Primary Key

If it should be the case, that the Entity ID / Primary Key of the searched entry is already known, the Retrieve Entity Flow Node can be used instead. In this case, the entire data information of an entity, for example, contact, is returned and stored in the Input or Context object of Cognigy.AI. A possible scenario would be the cooperation of Search Entity and Retrieve Entity since one could first find the right contact and then get all information by executing the second Flow Node:


Since the required Contact ID / Primary Key is returned by the Search Entity Node, it can be used dynamically by using CognigyScript again:


The used CognigyScript extracts the contact ID, in this case, from the previously-stored Context result:


The used contactid value is only available if the list of Return Values inside of the Edit menu of the Search Entity Flow Node contains the word "contactid".

Create a new Contact

Finally, a virtual agent could create a new entity, e.g. a new contact, during a chat/voice conversation. A possible chat could look such as the following:


Next to the necessary Question Flow Nodes, that could be used within the "Missing Pattern", the Create Entity Node has to be added to the Flow for this scenario:




Furthermore, the mentioned contact creation could be configured such as


in which the Entity Data field consists of the dynamically inserted values from the Cognigy Context:

    "firstname": "{{context.firstname}}",
    "lastname": "{{context.lastname}}",
    "emailaddress1": "{{}}"

These dynamic values will be translated into real values as soon as the request of creation is sent to Microsoft Dynamics:

    "firstname": "Laura",
    "lastname": "Wilson",
    "emailaddress1": ""



Article is closed for comments.

Was this article helpful?
0 out of 0 found this helpful