Table of Contents
- Introduction
- Overview
- Step-by-Step Guide to Building the Supply Chain Copilot
- Publish the Copilot to Teams
- Conclusion
Introduction
Leveraging advanced technologies like Microsoft Power Platform can significantly enhance your supply chain operations. In this blog, we will explore how to create a Copilot for supply chain management that identifies the best vendor based on vendor details stored in Dataverse. This Copilot will utilize parameters like lead time, quality score, and unit price, and employ AI prompts to make intelligent vendor recommendations.
Overview
Our supply chain Copilot will:
- Fetch Vendor Details from Dataverse: Retrieve data for multiple vendors, each providing the same product with different parameters.
- Use AI to Identify the Best Vendor: Implement AI-powered analysis to find the most suitable vendor based on the retrieved data and parameters like lead time, quality score, and unit price.
Step-by-Step Guide to Building the Supply Chain Copilot
Step 1: Set Up Dataverse for Vendor Data
To begin, we need to organize our vendor details in Dataverse. Create a table named Vendor Details with the following columns:
- Material Name: The name of the material or product (e.g., Aluminium Sheets, Copper Wires).
- Vendor Name: The name of the vendor supplying the product.
- Unit Price (Dollars): The cost per unit of the product.
- Quality Score: A score representing the quality of the product (typically on a scale of 1-100).
- Lead Time (Days): The time taken by the vendor to deliver the product.
Step 2: Populate the Dataverse Table
Enter the vendor details into the Dataverse table. We have the below data for the demo:
Step 3: Creating the Copilot in Copilot Studio
Head over to Copilot Studio and click on Create.
This will provide us the option to create a copilot based on an existing template or create a blank copilot from scratch. Let’s select New Copilot.
This will take us to the page where we can:
- Describe the copilot functionality and provide any specific instructions to the copilot.
- Once done, click on Create to provision the copilot.
Step 4: Enable Generative Selection of Topics (Dynamic Chaining)
The copilot is now created. We can then make the needed configuration changes:
- Click on Edit, edit the copilot details like name, icon, and description.
- Click on Settings to enable the Generative selection of topics so that without relying on triggers, the topics will be auto-selected based on user conversation resulting in a much smoother user experience.
To enable the automatic detection of topics from user interaction:
- Click on Generative AI.
- Select Generative (preview).
- Click on Save to update the settings.
- Click on the Close icon to go back to the home page of this custom copilot.
Step 5: Create Topics
Now let’s go ahead and create the topics that will automatically redirect the conversation flow to appropriate topics based on the question user posts.
- Click on Topics from the navigation menu. To add the topic, we can either go with the option to create a blank topic or use Copilot to create the topic with an initial set of prepopulated conversation nodes based on the topic description that we provide.
- Click on Add a Topic and
- Select Create from description with Copilot.
Let’s provide the below topic description details in the pop-up that opened when we clicked the Add topic button previously. Then, click on Create, which will provision the topic skeleton based on the provided description.
Thus we have the basic topic created with an automatic trigger as well as a question to the user which are generated using the description provided. We can now add more conversation nodes.
We now need to fetch the vendor details from the Dataverse table for which we will call a Power Automate. Let’s first create the flow by:
- Select Call an action.
- From the Basic actions tab, click on Create a flow.
This will open the Power Automate site where we will be taken to the newly created flow where we will:
- First change the flow name to Get Vendor Details.
- Click on + Sign to add a new action.
- Search for List Rows and select the action by the same name under the Dataverse section.
We will then configure the List rows action by:
- Specifying the table name.
- Mention the logical names of the columns that we want to fetch from the Vendor Details table.
Note: You can get the logical name of the columns used in the Select columns field from the Dataverse table by following the below path:
Now let’s initialize a variable to hold the output that we will return back to the copilot.
We will name the variable as varOutput of type string.
Next, we want to iterate the Dataverse returned values and create a collection of vendor details in a specific format. To do this, let’s add the Apply to each loop to the designer.
We will configure the Apply to each action to loop through the Dataverse returned table rows.
Within the added Apply to each, let’s add a Compose action, since we need to build the output that must be returned to copilot in a specific format.
We will add the below formula to the Compose action because we want to create the vendor details as a string output in the format:
VendorName : <VendorValue>, LeadTime: <LeadTimeValue>, QualityScore: <QualityScore>, UnitPrice: <UnitPrice>
We could easily create a table in the above format using Select action, but since the AI Prompt within copilot expects the input to be a string, we will be using the compose action to create the required string formatted output.
concat('VendorName: ', item()?['cr06f_vendorname'], ', LeadTime: ', item()?['cr06f_leadtimedays'], ', QualityScore: ', item()?['cr06f_qualityscore'], ', UnitPrice: ', item()?['cr06f_unitpricedollars'], ', MaterialName: ', item()?['cr06f_materialname'])
Within the Apply to each loop, just after the Compose action, let’s add the Append to string action so that each of the looped Dataverse rows is formatted and added to the output variable.
Thus in each of the iteration, the vendor rows will get formatted as a string and get appended to the output variable.
Finally, let’s return back the output variable to the copilot.
Click on Publish to save and publish the flow.
Let’s head back to the copilot and click on Done so that we can add this new flow to the copilot.
Select the recently added flow from the Call an action which will make the flow available for triggering from the copilot as an action.
As we can see, the vendor details records are now returned as a string which we will use as one of the inputs to the AI Prompt along with the Product Name for which we are initiating a procurement.
Now let’s add the AI prompt using which we can find the best vendor for the product specified by the user. To do this:
- Select Call an action and
- From Basic Actions, select Create a prompt.
This will open up the Prompt AI Builder in a pop-up where we can:
- Create the Product Variable to which we will pass the user-inputted product name for which he is finding the best vendor.
- Create the Product Details variable to which we will pass the Power Automate returned vendor details.
- In the Prompt section use the below prompt and add the variables dynamically using the Insert button which will allow us to add the Product and Product Details input variables into the prompt.
- Click on Save custom prompt which will make the prompt available in the copilot designer.
The prompt is now available, let’s configure it by adding the first input parameter which is the user input Product Name.
Next, we will add the Power Automate returned output variable to the Product Details field.
Finally, we need to store the output record generated by the Prompt action in a variable for which we will create a new variable by the name varBestVendor.
Thus we have configured the Prompt action with the required input and it should ideally fetch us back the best vendor for the passed-in product based on the Unit Price, Lead Time, and Quality Score parameters. Finally, we will show the best vendor output as a basic card back to the user for which we will select the text property of the varBestVendor record which will contain the generative AI output.
Publish the Copilot to Teams
We will finally publish the copilot and add it to the Teams Channel for which we will enable the teams channel by selecting the Channels Tab -> Microsoft Teams -> Turn On Teams.
Click on the Availability Options to select how to distribute the copilot within Teams.
We have the option to publish the app to the app store which goes through an admin approval or we can download the zip file and upload it as a personal app. For this demo, we will go publishing the app org-wide.
Click on Submit for Admin approval and the admin can approve this from the Teams admin center.
We can see that the copilot has become available for publishing in the Teams admin center. Click on Publish.
Let’s now add the copilot to Teams so that we can interact and get results with it.
Thus we have initiated the conversation with the copilot and tried to find the best vendor for Copper Wires. If we filter the Dataverse table for Copper Wire Vendors, we could see 3 records but AI prompt that we used have refined the results by comparing the Unit Price and Quality score to arrive at the best vendor.
We can see that the copilot has picked the vendor details from Dataverse and using the AI Prompt, fetched the generative contextual answer for the best vendor by comparing the unit price and quality score.
Conclusion
In this blog, we’ve explored how to build a supply chain Copilot using Microsoft Power Platform and Dataverse to streamline the vendor selection process. By leveraging Dataverse for structured storage of vendor details and employing AI prompts for intelligent analysis, our Copilot provides an efficient solution for identifying the best vendor based on critical parameters like lead time, quality score, and unit price.