Edit online

Creating Custom AI Actions for the AI Positron add-on

21 May 2025
Read time: 19 minute(s)

In the AI Positron Assistant preferences page, you can define a reference to a folder that contains custom actions.

Once the add-on is installed, the New Document wizard can be used to create either a new AI Positron Custom Action file that contains a custom action definition in JSON format or an AI Positron Custom Actions List that contains a JSON array with multiple defined actions. Validation and content completion are automatically provided for such custom action files. To edit multi-line parameter values, you can switch the edited action JSON definition file to the Author visual editor mode.

If the action definition files are saved in the custom actions folder defined in the AI Positron Assistant preferences page, the AI Positron Assistant view should automatically reload its Actions list to include them.

Various examples of custom AI actions can be found here and can be used as starting points for your own similar AI actions.

An AI action definition may contain the following properties:
id

A unique ID for the action. If the ID of the action starts with agent.hidden.action., then the action is not visible to be invoked directly but can be called by using the invoke_ai_action function.

Example:
{
        "id": "improve.grammar.custom.styles",
        "title": "...",
        ...
}
Note:
An Oxygen desktop plugin can contribute an extra translation.xml file that contains translations. Such a plugin may translate titles and descriptions for AI actions using the action ID as part of the key, for example:
	<key value="improve.grammar.custom.styles.title"> 
		<val lang="en_US">Improve Styles</val> 
		<val lang="de_DE">...</val> 
		... 
	</key>
	<key value="improve.grammar.custom.styles.description">
		<val lang="en_US">Analyze and improve styles.</val>
		<val lang="de_DE">...</val>
		...
	</key>
title
The action name/title that gets presented in the UI. Example:
{
        "id": "improve.grammar.custom.styles",
        "title": "Improve Grammar and Styles",
        ...
}
description
A longer description of what the AI action does, usually used as a tooltip. Example:
{
        "id": "...",
        "title": "Improve Grammar and Styles",
        "description": "Improve the grammar and styles based on the company's style guide."
}
short-description
A shorter description for the AI action that usually appears under the action title in the chat view. If not specified, it defaults to the description value. Example:
{
    "id": "action.translate.to.english",
    "title": "English",
    "short-description": "Translate to English",
    "description": "Translate the selected content to English while preserving its original DITA XML markup.",
    ....
}
categoryId
The optional category in which the AI action is visually grouped, if not specified it defaults to Other. Example:
{
        "id": "improve.grammar.custom.styles",
        "title": "Improve Grammar and Styles",
        "categoryId": "Rewrite"
}
embed-assist
Set this optional boolean parameter to true to add the AI action to the top right AI Positron Assistant drop-down button that appears when editing content in the Author visual editing mode.
quick-assist
Set this optional boolean parameter to true to add the AI action to the quick assist bulb drop down menu that appears in the left vertical stripe.
profile
Set this optional parameter to confine the AI action to be visible only when the add-on is installed in certain application types. Example:
 {
        "id": "action.create.new.xslt",
        "title": "Create New XSLT",
        "profile": "xml_editor, xml_developer",
        ....
}
framework
A framework pattern (like 'DITA*') or content type name (like 'text/css') that, when matched, presents the action when the document pertaining to the framework is opened. Example:
{
    "id": "generate.img.alternate.text",
    "title": "Generate Image Alternate Text",
    "framework": "*DITA*",
    ...
}
An example of an AI action that shows this for any edited XML document (as it matches the text/xml content type) can be found here.
prompt_ref
A reference to a separate file (usually encoded in Markdown) that defines the entire action prompt.
Example:
{
    "id": "action.update.title.based.on.content",
    ....
    "prompt_ref": "prompts/action_update_title.md"
  }
Important:
The prompt is the most important part of the AI action. A prompt must be as precise and detailed as possible. Some companies may adopt prompt methodologies like COSTAR to specify the prompt value. Example of a large prompt file..
context
Multi-line parameter value that defines the prompt that is sent to the AI along with the content to be processed.
Example:
{
    "id": "action.review.logical.mistakes",
    "title": "Logical Inconsistencies",
    "type": "show-response",
    "context": "# CONTEXT #\n\n${contextInfo}\nYou will act as a reviewer interested in finding inconsistentcy and logical mistakes.\n\n# OBJECTIVE #\n\nYou are tasked with reviewing the given content.\nFind logical and inconsistency mistakes in the content and return a report.",
    "expand-params": [
        {
            "name": "contextInfo",
            "value": "${contextInfo}"
        }
    ]
}
Important:
The prompt is the most important part of the AI action. A prompt must be as precise and detailed as possible. Some companies may adopt prompt methodologies like COSTAR to specify the prompt value.
examples
An optional JSON array that encodes examples that may help the AI better understand how to apply the prompt.
Example:
{
  "id" : "replace.bold.with.uicontrol",
  "title" : "Replace bold with uicontrol",
  "input-type" : "markup",
  "type" : "replace-selection-with-fragment",
  "context" : "Find where the bold element (<b>) has been used to mark up UI elements and change those instances by replacing the bold element with the uicontrol element (<uicontrol>). If you find some other content marked up with bold element, content that does not define UI elements, leave it unchanged. Also keep any other content unaltered.",
  "examples" : [ {
    "prompt" : "<b>Run</b>",
    "completion" : "<uicontrol>Run</uicontrol>"
  },
  {
    "prompt" : "text1 <b>Run</b> text2",
    "completion" : "text1 <uicontrol>Run</uicontrol> text2"
  }]
}
Note:
Examples can also be specified as part of the context prompt or as part of the external prompt file referenced with prompt_ref.
expand-params
A JSON array that can define values for parameters that should be expanded in the context content.
All custom AI actions should define and use the ${contextInfo} parameter, which gets expanded to the value of the Context text area in the AI Positron Assistant preferences page. Example:
{
    "id": "thesaurus",
    "title": "Thesaurus/Synonyms",
    "type": "replace-selection-with-fragment",
    "context": "${contextInfo} Return a list of synonym alternatives for:",
    "expand-params": [
      {
        "name": "contextInfo",
        "value": "${contextInfo}"
      }
    ]
  }
You can also define parameters that can be configured by the end user when hovering over the AI action in the UI. Example:
{
  "id": "thesaurus",
  "title": "Thesaurus/Synonyms",
  "type": "replace-selection-with-fragment",
  "context": "${contextInfo} Provide a max of ${number} synonyms for:",
  "expand-params": [
    ...
    {
      "name": "number",
      "label": "Number of synonyms",
      "value": "10",
      "choice-type": "single-choice",
      "alternate-values": [
        "10",
        "20",
        "30"
      ]
    }
  ]
}
The following properties are available for a defined parameter:
name
The parameter name. It can be referenced multiple times with the syntax ${param_name} in the context parameter or in the external prompt file referenced using prompt_ref.
label
The label that appears in the UI when the parameter's value is configured by the end user.
value
The value of the parameter. It can contain various editor variables that get automatically expanded. Example:
{
        "id": "action.update.prolog",
        ...
        "context": "Update the DITA XML topic prolog with the current date ${currentDate}...",
        "expand-params": [
            {
                "name": "currentDate",
                "value": "${date(yyyy-MM-dd)}"
            }
        ]
    }
alternate-values
An optional array of alternate values that are available to be configured by the end user when hovering over the AI action.
choice-type
An optional choice type that defines how the end user can configure the alternate values (combo box, check boxes, radio buttons).
prefix
The optional prefix value to be used for each expansion of the parameter's value.
parameters
An array of parameters that can be used to specify an engine name, temperature, or the available function definitions. Some of the most commonly set parameters:
engine

The optional name of the engine to use with the AI action, no matter what the default AI engine model is configured to be.

Example:
{
    "id": "action.review.logical.mistakes",
    ....,
    "parameters": {
        "engine": {"name": "o1"}
    }
}
temperature
Temperature is an optional parameter that governs the randomness and thus the creativity of the responses. It is always a number between 0 (more deterministic) and 1 (more random). The default value is 0 and it should, in general, remain unspecified when your AI actions are intended for technical documentation that is precise in nature.
function_refs
An optional JSON array that describes which functions can be used when executing this action. The list of functions that can be referenced is available here.
Example of an AI action that uses Retrieval Augmented Generation (RAG) functions to find related content in the project:
{
    "id": "find.add.related.links",
    ...
    "parameters": {
    "function_refs": [
        {"ref": "get_related_resources_overview_from_project"},
        {"ref": "get_content_for_document_url"}
    ]
}
}
Example of an AI action that uses the get_content_for_document_url function to retrieve content from a web site:
{
    "id": "action.get.oxygen.version.web.site",
    "type": "insert-schema-aware-fragment",
    "title": "Insert Latest Oxygen Version",
    "context": "Obtain the latest version of Oxygen from the 'https://www.oxygenxml.com/xml_editor/whats_new.html' web site by calling the function 'get_content_for_document_url' and return it.",
    "parameters": {
        "function_refs": [
            {"ref": "get_content_for_document_url"}
        ]
    }
  }
Important:
There are specific actions that can be called to invoke other AI actions from an AI action, thus creating an agenting mechanism where various parts of the work is done by various actions. An example can be found here.
input-type
Describes how the XML content from the document that is sent to the platform should be processed, as regular XML including markup tags or as plain text without the tags and with all DITA XML content references and key references expanded. By default, its value is assumed to be 'markup', which means the content is sent exactly as it is. Example of an AI action that requires the input to be sent without any markup tags and with the DITA XML conrefs and keyrefs expanded:
{
    "id": "action.answer.questions",
    "type": "show-response",
    "description": "Generate answers to questions you ask based on the selected text or on the entire document content.",
    "input-type": "plain-text",
    ....
  }
type
The type of the AI action. Some of the most commonly used type values are listed below:
replace-selection-with-fragment
The most common type of action. Sends the selected content to the AI platform and proposes to replace the selection with the received response. If there is no selected content automatically, the entire document is selected when the action is invoked.
Example:
{
  "id" : "replace.bold.with.uicontrol",
  "title" : "Replace bold with uicontrol",
  "type" : "replace-selection-with-fragment",
  "context" : "Replace the bold element with the uicontrol element (<uicontrol>)....",
}
insert-schema-aware-fragment
Inserts the content received from the AI engine in the current document at the cursor position or at an offset specified by the insert-modes. If the inserted content is invalid at the proposed offset, the application attempts to find a proper location for it. Example:
{
    "id": "action.update.title.based.on.content",
    "type": "insert-schema-aware-fragment",
    "title": "Update Title",
    "context": "You are tasked with creating a title for the given text, summarizing it and focusing on its main points:"
}
prompt-user
Shows a dialog box that asks for a context and then runs the action.
Example:
{
        "id": "action.formula.equation",
        "title": "Formula/Equation",
        "type": "prompt-user",
        "additional_info": {"prompt-example": "hydrogen peroxide"},
        ...
}
show-response
Sends the selected content or the entire document to the AI platform and shows the response to the end user.
Example:
{
    "id": "action.review.logical.mistakes",
    "title": "Logical Inconsistencies",
    "type": "show-response",
    "context": "Find logical and inconsistency mistakes in the content and return a report.",
}
create-new-document
Shows a dialog box that asks for a context and then creates a new document based on the received server response. The "additional_info"/"properties"/"file_extension" property can be set to impose an extension for the newly created document.
Example:
{
    "id": "action.create.schematron.rules",
    "title": "Schematron Rules from Style Guide",
    "type": "create-new-document",
    "additional_info": {
        "properties": {"file_extension": "sch"}
    },
    "prompt_ref": "prompts/create-schematron-rules.md"
}
insert-modes
A JSON array that defines places for inserting the content in an XML document. The first mode for which the XPath condition becomes true is run. Such modes are used when the AI action type is insert-schema-aware-fragment.
Example:
{
    "id": "action.update.title.based.on.content",
    ...
    "type": "insert-schema-aware-fragment",
    ...
    "insert-modes": [
      {
        "xpath-condition": "(//title)[1]",
        "target-location": "(//title)[1]",
        "action": "replace"
      },
      {
        "target-location": "(//shortdesc)[1]",
        "action": "insert-before"
      }
    ]...
  }

Hope this helped, as always you can use the feedback form below if you want to ask more details about the possibilities of AI actions or want to brag about the custom AI actions you have created.