Integrate Power apps with Azure cognitive service and Dynamics crm using MS Flow

Power Apps and Azure cognitive service integration

 

While exploring power apps, i build this power app which i connected to azure cognitive service to retrieve the sentiment score of feedback given by a user and stored the result into crm as a record using MS flow.

In last post, we learn How to Create a Cognitive Services APIs account in the Azure portal Adding into that, here we’ll use azure cognitive service api for user’s feedback sentiment analysis and will use MS Flow to store the result in Dynamics crm as a Feedbacksurvey (Custom entity) record.

It have 4 parts:

Part A:- Creating azure portal account and configuring cognitive service api account.

Part B:- Creating Power App and connecting to cognitive service

Part C:- Creating a flow to sync result into crm

Part D:- Testing

Let’s start with Part A:-

Part A:-

This we already did in our post How to Create a Cognitive Services APIs account in the Azure portal | Step by step setup

Please follow steps in above post to create a CS API account.

Let’s move to part B.

Part B:-

Step 1:- Go to https://web.powerapps.com and click on Create new app under apps

Step 2:- You’ll find your self on below screen

 

12.png

First thing is to connect our powerapp to azure cognitive service account we just created in step A.

To reduce no of screenshots, i have composed a small video for it

Step 3:- Setting up screens

3.1 Setup of Screen 1

Set up the icons as shown in below screenshot:

13.png

3.2 Setup of Screen 2

Create a new screen as below

15.png

17.png

 

Step 4:- We’ll now add commands on buttons of screen 1.

4.1)To clear content on reset, set on-select property of reset to false

14.png

4.2)Now let’s add command on analyse button.

On analyse button we’r performing below 2 actions

a) We’ll call cognitive service api and will pass “feedbackinput” text and will get the score of feedback as result

b) Navigate to screen 2

Put below formula in onselect event of analyse (You can easily understand the working of both formulas):-

ClearCollect(sentimentCollect, TextAnalytics.DetectSentiment({language:"en", text:feedbackinput.Text}).score);
Navigate(Screen2,ScreenTransition.Cover)

16.png

Step 5:- Add command on screen 2

Set following formula in reult_1 Text:-

"Your feedback is " & Round(First(sentimentCollect.Value).Value, 3)*100 & "% positive

Thankyou"

Here sentimentCollect.Value is the sentiment

18.png

Now as we want to store the result in Dynamics 365, we first need to create a flow to create record in dynamics 365. For that plese refer Part C.

 

Part C:- Creating a Flow to create a record in Dynamics 365

For this power app, i have created an entity named “feedback” survey with fields like sentiment,sentiment text, comment, and name.

Below is quick video to create a record in D365 using MS flow.

Below is the screenshot of flow created

19.png

Part B Step 6:-

Once our flow is ready and configured we’ll call our flow on the click of submit button:-

On select property of submit button is as below

FeedbackResponse.Run(namevalue,feedbackinput,Round(First(sentimentCollect.Value).Value, 3)*100,"Your feedback is " & Round(First(sentimentCollect.Value).Value, 3)*100 & "% positive Thankyou");
Navigate(Screen1,ScreenTransition.UnCover)

Command 1

FeedbackResponse.Run(namevalue,feedbackinput,Round(First(sentimentCollect.Value).Value, 3)*100,”Your feedback is ” & Round(First(sentimentCollect.Value).Value, 3)*100 & “% positive Thankyou”);

FeedbackResponse is name of FLow. Run is method to call flow.

4 Parameters are as follows:-

1.-namevalue : name filled on screen1 to be set as name field of feedback record

2.-feedbackinput : feedbackinput is the feedback given by user on screen1

3.-Round(First(sentimentCollect.Value).Value, 3)*100 : sentiment value

4. “Your feedback is ” & Round(First(sentimentCollect.Value).Value, 3)*100 & “% positive Thankyou” : feedbacktext parameter

Command2:-

Navigate(Screen1,ScreenTransition.UnCover) : to open screen 1 on click of button in Uncover fashion

 

20.png

Once done, you need to click on file->save and save and publish the app.

You can test your powerapp in web studio itself with the play button in top right corner.

Part D:- Let’s test this power app.

Install powerapps from play store and connect to your instance.

You’ll see feedback Analysis App there. Open it and process

Open the feedbacksurvey record in crm:-

21.png

 

So this is it.

In this post we learn about Power apps, connecting it to azure cognitive service, how to user Microsoft flow to integrate powerapp and MSD 365.

Hope the post was helpful. Feedback are awaited.

Happy learning once again…!!

 

 

 

4 thoughts on “Integrate Power apps with Azure cognitive service and Dynamics crm using MS Flow

Add yours

    1. i think in azure cs you have no of api calls specified in a plan. the more feedbacks you get, the more azure you consume.

      Like

  1. Is there any additional Setup needed which is not described in this post?

    in my PowerApp the function on the analyze button doesn´t work. I have created the app step by step following your description

    Like

    1. share the screenshot, on analysis button you need to click on advanced on right to specify the action formula…msg me on skype directly for quick help (username: vishalgrade )

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: