Set Citation to Open Specific PDF Page In Copilot Studio

Citations can be customized to open a PDF to a specific page in Copilot Studio by appending the text “#page=3”. When the user clicks on the citation the Agent will navigate them to the page making it easy to see what text the Agent uses as a knowledge source. This is very useful for knowledge retrieval agents that return exact text from a set of PDF documents in a SharePoint library.
Table of Contents
• Introduction: The Employment Standards Agent
• Create A New Agent In Copilot Studio
• Add SharePoint Document Library With PDF Files As Knowledge
• Save The Complete LLM Response From A Generative Answers Node
• Get The Answer Variable JSON Schema
• Customize The Citation To Include Page Number
• Output The Answer And Citation In A Message Node
• Test The Clickable Citation To Open PDF To Specific Page
Introduction: The Employment Standards Agent
A team of lawyers uses the Employment Standards Agent to get the answers to their questions from acts and regulations stored in PDF files. When the lawyer clicks on the citation the Agent opens the PDF file to the specific page where the citation has referenced.

Create A New Agent In Copilot Studio
Open Copilot Studio and create a new agent named the Employment Standards Agent.

Fill-in the Agent description and general instructions with this text:
Description: The Agent will help a lawyer to read Employment Standards acts & regulations and answer their questions about the law. General Instructions – Respond to the User’s questions with the exact text from one or more sections of the Employment Standards Act & Regulations knowledge source. – Exact text from the knowledge source should be placed between quotes (example: “The employee must give the employer a copy of the physician’s certificate as soon as possible.”) – Always provide the complete sentence being quoted, do not take an excerpt. |
Add SharePoint Document Library With PDF Files As Knowledge
PDF files must be stored in a SharePoint document library for the Agent to open them to a specific page when the citation is clicked. Create a new SharePoint document library named Employment Standards. Then upload all of the acts & regulations needed for the Employment Standards Agent’s knowledge.

In Copilot Studio, go to the knowledge tab and add the document library as a new SharePoint knowledge source named Employment Standards Acts & Regulations.

Once the SharePoint knowledge source has a Ready status we can move onto the next step.

Save The Complete LLM Response From A Generative Answers Node
Our Agent will use a Generative Answers node to interpret the User’s message and get an answer from the SharePoint document library. Go to the Agent’s system topics and open the Conversational Boosting topic.

Select the Create Generative Answers node and inspect it’s properties. Toggle on the search only selected sources setting and choose the Employment Standards library.

The Generative Answers properties also include a prompt field that tells the node how to behave.

Use these instructions to ensure that the Generative Answers node outputs text with the proper legal citation format.
For any text between quotes provide a citation using the McGill Guide: “Employment Standards Code, CCSM c E110, s 10(2)(a)” In this citation: Statute Name = Employment Standards Code Jurisdiction= CCSM Chapter = c E110 Section Number = 10 Subsection = (2) Paragraph = (a) |
We want to edit the citations to after the Generative Answers is output. Uncheck the send a message checkbox. Then change save LLM response dropdown to complete and store it in a variable named “Answer.”

Get The Answer Variable JSON Schema
All the information we need to determine which page number the citation came from, the url of the cited source and the LLM response is stored in the Answer variable. To view the Answer variable contents, ask the Agent a question.

Open the Conversational Boosting topic then select the Variables tab. Inspect the Answer variable value.

The Answer includes an array of CitationSources with an Id, Name, Text and Url. Notice that the Page Number is found in the Text property.

It also includes the plain text output in the Content field and the combined response with citations in the Markdown field.

Customize The Citation To Include Page Number
A PDF can be opened to a specific page number by appending the value “#page=3.” We will create custom citations that include the page number. Insert a Set A Variable node in the Answer Is Not Blank condition branch.

To do this, we will iterate over all of the citation sources. We will check if the source is a PDF file. Then we will construct the citation in the required format and add the page number.

Copy and paste this code into the Formula field and press the Insert button.
Concat(
Topic.Answer.Text.CitationSources,
If(
// check if cited source is a PDF
EndsWith(Name,".pdf"),
// generate citation markdown
$"[{Id}]: {Url}#page={Mid(
Text,
Find("<page value=", Text
) + Len("<page value=") + 1,
Find(
">",
Text
) - Len("<page value=")-3
)} ""{Name}"""
)
)
Output The Answer And Citation In A Message Node
Now that the PDF file citation includes the page number we will output the message to the User. Add a message node to the topic.

Then use this code to join the Generative Response content to the updated citations variable.
Topic.Answer.Text.Content&Char(10)&Char(10)&Topic.varUpdatedCitations
Test The Clickable Citation To Open PDF To Specific Page
Our customized citations will now open the PDF to the specific page where the Agent found the answer to the User’s questions. Ask the Agent a question and wait for the response.

Click on the citation link in the response and the Agent will open the PDF to the correct page.

Did You Enjoy This Article? 😺
Subscribe to get new Power Apps & Power Automate articles sent to your inbox each week for FREE
Questions?
If you have any questions or feedback about Set Citation to Open Specific PDF Page In Copilot Studio please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.
Hi Matthew,
Thanks for this blog post.
If Generative orchestration is enabled the conversational boosting topic does not trigger. But I guess you can do the exact same thing with citations in a topic with the “AI response generated” trigger?
Arild
Arlid,
You are correct. The major difference other than the trigger is where you find the citations:
System.Response.Citations
Hi Matthew,
What if in text citation, I am not getting page value or html page like <page value> this. Then how to navigate in the particular PDF page.