CREATE COPILOT TOPIC (Part 2)
In this blog, we will leverage Copilot and Power Automate to create a customer account in D365 FO based on the trigger phrase that the user has entered followed by questions for further information.
A quick peak into what it looks like in the end,
As soon as a user enters the trigger phrase, Copilot will call the custom topic created and start asking subsequent questions as shown below,
Alright having said this, let's begin!
I. CREATE TOPIC UNDER COPILOT FOR FINANCE AND OPERATIONS
Navigate to Copilot for finance and operations, and create new topic,
Click on 'Add a topic',
As you can see, copilot offers two options when creating a new topic,
- From blank
- Create from description with copilot
In our case, we will use the 'Create from the description with copilot' option. Enter a name for your topic and a quick description as shown below,
Note:
In my case, I am unpinning the copilot section and test section for a better view of the canvas for editing,
Since I selected the second option while creating the topic, it gave me different phrases that essentially would act as a trigger.
Click on '+' under the trigger and navigate to 'Ask a question',
Add a question. In this case, the question would be 'What will be the customer's name?'.
Change identification to 'User's entire response', this means, anything user types will be considered as customer name, there are different options which we will see in future blogs.
Change the save user response as 'String' and provide the variable name as 'CustomerName'.
You can define variable properties on the right side pane as below,
Repeat this step for currency, language and customer group.
Note: Remember to provide a different variable name for each of these nodes (Questions) so we can pass on this information to Power Automate Flow.
Now the overall topic's flow will look as below,
Click on '+' under the trigger, and navigate to call an action and click on 'Create a flow' as shown below,
This will open a power Automate window in another tab. In the next step, we will look at creating a power Automate flow to create a customer account in D365 FO.
II. CREATE POWER AUTOMATE FLOW
Power Automate will populate two nodes automatically since the flow was called from the copilot as shown below,
Click on 'Run a flow from Copilot' and change the name to 'Copilot Create Customer Account' so it's easier to identify in the Copilot Studio later.
Click on 'Run a flow from copilot', this will open a pane on the left side where you can provide inputs.
In this case, we will add inputs for Customer Name, Customer Group, Customer Language and Customer Currency as shown below,
Click on '+' after 'Run a flow from copilot' and click on 'Add an action' as shown below,
When you select 'Add an action', Power Automate will pop up a pane on the left-hand side.
In the search box enter 'Create record', it will show different options.
Select 'Create record' under Fin & Ops Apps (Dynamics 365) as shown below,
Now that you have selected the 'Create record' option, select the node 'Create record'. This will open a pane on the left side.
In this pane, select the Instance where you want the record to be created, followed by an entity; in this case, we will select 'CustomersV3' for creating the customer record.
Once you save the Power Automate draft, it will pop up mandatory fields for creating a customer record as shown below,
Select the input fields we created in Step on 'Run a flow from copilot' respectively. Eg. Currency will have a 'CustomerCurrency' input field and so on.
For this example, we will select the default legal entity as 'USMF' and the Customer account number as '99887766',
Note: I had to change this as there was another customer with '91901', my flow was erroring out.
Once you have completed the required steps. Select 'Response to Copilot' node, the power automate will open pane on left, in this case we will return parameters back to Copilot Studio Topic as shown below,
In this case, we will return the customer account number and customer name.
Save the flow and publish (do not forget to publish).
Now that we have completed the creation of Power Automate, let's head back to updating Copilot Studio in the next step.
III. UPDATES TO TOPIC BASED ON AUTOMATE FLOW
Now that the Power Automate step is completed.
In the Copilot for Finance and Operations apps Click on '+' under the customer language question, navigate to 'Call an action' and select the flow created in the earlier step,
It should bring below screen where you can enter user inputs that will be passed on to customer flow,
Click on 'Message' box and provide details back to users for further information,
Once you enter the details in the message.
Save and publish the topic.
Note: If the Topic is not published, it will not take effect and will not be called in the sidecar in D365 FO.
IV. PROCESS TOPIC IN THE SIDECAR
Now that we have completed creating and publishing the topic.
Navigate to D365 FO and click on sidecar as shown below,
Enter any phrase from the trigger. In this case, I will enter 'Create customer'. This will trigger the copilot topic we created as shown below,
As I enter details, Copilot will start asking subsequent questions from the topic,
Once the copilot and flow complete the flow, it will create a customer record as shown below,
And that's how you can connect Copilot and Power Automate with D365 FO to create a customer record.
Thank you for visiting!