Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This article provides a step-by-step guide to extend Microsoft Copilot chat within a model-driven app to optimize Field Service. By integrating external data sources and customizing the Copilot agent using Copilot Studio, Field Service Managers gain real-time access to inventory data, enabling more efficient and informed decision-making.
The goal of this article is to highlight the potential of using agents in the context of Dynamics 365 Field Service. When choosing the appropriate technology, it is essential to consider factors such as the number of users, costs, security, and required performance.
The article explores two possible contexts:
- Solution A – where Dynamics 365 Field Service is not directly linked to a Dynamics 365 Supply Chain Management environment. For this scenario, the article explains how to extend the Copilot Chat in the Field Service app.
- Solution B – where Dynamics 365 Field Service is directly linked to a Dynamics 365 Supply Chain Management environment through the Power Platform Integration. For this scenario, the article explains how to extend the Copilot Chat of a custom model-driven app.
Solution A describes how to create an Azure Function and is based on this article: Cross-environment collaboration with Copilot in Dynamics 365. Therefore, the intended audience is professional developers. Scenario B, however, is targeted at advanced makers.
Note
The feature of extending Microsoft Copilot within a model-driven app is in preview.
Prerequisites
Install the Inventory Visibility Add-in - Supply Chain Management
Example scenario
A Field Service manager is preparing a work order for an upcoming customer site visit. Before dispatching a technician, it's crucial to verify the availability of all required parts. In traditional Field Service workflows, when a Field Service manager creates a work order and adds required products, there is no immediate insight into whether those products are available in inventory, particularly when the work order products are is in the Estimated status and inventory is managed outside of Field Service. This can lead to service delays due to unavailable parts or Partial work order completion.
Rather than logging into the Supply Chain Management system or contacting warehouse personnel, the manager simply opens the Copilot chat embedded within the work order form and selects the Provide WO Products Inventory Info prompt. Within moments, Copilot provides a formatted table displaying product availability across various sites and locations, key insights and recommendations allowing the manager to make quick, informed decisions with confidence.
Solution A – Field Service environment not linked to the Finance environment
By extending the Copilot chat of the Field Service app Field Service managers can check inventory availability directly from the Copilot chat not leaving the Work Order form. A newly introduced prompt guides the manager by suggesting the exact phrase to enter in the Copilot chat, making it easy to trigger the desired functionality and retrieve inventory details efficiently.
Solution architecture
The image illustrates a technical flowchart outlining the integration between Dynamics 365 Field Service and the finance and operations apps through the Inventory Visibility APIs.
The process begins within the Field Service Copilot Chat, where a user interaction triggers an agent flow. This flow retrieves Work Order Products based on a provided Work Order ID.
Next, an HTTP request is sent to an Azure Function, carrying the relevant Product IDs. The Azure Function then initiates a POST call to the Inventory Visibility public APIs hosted in the environment with Finance or Supply Chain Management environment, submitting the Product IDs for inventory checks. The API response is processed and summarized into a prompt, which is then displayed in the Copilot Chat interface for the manager’s review.
This entire workflow is encapsulated within a dedicated Agent Topic tailored for the Field Service app in the Dynamics 365 Field Service instance.
Configuration steps
This section outlines a possible approach for retrieving information from an external system and presenting it to the user in a readable format within the Copilot chat.
Step 1: Create a custom Zero Prompt
The Field Service app has an interactive agent visible and customizable in Copilot Studio called Copilot in Power Apps - Field Service.
Open the Copilot in Power Apps - Field Service agent. In the Topic tab, locate the Field Service Zero Prompt topic and create a copy. This enables customization of the topic, as the standard version is not editable.
Note
The standard Field Service Zero Prompt topic cannot be modified. Using a custom version will exclude it from future updates applied to the standard topic.
Create a new Container inside the Adaptive card as described here: Zero prompt experience (preview)
Save and publish the topic.
Step 2: Create the WO Product Inventory Check topic
Go to Topics and click *Add a Topic from blank drop down as described here: Add topics to Copilot chat in model-driven apps.
Rename it WO Product Inventory Check and define the trigger phrase Provide WO Products Inventory Info.
Tip
Select (...) More -> </> Open code editor to see the code of the agent.
kind: AdaptiveDialog beginDialog: kind: OnRecognizedIntent id: main intent: triggerQueries: - Provide WO Products Inventory Info
Add conditions to ensure the topic activates only in the context of a Work Order. Provide a message otherwise.
actions: - kind: ConditionGroup id: conditionGroup_bzzEnJ conditions: - id: conditionItem_IS8gGk condition: =Global.PA__Copilot_Model_PageContext.pageContext.entityTypeName = "msdyn_workorder" && Global.PA__Copilot_Model_PageContext.pageContext.pageType = "entityrecord" elseActions: - kind: SendActivity id: sendActivity_zQQXIk activity: Product inventory check can only be performed in the context of a Work Order
Create and agent flow to retrieve associated product IDs.
Add the node Add a tool - a New Agent flow. The flow designer opens. Create a flow that:
- accepts a Work Order ID as Input
- queries Work Order Products
- returns as Output the list of product IDs
Call the Inventory Availability API
Develop an HTTP-triggered Azure Function that serves as a wrapper for the Inventory Service APIs. The function accepts inputs including product IDs, site ID, and location ID. See Inventory Visibility API query
Implement the Azure Function following these high-level steps:
- Authenticate with Inventory Service. See Inventory Visibility Authentication for detailed instructions.
- Query Inventory Service Post method
/api/environment/{environmentId}/onhand/indexquery
and pass the required parameters as part of Body - Parse the response JSON and extract the
availableToReserve
value for each product ID.
Warning
Always ensure the API is secured and requires a valid token for invocation from the client application.
Summarize the response
Leverage the the Prompt node in Microsoft Copilot Studio to summarize the response returned by the HTTP call action as described here: Add a prompt to a topic node
An instructions example:
You are tasked with processing an input inventory response details to extract meaningful insights and generate a summary report. The report should highlight key findings, trends, and any actionable recommendations based on the data provided. Summarize the following supply chain inventory data by grouping by Org, Site, Loc and listing each product's ID with its Ava.ToReserve and Inv.Supply values. Include total AvailableToReserve and InventorySupply per product. Give the results in a tabular format for better readability, aligning correctly with dotted lines headers and rows columns. Use as header Org, Site, Loc, Prod, Name, Avalable, Inv.Supply. Provide your data table here: _your data_
Solution B – Field Service environment linked to Supply Chain Management environment
By extending Microsoft Copilot within a custom model-driven app, a tailored agent is created that enables the use of Generative AI orchestration. This functionality currently unavailable in the standard Field Service Copilot chat agent.
With generative orchestration, the agent can intelligently select the most appropriate tools, knowledge sources, topics, and even collaborate with other agents to respond to user queries or react to event triggers.
This solution leverages the ERP MCP Server and the Tool Find Inventory.
Configuration steps
Step 0: Enable extensibility of the Copilot chat agent
Each model-driven app includes an interactive agent, the Copilot chat, which can be customized using Microsoft Copilot Studio. Prior to customization, the feature must be enabled for the environment.
Open the model-driven app in Power Apps, and then on the left navigation bar select the Agents icon, search for Interactive agent, select the ellipses (…) -> and select Configure -> Configure in Copilot Studio. Learn more at Customize Copilot chat in model-driven apps.
A new agent named Copilot in Power Apps –
name
is created, wherename
represents the name of the model-driven app.In Settings, enable Generative AI orchestration for the agent’s responses instead of using the classic approach.
Save and publish the agent and the app.
Step 1: Create a custom Zero Prompt
- In the Topic tab, locate the Platform Zero Prompt topic and create a duplicate. This provides a customizable version of the zero prompt.
- Add a new Container within the adaptive card, following the guidance provided in Zero prompt experience (preview)
- Save and Publish the topic.
Step 2: Create the WO Product Inventory Check topic
Repeat 1 through 4 as outlined in Solution A.
Add a Question node that displays the content of the ProductIds variable (output from the flow).
Prompt: Would you like to verify the inventory availability? Include two choice options: Yes and No.
Add a Condition node to end the current topic if No is selected.
Save and publish the topic.
Step 3: Create the ERPMCPAgent
- Navigate to the general Agent list of Copilot Studio and create a new Agent Do not use the agent list within the Copilot in Power Apps agent, as this will create a child agent.
- Rename the agent ERPMCPAgent
- Add a Tool by selecting Model Context Protocol -> Dynamics 365 ERP MCP, and attach it to the agent.
- In Settings, enable Let other agents connect to and use this one
- Save and publish
Step 4: Connect the ERPMCPAgent to the Copilot in Power Apps agent
- Open the Copilot in Power Apps agent
- In the Overview tab, select Add agent -> Connect an existing agent (Copilot Studio)
- Choose ERPMCPAgent, provide a description, enable Pass conversation history to this agent, and confirm by selecting Add agent
- Select Publish to finalize the connection.
Related content
- Customize Copilot Chat in model-driven app
- Cross-environment collaboration with Copilot in Dynamics 365
- Extend your Copilot Agent in Power Apps with Copilot Studio and new SDK's
Contributors
This article is maintained by Microsoft. It was originally written by the following contributors:
- Sabrina Di Bartolomeo | FastTrack Solution Architect
- Sourajit Samanta | FastTrack Solution Architect