At integrate there was a bar chat which made me wonder why we are building maps and if I can just have AI transform data for me. I knocked up a little sample where we use a Logic App which is processing some data and then we use Chat GPT to transform the data for us by describing the transformation in natural language text. The below video goes through the demo, and there are some more info about the steps below.

 

 

A quick shout out to Sandro as I used his blog post to show me how to call ChatGPT from a Logic App

I created a compose shape to capture my input data and some information about what I want the map to do.

I then make a call to Chat GPT passing in this info and let it do the hard work for me.

I then process the response and then I can call my Logic App using the below input data

<Person>
    <FirstName>Mike</FirstName>
    <Surname>Stephenson</Surname>
    <Address>
        <GolfClub>High Gosforth Park</GolfClub>
    <Address>
    <GolfScores>
        <Score date="2023-01-01">72</Score>
        <Score date="2023-01-02">74</Score>
        <Score date="2023-01-03">73</Score>
        <Score date="2023-01-04">77</Score>
    </GolfScores>
</Person>

From the map I got the below result

{
    "Person": {
        "FirstName": "Mike",
        "LastName": "Stephenson",
        "FullName": "Mike Stephenson",
        "Address": {
            "GolfClub": "Parklands"
        },
        "GolfScores": [
            {
                "Date": "01/01/2023",
                "Score": 72,
                "GrossScore": 72,
                "NetScore": 65
            },
            {
                "Date": "02/01/2023",
                "Score": 74,
                "GrossScore": 74,
                "NetScore": 67
            },
            {
                "Date": "03/01/2023",
                "Score": 73,
                "GrossScore": 73,
                "NetScore": 66
            },
            {
                "Date": "04/01/2023",
                "Score": 77,
                "GrossScore": 77,
                "NetScore": 70
            }
        ]
    }
}

Thats a pretty interesting way to map the data. Sandro was then telling me about his mapping issues, we modified the logic app to be able to pass in the sample data and instructions so we called it with the below data.

If I have this message as an input

<ns0:PersonOrigin xmlns:ns0="http://HowMapsWorks.PersonOrigin">
  <FirstName>Sandro</FirstName>
  <LastName>Pereira</LastName>
  <DateOfBirth>1978-04-04</DateOfBirth>
  <Address>Crestuma, Porto, Portugal</Address>
  <ZipCode>4415 Crestuma</ZipCode>
  <PhoneCalls PhoneNumber="+351960123876" Cost="0.5" />
  <PhoneCalls PhoneNumber="+373181818181" Cost="5" />
  <PhoneCalls PhoneNumber="+351910123876" Cost="1.5" />
  <PhoneCalls PhoneNumber="+351960123876" Cost="0.2" />
  <PhoneCalls PhoneNumber="+299221122111" Cost="10" />
  <PhoneCalls PhoneNumber="+351910123876" Cost="0.5" />
</ns0:PersonOrigin>

Can you map this to json
Can you add a field calculating the persons age from today using the DateOfbirth field
Can you add the gps coordinates for the address as a field based on the ZipCode
In the PhoneCalls array can you lookup the contry for each phone call based on the PhoneNumber and add a new field called country
Can you do a summary of the cost grouped by country and rounded to 2 decimal places
Give me just the output json and no waffle

I then get back this awesome response where you can see it did all of the country lookups based on the phone number, worked out sandros GPS location and also summarised the cost of calls by country. The response looks like the below.

{
  "FirstName": "Sandro",
  "LastName": "Pereira",
  "DateOfBirth": "1978-04-04",
  "Address": "Crestuma, Porto, Portugal",
  "ZipCode": "4415 Crestuma",
  "Age": 43,
  "GPS": {
    "Latitude": "41.0699",
    "Longitude": "-8.6442"
  },
  "PhoneCalls": [
    {
      "PhoneNumber": "+351960123876",
      "Cost": 0.5,
      "Country": "Portugal"
    },
    {
      "PhoneNumber": "+373181818181",
      "Cost": 5,
      "Country": "Moldova"
    },
    {
      "PhoneNumber": "+351910123876",
      "Cost": 1.5,
      "Country": "Portugal"
    },
    {
      "PhoneNumber": "+351960123876",
      "Cost": 0.2,
      "Country": "Portugal"
    },
    {
      "PhoneNumber": "+299221122111",
      "Cost": 10,
      "Country": "Greenland"
    },
    {
      "PhoneNumber": "+351910123876",
      "Cost": 0.5,
      "Country": "Portugal"
    }
  ],
  "CostSummary": {
    "Portugal": 3.2,
    "Moldova": 5,
    "Greenland": 10
  }
}

There seems to be a bug in my instructions for Sandro’s age, he says its a feature!

Anyway hope this gives people loads of ideas of cool stuff we can do, one of the interesting things is that the response isnt always going to be exactly the same. What id like to see is features in Azure for natural language data transformation where I could provide samples and a description of what to do and then train my map so that it becomes reliable and efficient at mapping the data and then I could just call it from a Logic App. This would be an awesome mapping feature for Azure Integration Services!

 

 

Buy Me A Coffee