Skip to content

Crownpeak/function-server-example-confluence

Repository files navigation

FirstSpirit Function Server Example Module | Confluence

This project demonstrates how to implement a custom Function Server for FirstSpirit AI. A Function Server extends the FirstSpirit AI capabilities by registering custom functions that the AI can invoke autonomously during prompt execution. This enables the AI to access external data sources, execute business logic, or delegate complex computations to your own code. When processing user requests, the AI analyzes available functions and automatically selects and calls the appropriate ones based on their definitions and the context of the request.

This example module illustrates how to create your own Confluence connector, which can retrieve information from a Confluence instance.

References

Requirements

  • FirstSpirit 2025.11 or newer
  • Java 17
  • Gradle 8.11 or newer
  • Confluence
    • You need a technical user that has permission to access your Confluence instance.

The following Gradle properties must be set in order to build the module. Make sure to add them to the file ~/.gradle/gradle.properties in your local home directory:

artifactory_hosting_username=CLOUD_USERNAME
artifactory_hosting_password=CLOUD_ENCRYPTED_PASSWORD

The encrypted cloud password can be retrieved through a Artifactory REST API call (requires an authenticated session).

Usage

  • Build the module using ./gradlew build and install it in your FirstSpirit server
    • You can find the FSM file under build/fsm/fs-ai-function-server-example-confluence-<version>.fsm
  • Add an API Token for the Confluence user that you want to use. Give it an indicative name and optionally an expiry date.
  • In the ServerManager, open the configuration for the 'Confluence | Function Server Configuration Service'. Add the API Token and the email address for the Confluence that you want to use, and set the Confluence URL.
    • Optional: Define special pages as JSON that can be used to provide specific information to the AI. The module will automatically create matching functions for those pages. E.g.:
      [ 
          {
            "id" : "2848522241",
            "functionName" : "glossary",
            "description" : "provides a term register for technical terms to use in writing"
          },
          {
             "id" : "2848260211",
             "functionName" : "writing-guidelines",
             "description" : "provides set of mandatory writing guidelines to follow when creating texts"
          } 
      ]
      will create two AI functions called 'glossary' and 'writing-guidelines' for the two Confluence Pages. The AI will automatically invoke those functions to fetch these pages when required.
  • In the FirstSpirit AI Configuration, define a new prompt.
  • In the configuration dialog for the prompt, allow the functions from this module to be called by simply adding the plugin ConfluenceExampleFunctionServerPlugin to the list of allowed functions.
  • Execute your prompt operation in the FirstSpirit ContentAssistant to see the results. The FirstSpirit AI will automatically call the function if it is appropriate for the current request.

About

Demonstrates how to implement a custom Function Server for FirstSpirit AI connecting to a Confluence instance

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages