Documentation can be indexed by using the Plain CLI. With it you can index:

  • a single URL
  • a sitemap URL (each entry in the sitemap is indexed)
  • Optional: add a label type ID to associate the document with

For installation and usage instructions, please see the Plain CLI docs.

Labels

If you provide a label type ID when indexing a document, suggested responses will only use the documentation when the thread has the specified label type also associated.

This is useful for example if you have different products that you support, with different documentation.

Automation

To keep indexed documents up to date, you can automate the indexing process the Plain CLI on a schedule.

Github Actions example

Here is an example Github Action to re-index the documents using the Plain CLI run on a schedule.

  • The action runs every 3 hours
  • The action uses the PLAIN_API_KEY secret to authenticate with the Plain API
  • The action indexes all URLs in the sitemap

The PLAIN_API_KEY requires the following permissions:

  • indexedDocument:create
name: Index docs

on:
  schedule:
    - cron: '0 */3 * * *'

jobs:
  lint:
    name: Index Documents
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v3
        with:
          node-version: '18'

      - name: Install CLI
        run: npm install -g @team-plain/cli@latest

      - name: Index Documents
        run: plain index-sitemap https://www.plain.com/docs/sitemap.xml --labelTypeIds lt_01G0EZ1XTM37C643SQTDNXR1
        env:
          PLAIN_API_KEY: ${{ secrets.PLAIN_API_KEY }}`