Machine Learning– Doesn’t it sound intriguing? Machine learning is a kind of Artificial Intelligence (AI) that helps computers learn from existing data with a specific end goal to forecast future practices, results, and patterns.
These forecasts or expectations from machine learning can make devices and apps more quick witted. Machine learning as it depends on math has a more noteworthy capacity to discover connections between undertakings, or even groups of individuals at an awesome speed.
Azure Machine Learning is a powerful cloud-based analytics solution, which was been recognized as a game changer in applying the power of the cloud to solve the problem of big data processing.
So, how Machine Learning can be leveraged in the SharePoint space?
Microsoft Azure provides a whole bunch of powerful services that let you build apps with powerful algorithms. One among these is “Cognitive” services, which work across devices and platforms. Cognitive Service provides a set of awesome APIs that helps to tap into the power of machine learning and build powerful intelligence into applications to enable natural and contextual interactions.
In this article, I will take a gander at “Text Analytics API”, which evaluates sentiment and extracts keywords.
I have integrated the Azure “Text Analytics API” with SharePoint in the following scenario:
“Let’s say we have launched a product/website and we are capturing the product feedback from users and storing it in a SharePoint list. Every time a user provides feedback, the Text Analytics API is invoked to extract the sentiment of the feedback and same is saved in a different column in the same list. This API returns the sentiment as the numeric score between 0 to 1. Scores close to 1 indicate positive sentiment, while scores close to 0 indicate negative sentiment. This indication of positive and negative sentiments can be utilized to plot graphs”.
The “Text Analytics API” can be leveraged to extract keywords as well from SharePoint blogs and contents, and the keywords can be further utilized for search as well as tagging functionality.
The “Text Analytics API” can be invoked in different ways from SharePoint. To embed the above scenario in SharePoint, I have utilized Microsoft Flow to invoke the API whenever a feedback is entered by any user. Microsoft Flow is another interesting platform, which gives us unprecedented ability to automate business.
Let’s go stepwise on how to consume Azure Text Analytics API in SharePoint using Microsoft Flow.
The prerequisite for this is to have an account with Azure Management Portal. If not, we need to create Azure Account by logging into https://portal.Azure.com
Once the account creation is completed, the below steps need to be executed to create Cognitive Services Account:
1. Login to Azure Management Portal
2. Click “+ New” button, this will display all the services in a new pane
3. Click “Intelligence + analytics”, this will open a new pane with all apps under “Intelligence + analytics”. Click on “Cognitive Services APIs (preview)”.
4. This will open a new pane to create Cognitive Services account. As stated above Azure Cognitive Services provide plenty of powerful APIs.
Account name: Enter the name of the account for the service
Subscription: Based on your subscription this will be populated
API Type: As mentioned above, Cognitive Services provide multiple APIs. For this scenario, I have selected “Text Analytics API”
Pricing Tier: All pricing options for the selected API will be listed in the dropdown. To start with I have free pricing tier.
Resource group: We can create a new resource group or use an existing group.
Once the above details are filled, click on “Create” button. This completes the creation of Cognitive service account and the same will be reflected in the Dashboard of the portal.
5. Click of the service in Dashboard will redirect to the details page of the service. The details page will display the endpoint and the keys for the API.
The highlighted URL tagged under “Endpoint” is the endpoint of the API which needs to be consumed in SharePoint. The endpoint cannot be consumed directly without passing the key. Click on “Keys” link under “Resource Management”. This will display both the keys mapped to this account, the keys can be regenerated again.
So, we are all set with the API endpoint as well as the keys.
Let me now highlight on how I have consumed the API in SharePoint Online using Microsoft Flow.
As mentioned above, Microsoft Flow is a service which helps in building automated workflows between web application and services. Also, Microsoft Flow provides plenty of inbuilt templates as well as actions which can be utilized to build workflows.
To start with Microsoft flow:
1. Login to https://flow.microsoft.com
2. Click on “My Flows” located in the header. This will then present you links to create your flow with existing inbuilt templates or create from the blank template. To incorporate the flow as per my scenario I have used the blank template.
Below figure details down how I have embedded Microsoft Flow in SharePoint:
Each collapsed section in the above diagram represents an action.
Let me provide some more explanation on the actions I have used in my example:
When a new item is created: Like SharePoint workflows provide an action for list item creation, Microsoft Flow provides an action for list item creation as part of SharePoint service
We need to specify the SharePoint site URL and the required List Name.
HTTP: Once a feedback is captured (list item is created), my trigger would be to invoke the Azure Text Analytics API to extract the sentiment of the feedback. The action utilized for this trigger is “HTTP”
Here in this action, we need to post our Azure Text Analytics API with the required endpoint and the key. The API endpoint goes under Uri in this action. The header for the API needs to be passed in JSON format as specified in the above figure. “Ocp-Apim-Subscription-Key” is the name of the key to pass the Account key while invoking the API.
Similar to the header, the body needs to be passed in JSON format. The above figure depicts the format in which request body needs to be passed while invoking the API, where the value for “text” key should be the statement for which we need to extract the sentiment. Microsoft Flow provides the provision to pass dynamic content returned from previous actions.
In this example, I have passed the value of “Title” column of my SharePoint list (this column holds the feedback). Once the request is invoked, it sends back the response content and the same will be further utilized in the flow to update the list item.
The last action in the flow would be updating back the sentiment score for the feedback.
Update item: Similar to create item action, in “Update Item” action also we need to specify the SharePoint site URL and the corresponding list name. We can identify the item from the list by passing the ID of the list item.
Here, I have passed the ID and Title as dynamic content returned from my first action (When a new item is created). “Sentiment” is the column in my list which captures the sentiment score of the corresponding feedback. As mentioned above, HTTP action in this flow will return response “Body” and “Status code”, “Body” will be returned in the below JSON format:
Here, the value for “score” key denotes the sentiment score for the feedback. In my SharePoint list, I have used a calculated column to parse the response content and display only the score. This score can be further utilized to plot graphs which will provide a better idea of feedbacks.
This completes the whole flow of leveraging Azure Text Analytics API along with Microsoft Flow in SharePoint space. As stated above, Azure Cognitive services provide plenty of awesome APIs which can be integrated across the platform. Enable natural and contextual interaction with tools that boost users’ experiences using the power of machine-based intelligence and tap into an ever-growing collection of powerful artificial intelligence algorithms for vision, speech, language, and knowledge. Let’s seize this opportunity and utilize most of these services and APIs in SharePoint space and build influential intelligence into our applications.