Hi friends, here is a quick hack to control your Copilot responses from D365F&O effectively, using ChatGPT and Power-Automate prompts. Suppose you want to inquire how many vendors are there in your F&O instance for a given vendor group. This small write up tells you, how could you achieve the same using a cool hack. Check out the steps below:
Step 1
Define the question by creating a new topic in https://copilotstudio.microsoft.com/ :Ask the user back with a counter question:
Here you are storing the response in a Global variable called: vendGroup:
Step 2
Call an action element from here, which is calling a Power Automate from here:Let us define the flow now. Begin by accepting an input as follows:
And then I am calling my AAD token generation logic and parsing it as defined in the following step:
And parsing the obtained token from here, by init-ing in a variable:
And then I am calling on to my D365F&O instance, so as to filter the vendors, based on entered vendor group. For this I can call the JSON filtration call by:
https://<Base URL>/data/VendorsV2?$filter=VendorGroupId eq ‘30’
In this example I am trying to filter the vendors by vendor group = 30. I am doing the same in my Power automate step as shown below:
This would return a response like this:
Copy the response, on to a notepad, for later reference.
Step 3
Lets come back to https://make.powerautomate.com/ and create an AI prompt:Here lies the magic of the ChatGPT. We would be feeding in the response from filtered JSON answer from D365FO and would ask ChatGPT to classify the response based on Vendor account and vendor name. In the prompt window, you can specify the type of your response you need:
Here JSON in the input, that we would pass on (in the next step) in the next step. To create a variable like this, you need to click on Add button (as highlighted):
In the following prompt, give a suitable name (like I kept it as JSON) and paste the input payload which you obtained from above step:
Click on Add input to save the same.
Take a look at my prompt again:
Here I am saying to ‘remove any JSON content’. I had to do this – as otherwise the ChatGPT would trail the outcome with a JSON explanation of it’s execution, which is certainly not needed for any end user 😊
Click on ‘Save custom prompt’ to save your changes.
Step 4
Let us come back to our Power automate design and Add the following action: “Create text with GPT using a prompt”:Click on the Prompt type. Your created custom prompt should show over there:
Both in Input text and JSON you give the body of the payload which you received from the above step (HTTP call to D365F&O).
That’s it – we had just generated the gist of the JSON content from D365F&O OData entity, using ChatGPT.
All I need to do now is to obtain the result of this execution in a variable like this:
And then pass on the variable to a Copilot response:
Save the draft and publish the Flow. We are done with Power Automate design. Let us get back to out Copilot topic now.
Step 5
We are now passing on the variable which we got from the user (step 2) and calling our newely created Power Automate:
And storing the response in a variable called ‘Response’.
And then we are finally sending the response back to user:
Done. Let us now Save the topic and Publish it.
Testing time
Let us now launch our Copilot sidecar and ask the question:To which it responds:
This is the response which I gave to the copilot:
And here is how it answered:
Which contains the number of vendors as along with it the vendor names too.
Cool, ain’t it? Let me take your leave for today. I would soon be back with more such cool hacks on Copilot, prompts and Dynamics365. Take care, love and Namaste, as always 😊
*This post is locked for comments