Assistants

Added in: release-2024-05

Integration of Livingdocs Assistants

Welcome to the developer guide for integrating Assistants within Livingdocs. This guide is designed for developers looking to leverage this feature to enhance productivity and capabilities in their newsroom, using (Gen) AI or any other automation.

Overview

With release-2024-05, we introduced the first version of the Livingdocs Assistants Platform. This platform works on top of the Document Command API and offers a UI in the Livingdocs Editor for users to trigger assistants. These assistants support powerful document manipulations to streamline the content creation process.

The integration mainly involves the following components:

Livingdocs Assistants

Livingdocs Assistants are designed to understand the user’s context, namely the current document and focused components. Assistants can generate an array of commands that are then executed server-side. This feature allows for complex document manipulations through a simplified interface, initiated from the editor UI using the Cmd+K (macOS) or Ctrl+K (Windows/Linux) shortcut, where users can find and execute available assistants.

K-Menu with list of Assistants

Document Command API

The commands generated by assistants are handled by our Document Command API, which supports a variety of operations for manipulating documents. Notably, the publish command is not available to assistants to ensure controlled publishing workflows. The most relevant commands for assistants include setMetadataProperty, setEditableDirective, and the insertComponent command.

Assistant Actors

We believe content created by AI should be denoted as such from the beginning. This is why all changes to documents made as a result of commands from assistants are associated with a special Actor. Per project/assistant combination, a new Actor is created as soon as a document is modified by an assistant. The assistant Actor appears as a special user in the Collaboration UI and is also visible in the history.

Implementing a Livingdocs Assistant

Here’s how you can register an assistant within your project using the liServer.registerAssistant function:

liServer.registerAssistant({
  projectHandles: ['myProject'],
  handle: 'enhanceArticle',
  label: 'Enhance Article',
  description: 'Optimize article elements like metadata and structure.',
  icon: 'wizard-hat',

  async assist({context}) {
    const {document, projectConfig, focusedComponentId} = context
    // Ensure the context is suitable for this assistant
    if (!document) {
      throw new Error("Unsuitable context for the 'enhanceArticle' assistant.");
    }

    // This assistant might use GenAI to enhance the document, if appropriate
    const {headline, lead, seoTitle} = await myGenAIDocumentEnhancer(document)
    return {
      commands: [
        {
          operation: 'setEditableDirective',
          componentId: 'doc-1a2b3c4d5',
          directiveName: 'headline',
          value: headline
        },
        {
          operation: 'insertComponent',
          componentName: 'lead',
          content: {
            text: lead
          },
          position: {
            previousComponentId: 'doc-1a2b3c4d5'
          }
        },
        {
          operation: 'setMetadataProperty',
          propertyName: 'seoTitle',
          value: seoTitle
        }
      ]
    }
  }
})

Possible properties on context:

  • projectConfig
  • documentId (optional)
  • document (optional)
  • focusedComponentId (optional)

Commands are executed with an assistant actor (one per project/assistant combination). Actors are created on demand.

Benefits and Use Cases

Integrating Livingdocs Assistants can significantly improve workflow efficiency, enabling fewer clicks and more automation in document handling. Below are a few potential use cases for such assistants:

  • Adding subtitles: Automatically analyzing content and structuring it with appropriate subtitles.
  • Writing Leads: Generating compelling leads for articles to capture reader interest.
  • SEO Optimization: Automatically setting SEO metadata to improve search engine visibility.

We encourage developers to explore these capabilities and consider how they can be adapted to enhance their workflows.