Closed AdhocAdam closed 6 years ago
Take the following PowerShell functions (requires an Azure subscription, Cognitive Services, and Text Analytics API deployed) where the input is an end user emailing about their inability to sign into a website seen in the $content variable.
#azure settings
#azureRegion = based on where Cognitive Services app is deployed as seen in its respective settings pane, i.e. ukwest, eastus2, westus, northcentralus
#apiKey = Text Analytics API key as seen in the Azure Portal for the deployed cognitive service
$azureRegion = ""
$azureCogSvcAPIKey = ""
function Get-AzureEmailSentiment ($messageToEvaluate)
{
#define cognitive services URLs
$sentimentURI = "https://$azureRegion.api.cognitive.microsoft.com/text/analytics/v2.0/sentiment"
#create the JSON request
$documents = @()
$requestHashtable = @{"language" = "en"; "id" = "1"; "text" = "$messageToEvaluate" };
$documents += $requestHashtable
$final = @{documents = $documents}
$messagePayload = ConvertTo-Json $final
#invoke the Cognitive Services Sentiment API
$sentimentResult = Invoke-RestMethod -Method Post -Uri $sentimentURI -Header @{ "Ocp-Apim-Subscription-Key" = $azureCogSvcAPIKey } -Body $messagePayload -ContentType "application/json"
#return the percent score
return ($sentimentResult.documents.score * 100)
}
function Get-AzureEmailKeywords ($messageToEvaluate)
{
#define cognitive services URLs
$keyPhraseURI = "https://$azureRegion.api.cognitive.microsoft.com/text/analytics/v2.0/keyPhrases"
#create the JSON request
$documents = @()
$requestHashtable = @{"language" = "en"; "id" = "1"; "text" = "$messageToEvaluate" };
$documents += $requestHashtable
$final = @{documents = $documents}
$messagePayload = ConvertTo-Json $final
#invoke the Text Analytics Keyword API
$keywordResult = Invoke-RestMethod -Method Post -Uri $keyPhraseURI -Header @{ "Ocp-Apim-Subscription-Key" = $azureCogSvcAPIKey } -Body $messagePayload -ContentType "application/json"
#return the keywords
return $keywordResult.documents.keyPhrases
}
Get-AzureEmailKeywords -messageToEvaluate "Can someone reset my password for the website?"
Get-AzureEmailSentiment -messageToEvaluate "Can someone reset my password for the website?"
The keywords extracted from this request are: password website
The sentiment rating being 75% (0.7531810998916626) with 100% being a positive sentiment.
With respect to the sentiment rating, this introduces possibility of:
With respect to keyword results, this introduces the possibility of:
Looking to target v1.4.x or v1.5 of the connector for a first pass at this functionality. The plan is to introduce a configurable setting to enable this functionality to perform...
Sentiment Analysis Submit the email body to Cognitive Services and receive a value/score so as to define a minimum threshold for creating a Service Request. For example, if the returned score is less than the defined threshold the connector will instead create an Incident instead of a Service Request. This will only apply to New Work Item creation on the default mailbox.
Example Setting:
$minPercentToCreateServiceRequest = "95"
Keyword Analysis If leveraging the Search Cireson Knowledge Base and/or Service Catalog features of this connector, Keyword analysis will be performed so as to extract pertinent keywords to perform a search against those respective data sources. So instead of the connector's default behavior of searching every single word in an email, Cognitive Services will extract it believes to be keywords from the email and in turn those returned keywords will be used to search against said data sources.
As a means to provide some guidance on the threshold score for Sentiment analysis as well as insight into Keyword analysis, take the following examples.
Sentiment Score (%) | Keywords | Email body/message |
---|---|---|
98.86758327484130900 | setup hotkeys applications new keyboard | "Thank you for the new keyboard! Can I setup hotkeys for applications on it?" |
92.94477701187133800 | new laptop process | "I'd like to order a new laptop. How can I get this process started?" |
83.29106569290161100 | new phone native app Outlook | "Just received my new phone. Do I need Outlook or can I just use the native app?" |
74.134469032287600 | password | "Can you reset my password?" |
50.0 | printer | "my printer isn't printing" |
22.74151146411895800 | firewall website | "Why is the firewall blocking this website?" |
16.34500920772552500 | PC virus scan | "My PC is acting weird. I think I have a virus. Can you like run a scan or something?" |
15.59586524963378900 | reason way permantly fix printer tray | "The printer for whatever reason is now printing from tray 2. Why does it keep getting reset? Isn't there some way to can permantly fix this?" |
14.799088239669800 | days | "I can't believe I've been waiting 4 days to get this fixed. When is this going to be dealt with?!" |
14.383226633071900 | vendor remote access password | "Our vendor needs remote access. I think they have it, but maybe their password expired? Can someone look into this?" |
14.1702562570571900 | PC times website | "Hey the website is down! I even restarted my PC three times." |
12.45351433753967300 | new cable monitor | "i need a new cable for my monitor" |
11.03039979934692400 | days | "I can't believe I've been waiting 4 days to get this dealt with. When is this going to be fixed?" |
1.392689347267150900 | s drive | "my s drive isn't connected" |
Will create additional GitHub Issues tagged as feature requests as this feature set for Azure Cognitive Services grows.
Explore the possibilities of Azure Cognitive Services integration as it pertains to parsing keywords and understanding requests. (e.g. Text Analytics API or Language Understanding)
If this becomes viable, this could be the first step towards creating artificial intelligence around Service Manager through the connector.
Requests would have to stay under 5,000 per month lest incur charges. This functionality can be tested without having to sign up for a free Azure subscription at the following link