mscrm-addons.com logomscrm-addons.com logo
  • Release History
  • Knowledge Base
  • Documentation
  • Contact Support
  • Release History
  • Knowledge Base
  • Documentation
  • Contact Support
home/Knowledge Base/DocumentsCorePack(DCP)/Document Generation via Copilot in Dynamics 365 Sales using DocumentsCorePack

Document Generation via Copilot in Dynamics 365 Sales using DocumentsCorePack

378 views 0

With Copilot in Dynamics 365, users have the ability to pull up records, receive insights and prepare for meetings all by writing simple prompts.  Copilot aims to assist in streamlining work processes, and by integrating DocumentsCorePack into it, documents can be generated with the power of AI as well.  This article will detail and demonstrate how to generate documents via Microsoft Copilot.

Step-by-step video

This step by step video will walk you through how to enhance Microsoft Copilot with the powerful document generation capabilities of DocumentsCorePack.

AI-Powered Document Generation with Copilot in Dynamics 365 Sales (Video)

Step-by-step description

Creating a topic

We would like to use Copilot to generate an invoice from an invoice record.  This will allow us to quickly generate a document from an invoice after submitting a prompt. 

First, you’ll need to create an agent if you haven’t done so already. In our scenario we want to extend the Dynamics 365 integrated “Copilot in Sales”. Therefore, we open the existing “Copilot in Dynamics 365 Sales” agent in copilotstudio and create a new topic.  Click on Topic in the toolbar and click on Add a new topic -> From blank 

Figure 1: Adding a new topic

In this topic, we will need to create some trigger phrases that will trigger Copilot to generate a document.  Since we want this agent to generate an invoice, we should include phrases like “Create an invoice” or “generate an invoice document.” 

Add a trigger

Figure 2: Create trigger phrases

Then, we’ll need a condition that checks for the record’s GUID and entity, which we’ll need to pass along later to a flow to generate our document.  To do this, we’ll add a condition. 

Adding a condition

Figure 3: Adding a condition

In the Condition window, click Select a variable.  As part of this condition, we will need to check if the record’s GUID is not blank before proceeding.  To do this, find the Global.PA__Copilot_Model_PageContext.pageContext.id.guid variable, which can be found by using “Context.id.guid” as a search term.  Then, set the lower dropdown to is not Blank, letting us ensure that we will only advance if the GUID is not empty. 

Select a variable

Figure 4: Searching for and selecting a variable

In the same window, add a new condition.  This condition will be for checking if our entity is an invoice.  Like previous, click Select a variable, find the Global.PA__Copilot_Model_PageContext.pageContext.entityTypeName by using “Context.entityTypeName” as a search term, and select the corresponding result.  Set the operator to is equal to and select invoice. 

Add a new condition in the same window

Figure 5: The full condition

We’ll configure the other branching path to print a message to the user if the condition is not met.  Afterwards, save your progress. 

Second Branch Configuration

Figure 6: Second branch configuration

Creating an action

Next, navigate to the Actions tab and add an action.  In the Add action window, click New action and select New Power Automate flow.  We’ll need to create one for our topic. 

Adding a new power automate flow action

Figure 7: Adding a New Power Automate Flow action

This will redirect us to the Power Automate editor.  You will notice that we already have two steps within this flow.  In the first step, add a single parameter called “RecordID” to contain the record’s GUID that will be passed in from Copilot. 

single parameter addition

Figure 8: Single parameter called “RecordID”

We’ll need to add a step after this, Create document (sync), from our DocumentsCorePack Connector.  In this step, we will choose the (1) template to be merged, enter the (2) RecordID parameter from the above step, set our (3) filetype to PDF, and set the generated document to be saved to (4) SharePoint. 

create document from DCP connector

Figure 9: Create document (sync) from DocumentsCorePack Connector

For our last step, Respond to the agent, we want to return the document URL and filename to Copilot.  To retrieve the document URL, you will need to insert the Return value 2 variable from the previous step into a replace function, as the variable contains an encoded version of the URL.  For the filename, you can also get that from the previous step via the File name variable. 

Return document URL and filename to copilot

Figure 10: Return document URL and filename to Copilot

Save your flow once you’re finished and return to the Add action window.  Select the flow you created. 

Add action window

Figure 11: Return to Add action window

You will be prompted to configure your flow’s inputs and outputs. Under inputs, select the RecordID parameter. 

select RecordID parameter under inputs

Figure 12: Select RecordID parameter under inputs

Under How will the agent fill this input, set it to Set as value.  The value needs to be the record’s GUID, meaning we will need to search for and enter the Global.PA__Copilot_Model_PageContext.pageContext.id.guid variable into the field. 

Set as value for agent to fill

Figure 13: Set as value for agent to fill

After entering the value, click Done. Then, after ensuring DocumentURL and Filename have been added as outputs, click Add action. 

Add action

Figure 14: Add action

Returning to our topic 

Return to the topic we created earlier. Under our condition, click on the plus (+) button and select Add an action. In the subsequent window, select the flow we created. 

return to topic and add action

Figure 15: Return to topic and add an action

Our final addition to our topic will be our message to the user containing the generated document.  Under our flow, click on the plus (+) button once more and select Send a message.  Enter the text you would want to display. 

On top of this, we will have to create a formula that displays our document in a clickable link.  This can be done by clicking on the formula (fx) button and entering the following formula into the field: 

“[” & Topic.filename & “](” & Topic.documenturl & “)” 

After entering the formula, click Insert.  Then, save and publish your agent. 

insert a formula

Figure 16: Inserting formula

Testing our agent

Our agent can be tested on any invoice record by entering a simple prompt in Copilot.  As an example, we will test it on the following invoice. 

example invoice

Figure 17: Example invoice

By entering a prompt in Copilot, we can receive a link to our generated document. 

copilot prompt

Figure 18: Enter prompt in Copilot

Click on the link which will bring us to the document itself. 

Final invoice

Figure 19: Final invoice document from Copilot

That’s it! We appreciate your feedback! Please share your thoughts by sending an email to support@mscrm-addons.com 

Was this helpful?

Yes  No
Related Articles
  • Deploying DocumentsCorePack: Setup, Automation, and Real Business Impact in Dynamics365
  • Introducing the DocumentsCorePack Template Designer Office Add-In (Beta)
  • 3 Ways DocumentsCorePack Transforms Proposal, Quote, and Contract Creation
  • DeepSign for DocumentsCorePack 
  • Generate and send a document for e-signing using DeepSign
  • How to prepare a document for DeepSign
Latest Articles
  • What Happens After You Deploy AttachmentExtractor: Storage & Cost Savings in Dynamics 365
  • Deploying DocumentsCorePack: Setup, Automation, and Real Business Impact in Dynamics365
  • Introducing the DocumentsCorePack Template Designer Office Add-In (Beta)
  • How to Eliminate Excess Storage Costs in Microsoft Dynamics 365 Without Losing Access to Emails and Attachments
  • 3 Ways DocumentsCorePack Transforms Proposal, Quote, and Contract Creation
Popular Articles
  • DocumentsCorePack Template Designer – Getting Started
  • Step-by-Step: How to configure a One-Click-Action
  • Application Access for Dynamics 365
  • How to find your environment’s unique name in Microsoft Dynamics 365
  • How licenses are counted
Top Rated Articles
  • “Undefined”-labels in Chrome and Edge 114 and higher
  • Important information for Dynamics 365 online customers using DocumentsCorePack and/or AttachmentExtractor
  • How to activate the DocumentsCorePack Connector for PowerApps & Microsoft Flow
  • How to insert Condition Fields in DocumentsCorePack Templates designer
  • How licenses are counted
Categories
  • *News and General Infos* 64
  • Webinars 45
  • Template Designer(DCP 196
  • DocumentsCorePack(DCP 258
  • TelephoneIntegration (TI 65
  • AttachmentExtractor (AE 75
  • PowerSearch (PS 50
  • ActivityTools (AT 61
  • SmartBar (SB 54
  • GroupCalendar (GC 47
Our Vision

“We see it as our purpose to provide products that simplify and speed up our customers’ Microsoft Dynamics 365 experience.”

Knowledgebase
LogIn
mscrm-addons.com
  • Products
  • Online Shop
  • Downloads
  • My Account
About Us
  • About Us
  • Case Studies
  • Newsletter
  • Partner Program
  • Contact
Support
  • Support
  • Terms & Conditions
  • Documentation
  • Webinars
  • Legal Documents
  • Impressum
  • © 2025 www.mscrm-addons.com. All Rights Reserved.