{"id":26894,"date":"2019-05-06T11:35:12","date_gmt":"2019-05-06T15:35:12","guid":{"rendered":"https:\/\/centricconsulting.com\/?p=26894"},"modified":"2023-08-18T13:08:29","modified_gmt":"2023-08-18T17:08:29","slug":"interact-with-machine-learning-using-powerapps-and-flow-part-2","status":"publish","type":"post","link":"https:\/\/centricconsulting.com\/blog\/interact-with-machine-learning-using-powerapps-and-flow-part-2\/","title":{"rendered":"Interact with Machine Learning Using PowerApps and Flow \u2013 Part 2"},"content":{"rendered":"

Building on skills learned in our previous blog, interact with machine learning and create a mobile app using Microsoft Flow and PowerApps.<\/h2>\n
\n

Part of the Hackathon hosted by Centric Consulting intended to get our consultants a bit more exposure to\u00a0Machine Learning<\/a>. In the first part of this exercise<\/a>, we walked through\u00a0successfully connecting Microsoft Flow (and PowerApps<\/a>) to an Azure Machine Learning Web Service.<\/p>\n

Creating a Flow<\/h2>\n

Now that we\u2019ve got our Custom Connector in Place, let\u2019s make a flow!<\/p>\n

So, open Microsoft Flow, and create a new blank flow. I named my flow \u2018Machine Learning Request-Response.\u2019 The first action we want to add is the generic \u201cPowerApps\u2019 trigger.\u00a0 This step essentially says \u201cStart this Flow when PowerApps says so.\u201d<\/p>\n

\"PowerApps<\/a><\/p>\n

The next action we want to take is the \u201cExecute the web service and get a response synchronously\u201d action in our custom connector.<\/p>\n

\"PowerApps<\/p>\n

Once you\u2019ve clicked on that action, look for a prompt asking for a new connection name. Put in the API key from your Machine Learning Web Service (Part 1 of this series<\/a> shows you where to find this key).<\/p>\n

\"PowerApps<\/p>\n

After you click \u2018Create,\u2019 you should see the details of the action, where you can format your request. The header area should be automatically filled out, and you can copy and paste the sample body of the request from the API Help Screen (also shown in Part 1 of the series).<\/p>\n

\"PowerApps<\/p>\n

Next, we want to replace \u201cValues\u201d in the body of our request with input gleaned from PowerApps.<\/p>\n

Since we use PowerApps to input certain values, Flow has to know which values are mapped to which Input Boxes. So, we want to remove the word \u201cvalue\u201d in between each quotation mark, and click on \u201cAsk In PowerApps.\u201d This step creates a variable that passes from PowerApps to flow:<\/p>\n

\"PowerApps<\/a><\/p>\n

Next, let\u2019s create a new action to parse our JSON response. Find the \u201cParse JSON\u201d action and add it.<\/p>\n

\"PowerApps<\/p>\n

We\u2019ll be passing the output of our API call to parse JSON, so in the content box, you should see a Body variable. Click to add that.<\/p>\n

Next, we need to define the schema of our JSON output. Click on \u201cUse Sample payload to generate schema.\u201d<\/p>\n

\"PowerApps<\/p>\n

We want to copy and paste a sample response from the API.\u00a0 Once again, you can get this sample from the API Help document of your Machine Learning Web Service (as described in Part 1 of this series).<\/p>\n

\"PowerApps<\/p>\n

We need to add one final action to our flow. We want to respond to PowerApps with the value we were expecting from our response (instead of the entire JSON output response).<\/p>\n

First, we need to add the \u201cRespond to PowerApps\u201d action:<\/p>\n

\"PowerApps<\/p>\n

Next, we add a \u201cText\u201d response. We have to define a name (I used \u2018flowresponse,\u2019 but use whatever is most descriptive for you).<\/p>\n

So in the value field, we want to construct an expression to find the value we want. In this case, based on my JSON schema it would be: body(\u2018Parse_JSON\u2019)[\u2018Results\u2019][\u2018output1\u2019][\u2018value\u2019][\u2018Values\u2019]\n

\"PowerApps<\/p>\n

That expression grabs the body of the output from parse JSON, and drills down to the \u201cValues\u201d key and gets the value.<\/p>\n

You can now save your flow, and it\u2019s complete!<\/p>\n

Now, Let\u2019s make a PowerApp!<\/h2>\n

I\u2019m not going to review every single detail of building a PowerApp. If you need a refresher, read this blog<\/a>.<\/p>\n

For this demo, I built a PowerApp with four screens. A title screen, two screens to input the data, and one screen to view the results.<\/p>\n

The input screen contains input text boxes (and one date control).<\/p>\n

\"PowerApps<\/a><\/p>\n

Now what I would like review what occurs when a user submits a request. On the submit button, I added my flow from \u201cActions -> Flows.\u201d I then constructed this argument:<\/p>\n

ClearCollect(responseColl, \u2018MLRequest-Response\u2019.Run(DatePicker1, TextInput1_2.Text, TextInput1_3.Text, TextInput1_4.Text, TextInput1.Text, TextInput1_5.Text, TextInput2.Text, TextInput1_6.Text, TextInput1_7.Text, TextInput1_8.Text, \u201c\u201d, \u201c\u201d)); Navigate(Screen3, Cover)<\/p>\n

So, what\u2019s happening here is I am instantiating a collection, which is collecting the response from running the flow.<\/p>\n

In the flow, I am passing the parameters the flow wants by sending it the text values the user entered in for each of my input text boxes and then navigating to the next screen.<\/p>\n

\"PowerApps<\/a><\/p>\n

When I click the \u201cSubmit\u201d button in my designer preview, I can go look at my collections, and see the value added to the collection:<\/p>\n

\"PowerApps<\/p>\n

Now that I have my value, I also wanted to display it in a more friendly way (without brackets and everything past the decimal).\u00a0 So I added a label and used the following formula:<\/p>\n

\"PowerApps<\/a><\/p>\n

This formula takes the flow response and looks for a contiguous match of just digits. Then I used concatenate to put “Days\u201d at the end.<\/p>\n

Lastly, as a bit of housekeeping on apps usage, when a user clicks the \u201cStart Over\u201d button, it resets all the controls, and sends the user back to the home screen!<\/p>\n

\"PowerApps<\/a><\/p>\n

The Final Application<\/h2>\n

Following these steps in tandem with those listed in Part 1<\/a>, we successfully connected Microsoft Flow and PowerApps to an Azure Machine Learning Web Service and created a fully functional mobile app to predict how long an employee might stay with an organization. Now you can take these skills and apply what we practiced to your own business needs and strategies.<\/p>\n


\n

Part six of a\u00a0Women in Tech series.<\/a> This blog was originally published on Jo’s blog, here<\/a>.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"

Building on skills learned in our previous blog, interact with machine learning and create a mobile app using Microsoft Flow and PowerApps.<\/p>\n","protected":false},"author":86,"featured_media":33369,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_oasis_is_in_workflow":0,"_oasis_original":0,"_oasis_task_priority":"","_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","footnotes":""},"categories":[1],"tags":[19123],"coauthors":[15564],"acf":[],"publishpress_future_action":{"enabled":false,"date":"2024-07-22 09:38:31","action":"change-status","newStatus":"draft","terms":[],"taxonomy":"category"},"_links":{"self":[{"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/posts\/26894"}],"collection":[{"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/users\/86"}],"replies":[{"embeddable":true,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/comments?post=26894"}],"version-history":[{"count":0,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/posts\/26894\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/media\/33369"}],"wp:attachment":[{"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/media?parent=26894"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/categories?post=26894"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/tags?post=26894"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/coauthors?post=26894"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}