Note – This post discusses preview features which are, at time of writing, only available in the US. You can take out US based trials, as I did for this post, to demonstrate the functionality which will hopefully be coming to EMEA soon however there are terms and conditions you must be happy with for using preview features, US trials and also using the Azure functionality in regards to access to data and the sharing of potentially confidential information.

The release of Dynamics 365 at the end of last year saw some new features available for public preview. One of the features in preview is the Cognitive Services integration, currently available in the US. The Cognitive Services APIs are a group of APIs that span across different categories such as vision or text analytics. A large number of them have a Machine Learning component where a model will be created and then adjusted over time based on the data that it feeds upon, however not all of them require this and instead perform computation without having the ‘learning’ ability.

What I really like about them is the functionality feels very much ‘pick up and play’ and can be utilised to enhance your application(s) in a number of different ways where you remain in control but Azure does the heavy lifting. They are almost limitless in their uses and one of the reasons I’m so excited about them is their potential in enhanced functionality that could see both users and customers benefit from the insights they offer.

At the end of this post, I discuss briefly how to set up connecting to the APIs in a basic console application using the sample code it provides, but before I do that, the great thing for Dynamics is some of this functionality is available as standard, with no code required (and only requiring an Azure Subscription). This post will focus on how to set those up.

The two core standard integration pieces I am going to walk-through are the Knowledge Article Suggestions functionality using the Text Analytics API and the Product Recommendations functionality which uses the Recommendations API.

Set things up first…

Setting up subscriptions to the services

For both of these pieces of functionality you need to have an Azure Subscription with credit (either the free one or paid is sufficient). (Note – you are responsible for ensuring you are not charged for your subscription!)

You need to add the Recommendations API and the Text Analytics API to your services so you have access to the Keys you will use to authenticate. This can be achieved by following the steps in the video below. (Once you have the service setup, click it on your dashboard and you will then see an area where you can access ‘Keys’) – you may need to wait 10 or so minutes for the Keys to activate if you are running through this for the first time.


The next step is then to activate this functionality from the Administrative area of the settings within Dynamics 365, on the last tab ‘Previews’ and agree to the terms and conditions. Throughout setup, you’ll also have to agree to the terms that your data will be sent to a third party and your okay with this at various points.

Navigate to the Administration area to then setup your connection details by adding in your endpoint URL and the Key from your Azure portal respectively, for each service you intend to use. The example below shows the Text Analytics Connection setup details. Once entered, save the details and test your connection, you will see ‘Success’ appear if it was successful.


Thats it! Your now ready to go into a bit more detail and set up the specific configurations for each piece of functionality.

Setting up Knowledge Article Suggestions using the Text Analytics API

Creating your Model

The Knowledge Article suggestions allow a user to be ‘suggested’ useful Knowledge Articles within a Case based on specific matching criteria that you setup in the model. Follow the steps below to set this up and see this functionality in action.

Click on the Knowledge Search Setup via the Service Management screen

Create a New Knowledge Search Model and complete the following

  • Name of the Model – Name this whatever you wish!
  • Source Entity – This will be Case as standard, unless you have enabled any other entity for Knowledge Management
  • Max Number of Key Phrases –  How do you want to split the searching down into?

Next step is to make a Key Phrase Determination Field record by saving the record and then clicking the + icon on the sub-grid below – these are what your knowledge article will be retrieved upon based on the text in the specified entity and field. I’ve set a basic one up for Case and Title – so it should bring me Knowledge Articles that match the title of my case.

Activate your Model.

Make changes to the Case form

You need to modify the centre pane of the Case form (referred to as ‘Conversations’) which has the Knowledge Article Search on it to include automatic suggestions from Text Analytics – once this is done, save and publish your changes.

See it in action!

Your ready to demonstrate your Knowledge Article Search now based on the keywords you have in the Case Title and those found within the Knowledge Article if you followed my example, or it would be whatever you have setup. I kept my demo simple where I searched for Cats which yielded no results. I then made a new Knowledge Article which included Cats and you can see this now appears under the search. The extensibility comes when you start building up fields in your model so you can ensure something specifically relevant to the text entered on the case is matched to your articles.



Setting up Product Recommendations API

Creating your Model

Setting up the Product Recommendations API is a little more work compared to the Knowledge Search as it is more of a live model that is built and logs its correctness over time, increasing its precision.

Recommendations in the Product Catalog has actually existed for some time, however this has been a manual link requiring updating by a user. This allows a user of Dynamics 365 to click on the ‘Suggestions’ and see products which are linked through product relationships via the cross sell, up sell or accessory categories. They could also specify if the relationship is bi or uni-directional and when selling the reciprocating product, if the other product should also be suggested in that circumstance.

With the integration to the Recommendations API, it basically takes all that hassle away of manually setting things up and will suggest products based in historical data within the system – referred to as ‘Basket’ data, which makes sense and is akin to an more eCommerce experience that we are familiar with when we purchase items online.

Once you have connected to the Azure Recommendations API and have a successful connection (see setup steps earlier in the post), you can now navigate to the Product Catalog and you will see a new area called ‘Product Recommendations’. Click this to start configuring your model.

This might look intimidating at first, so lets just go through how it works. A model is created which has a filter where it looks at the certain records – the model (as standard, without changing it) looks at completed (e.g. won, fulfilled etc) opportunities, orders and invoices. It will not look at in-progress records. These are called Basket Data Entities and are what your model will learn from based on when they are purchased/used in your records and what records they are purchased with. Items which are sold together get scored and the higher the score, the more likely they will appear on your recommendation list based on your Recommendation Entities (which are records which are setup to receive ‘suggestions’).

Setup the model by entering:

  • Model Name – Text based name of your choice
  • Max Recommendations – How many recommendations you want to show at once for cross-sell
  • Min Recommendation rating – The lowest rating  of a product score you wish to show to a user
  • Product Catalog Cross-Sell Link Rating – The lowest rating of a product score you wish to show for a user for cross-selling
  • Recommendation Version – to be entered as a lookup once you have built your model (see below)
  • Description – Optional text based description

For practicing, I suggest you leave the Basket Data Entities and Recommendation entities at their defaults for the Opportunity > Quote > Order > Invoice workflow as it fits with the standard out of the box process which you will likely be familiar with already, but if you want to take a deep dive into changing those you can do so on the subgrid. The filter is specifically there to look at records where the products are associated.


Once basic set up is complete, click ‘Build Model Version’ and then a job is created for the model to be  built which can take between 2-10minutes. If you have no applicable data based on your filters e.g new trial data without any completed records, it might fail (mine did) until I took a couple of opportunities through to the invoice stage. You can check the progress by navigating to the bottom of the record under the ‘Model Versions’ tab.

When your model has been built, select it in the lookup ‘Recommendation Version’ and you will get the ‘Build Model Version Insights’ appear – don’t be alarmed by your % coverage of the Catalog, especially if this is a trial version as this is based entirely on the data it has picked up from the records its being filtered upon, and the precision will be low, if not zero, as this is based on how often the suggestions have been picked (and validated as being correct, hense precision).

Once it has been successful, you can test recommendations by selecting the ‘Test Recommendations’ button on the ribbon and then selecting a product and then your model. Then select ‘Show Results’. You will get some suggestions based on your data which is a good indication everything is set up and your ready to go. I did a few more completions  of the Opportunity to Invoice flow at this point to up my scores a bit so I was on a build version of about 4 until I started seeing more interesting results.

Activate your model once ready by using the ‘Activate’ button at the top of the record and confirming the pop-up dialogs.

Now your ready to test your model – (you can combine both manual and model-based recommendations).  I left the defaults for the Basket Entities up and you can see below some of my results, including the short video. This model is great if you don’t want to be maintaining hard links to your products as you can simply set it up to continue increasing it’s catalog coverage and precision over time and building new versions if your criteria changes for your basket entities.




Custom application of the Cognitive Services API

There are a vast range of other API’s you can connect to offered by the Cognitive Services collection. One of my favorites at the moment is the sentiment analysis from the Text Analytics API which reminds me very much of the sentiment analysis used for Social Engagement (It may well be the same!) which gives a score from 0 to 1 on the negative/positive sentiment of a statement you input. Possible implementations for this could be a web resource that displays a UI which is on a sliding scale in a scenario based on activities for example, and can give sentiment scores based on emails or phone calls. This could even roll-up to an overall sentiment score for the regarding activity (e.g. Opportunity) and used to indicate an appropriate next action. (e.g. if its a negative sentiment on an Opportunity, this could indicate a higher priority to turn this around to a more positive sentiment).

There are loads of sample code and also browser examples of request headers and responses where you can play around with data inputs. I implemented one of the sample pieces in a console application where it is returning the sentiment of a statement. This could be added into a plugin and returned back into a field, or better yet, done inside a web resource and client side instead – there are so many options!

I hope you have found this insight useful into what will hopefully be standard functionality rolled out across all regions!