Share via


Logic Apps with Azure Cognitive Service

Introduction

Data is key enabler for future growth of any Enterprise and fortunately data is everywhere. With the Cloud innovation Integration has come a long way. Today when we talk of integration then lot of moving parts gets combined like IOT, Machine Learning, PowerBI dashboard, SaaS platform like salesforce, Dynamic CRM and list goes on Increasing. Integration need stories and story teller.

In the code solution we will be discussing about a fictitious  company Millennium Car Service station. The fictitious company does car service on weekdays for the customers who are enrolled within the company sites.  The current business requires to do some sentiment analysis of the customer and staff-customer relationship. This is key pointer to value customer experience with   Millennium Car Service station.

In the below solution we will be using Azure SQL (storing all customer feedback data ) with Logic Apps along with Cognitive services detect user sentiment based on the feedback he gives after Car is being serviced out .

As the solution already exists for customer service processing, we will use the existing data within the new Logic App to make some Customer sentiment analysis.

 

Design

In this solution we will go step by step to create a polling Logic App which uses Cognitive services sentiment analysis on real customer feedback.

  • Login to Azure Portal with your valid MSDN Subscription ** **
  • Search for Cognitive Services APIs(Preview) and create a new instance by clicking Cognitive Services on Azure portal . Fill the appropriate Account name, Subscription, API Type, location pricing tier and resource group  within which you want host sentiment Analysis API    

  • For this solution we have used two different stored procedure one for retiring data from Azure SQL table and another stored procedure for updating the row with appropriate sentiment analysis score.  We will not go in detail how to create Azure SQL database and table and there are already multiple of wiki available on this 
Create procedure  [dbo].[GetSalesData]
@isprocessed int  ,
@feedback  varchar(max) output
 
as begin
 
select top  1  @feedback=[CustomerProdcutFeedback] from[dbo].[CustomerServiceTable] where  [IsProcessed] =0
return (select top  1 [Id] from  [dbo].[CustomerServiceTable] where [IsProcessed] =0) 
end
create procedure  [dbo].[updateSalesData]
@customerChoice varchar(50),
@id int
 
as begin
 
update [dbo].[CustomerServiceTable] set [salespersonScore] = @customerChoice , [IsProcessed]=1  where   [Id] = @id
end
  • Next step is to create a polling Logic App which will poll azure SQL database on interval of 5 min and get the top record where Is processed flag is set to 0 . For this add a recurrence trigger with associated actions.

  • Select execute stored procedure action within Logic App, it will l prompt to enter Azure SQL credentials. Enter the correct details and click Create to create a new API connection 

  • After successful connection you can see the list of stored procedure available on the Azure SQL Server. In this case we have selected GetSalesData stored procedure   and passed 0 as input parameter.

  • Next step is to us compose action to contract message for sentiment analysis action within Logic Apps. The output of the compose action is send to Detect sentiment Action within Logic Apps 

  • The last step is run another stored procedure which will update the Azure SQL table with analysis score and set the Is-processed flag to 1 so that the specific record will not be polled in next run

  • Once all the Actions and trigger are listed within the Logic App , the browser workflow for Logic App will look like below with one Recurrence trigger and set of associated actions  (stored procedure call and compose action).

 

  • Save the Logic App so that it can run on schedule basis to get customer feedback data from Azure SQL Table . Now you can verify the run details by going into overview section of the Logic App .

  • Verify the Azure SQL Table for sentiment analysis Score based on customer feedback

References

See also

An important place to find a huge amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk Server Resources on the TechNet Wiki. Another important place to find Logic App related articles is the TechNet Wiki. The best entry point is Logic App Resources on the TechNet Wiki. Another important place to find an extensive amount of Cortana Intelligence Suite related articles is the TechNet Wiki itself. The best entry point is Cortana Intelligence Suite Resources on the TechNet Wiki.

Other languages