Extending Copilot in D365 Sales – Part 2
Posted by: Dian Taylor | on November 12, 2024
If you’ve worked with Dynamics 365 Sales, before most likely you’ve seen Copilot in Dynamics 365 Sales. Please note that I am not talking about Copilot for Sales, which requires an additional license, I am referring to Copilot that sits inside of the D365 Sales application. Out of the box this Copilot empowers sellers with quick access to sales data from Dynamics 365, allowing sellers to ask questions on Dynamics 365 data, SharePoint documents, right from within the Sales Hub in Dynamics 365 Sales. By extending Copilot in Dynamics 365 Sales, businesses can tailor Copilot’s capabilities to suit specific business requirements. This can include integrating Copilot with external systems to access external data sources and facilitate actions such as asking questions, and creating or updating records in those systems. Last week I wrote an article on how to extend Copilot in Dynamics 365 Sales. In this article I showed you how to create an action from a Power Automate flow, and how to add a new topic that calls the action. You can read the article here if you haven’t yet. This week I am going to pickup from where I left off in my last article. In this article I will continue extending Copilot in Dynamics 365 sales, by adding a menu item/header called ‘Create records’ to the ‘Prompt Guide’ (previously known as the sparkle menu) that holds the ‘Create case’ prompt!
Prompt Guide
If you’re not sure what the Prompt Guide is in Copilot in Sales, let me explain. When you open the Sales Hub in Dynamics 365 and open Copilot (either by opening the side car or navigating to the full page) you’ll see a few ‘button-like’ items on the top of the screen which represent prompt suggestions for sellers. These can be helpful as your sellers are most likely not aware of all the different things they can ask Copilot.
The out of the box the items shown are ‘Get Info’, ‘Ask Questions’ and ‘Stay Ahead’, and below the menu items it says: ‘Use “view prompts” for more suggestions’. The prompt guide shows more prompts that sellers can use, grouped into menu items, for example under the ‘Stay Ahead’ menu item sellers will see ‘Prepare for sales appointments’ and ‘Show emails that need follow up’. Since we can now configure Copilot in Dynamics 365 Sales, it would be beneficial to configure the prompt guide as well.
Configure the Prompt Guide
All configurations for Copilot in Dynamics 365 Sales are done from Copilot Studio. To access Copilot Studio you will need to navigate to https://copilotstudio.microsoft.com and open the ‘Sales Copilot Power Virtual Agents Bot’. The prompt guide is maintained in a topic called ‘SalesSparks’. When I open the ‘SalesSparks’ topic I can see a warning at the top of the screen informing me this topic can’t be edited. This is not a problem, because I can still create a new topic using the same trigger.
To do this I will create a new topic that I call ‘SalesSparks – Custom’. The first thing I need to do after clicking the +New Topic button and entering the Topic’s name, is change the trigger to match the trigger used in the ‘SalesSparks’ topic, which is the ‘event received’ trigger. Then I click ‘edit’ to set the event name to Microsoft.PowerApps.Copilot.RequestSparks. For Priority I enter the number 10. The next 2 nodes I need to add is a ‘Set text variable’ node type which is not available from the node menu. I open the SalesSparks topic again in a separate browser, and I copy the first node below the trigger. (I do this by clicking on the node I want to copy and click the ‘copy’ button on the top.) I navigate back to my custom topic and click the + button below the trigger and select ‘Paste’. I do this twice so I now have 2 nodes below the trigger. Then I change the Variable in the first node from Topic.GetInfo to Topic.CreateCase and I enter ‘Create case’ in the second field in the node. I then change the second node from Topic.GetInfo to Topic.CreateRecords and enter ‘Create records’ in the second field in the node. The text in the second field holds the text that sellers will see in the prompt guide.
In the next node I need to create a variable with a data type of ‘table’. This variable will hold the menu items for the ‘Create Records’ menu. (Yes I realize I only have one item here.) To do this I click on the ‘+’ button below the previous node and I click on ‘Variable Management’ and select the ‘Parse Value’ option. In the ‘Parse Value’ field I enter [ ], the data type is a ‘table’ and I am creating a new variable in the ‘Save As’ field called ‘CreateRecordsSparks’.
In the next node I need to set the value of the CreateRecordsSparks I created in the previous step. I select the ‘Set Variable value’ node and enter the ‘CreateRecordsSparks’ in the ‘Set Variable’ field. Below that I enter the PowerFX formula that holds all the items for the ‘Create Records’ menu, which in this instance is only the ‘Create Case’ menu item. The PowerFX formula is as follows:
[
{
displayName:""&Topic.CreateCase&" ",
type:"PromptText",
isEnabled: true
}
]
For the next node I need to add another variable and set it’s value. I click the ‘+’ button and add another ‘Set a Variable’ node. I click on the arrow below ‘Set Variable’ and click on ‘Create a new variable’. This will add the ‘Var1’ variable. I click on the Var1 variable and change the variable name to ‘SparkGroups‘. Then I click on the arrow in the ‘To Value’ field in the node. I click on ‘Formula’ ‘and enter the below PowerFX formula, by doing this, I am creating the new menu item in the prompt guide in Copilot in D365 Sales.
Filter([
{
displayName:""&Topic.CreateRecords&"",
displaySubtitle:""&Topic.CreateRecords&"",
iconName:"ArrowForward24Regular",
sparks: DropColumns(Filter(Topic.CreateRecordsSparks, isEnabled = true), isEnabled)
}
], CountRows(sparks) > 0
)
In the next node I need to add another ‘Parse’ node. To to this I click on the ‘+’ button below my previous node, select ‘Variable Management’ and select the ‘Parse Value’ option. NOTE: You can also copy the previous parse action and update the data in the node. In the ‘Parse Value’ field I enter [ ], the data type is a table and I am creating another variable, called’ Sparks’ in the ‘Save As’ field. The last two steps are ‘Set Variable’ nodes, which I find under ‘Variable management’ when adding the node. The first node I set the variable to Global.PA_Copilot_Sparks.sparkGroups and in the ‘To Value’ field I enter the below formula. NOTE: These last two variables are the exact same nodes as the last two modes in the out of the box ‘SalesSparks’ topic, which means you can also copy and paste them into your custom topic vs creating them manually.
ForAll(Sequence(CountRows(Global.PA_Copilot_Sparks.sparkGroups)+CountRows(Topic.SparkGroups)), If(Value<=CountRows(Global.PA_Copilot_Sparks.sparkGroups),Index (Global.PA_Copilot_Sparks.sparkGroups,Value), Index(Topic.SparkGroups, Value - CountRows(Global.PA_Copilot_Sparks.sparkGroups))))
In the last node (also a ‘set variable node’) I enter the Global.PA_Copilot_Sparks.sparks variable. In the ‘To Value’ I enter this formula:
ForAll(Sequence(CountRows(Global.PA_Copilot_Sparks.sparks)+CountRows(Topic.Sparks)), If(Value<=CountRows(Global.PA_Copilot_Sparks.sparks),Index (Global.PA_Copilot_Sparks.sparks,Value), Index(Topic.Sparks, Value - CountRows(Global.PA_Copilot_Sparks.sparks))))
And that is it! Don’t forget to save your topic and to publish your changes to they will become visible for your sellers! In order to test this you will need to log out of Dynamics 365 Sales and log back in. You have to do this because the prompt guide is cached in the browser. It will not refresh the menu by just doing a browser refresh. I hope you enjoyed this article, let me know what you think in the comments! If you want to download the code of the custom topic I created, you can do that here. Be sure to check in again next week for a new article or subscribe here to never miss another post!
Posted in Configuration, Copilot, Copilot Studio (previously Power Virtual Agents), D365 Sales | Tags:configure, Copilot in D365 Sales, Copilot in Sales, copilot studio, customize, D365, Dynamics 365, Embedded Copilot, Menu, Sales, Sales Copilot Power Virtual Agents Bot, Sparkle menu, View Prompts, View Prompts Menu | No Comments »