Menu

Techniques

Knowledge

A key capability of Copilot.js is to discuss your product capabilities and documentation with your users. For example, a user can ask:

  • "Is there a shortcut to create new file?"
  • "Where do I enable two-factor auth?"
  • "What pricing plans are there?"

Enabling knowledge

  1. In Dashboard > Copilots, click on a copilot, and enable the "know the docs" feature:

    Knowledge feature

  2. Under Settings, specify which public webpages will be added to the knowledge base of the copilot:

    Knowledge settings

  3. Under Versions, click on New version to fetch the webpages and make them active.

    Knowledge versions

Customizing citations

When using the knowledge feature, the messages created by the assistant may include citations to the original documents. For example, if you ask about a shortcut, the assistant may respond with:

The shortcut is Command V ([link](https://example.com/shortcuts)).

To customize the citation format, you can supply your own annotationMap prop to <CopilotProvider>. This function receives an annotation object, such as

{
  "type": "file_citation",
  "text": "【4:0†source】",
  "startIndex": 25,
  "endIndex": 37,
  "fileCitation": {
    "fileId": "file-AGXxGB7nDbntKzrntyNMMn",
    "page": {
      "id": "3fd7245f-dc27-4f59-aff8-1b7a25228a7c",
      "url": "https://example.com/shortcuts"
    }
  }
}

and returns a string to represent this citation in the assistant message, such as

 ([link](https://example.com/shortcuts))

The default annotationMap function is:

(annotation) => ` ([link](${annotation.fileCitation.page.url}))`
Previous
How it works