### Download a text file Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/step-library/steps/DOWNLOAD.md
Example demonstrating how to use the DOWNLOAD step to create and download a text file.
```APIDOC
## Example: Download a text file
This example shows how to set text content and then download it as a file named 'hello.txt'.
### Steps
1. **SET**: Define the text content to be downloaded.
- `text`: "Some text to download"
2. **DOWNLOAD**: Initiate the file download.
- `filename`: "hello.txt"
### Configuration
```yaml
- step: SET
text: "Some text to download"
- step: DOWNLOAD
filename: "hello.txt"
```
```
--------------------------------
### Simple GET Request Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/step-library/steps/REST.md
An example demonstrating how to perform a simple GET request using the REST step.
```APIDOC
## Simple GET Request
### Description
This example shows a basic GET request to retrieve items from an API and output the response as JSON.
### Method
GET
### Endpoint
`https://api.example.com/items`
### Parameters
#### Query Parameters
None
#### Request Body
None
### Request Example
```yaml
- step: REST
url: "https://api.example.com/items"
method: "GET"
outputs:
- type: json
name: items
```
### Response
#### Success Response (200)
- **items** (json) - The JSON response from the API.
#### Response Example
```json
{
"example": "response body"
}
```
```
--------------------------------
### Complete Context Menu Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/swing-integration.md
Example of a complete context menu action for translating content. This demonstrates defining a title, description, and a multi-step flow.
```yaml
- title: "Quick Translate"
description: "Translate content to French"
swing:
contextMenu:
enable: true
flow:
- step: DEEPL_TRANSLATE
instruction: "{textContent}"
target_lang: "FR"
- step: SHOW_RESPONSE
title: "Translation"
```
--------------------------------
### Basic Text Menu Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/menus-and-triggers.md
A simple example of a text menu with 'Rewrite', 'Shorten', and 'Translate' actions.
```yaml
story:
items:
- type: 'button'
icon: 'fa fa-redo'
title: 'Rewrite'
flowRef: 'rephraseSelection'
- type: 'button'
icon: 'fa fa-compress'
title: 'Shorten'
flowRef: 'shortenSelection'
- type: 'button'
icon: 'fa fa-language'
title: 'Translate'
flowRef: 'translateSelection'
```
--------------------------------
### Simple GET Request Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/step-library/steps/REST.md
Demonstrates a basic GET request to an API endpoint. Specifies the output type as JSON and names the output 'items'.
```yaml
- step: REST
url: "https://api.example.com/items"
method: "GET"
outputs:
- type: json
name: items
```
--------------------------------
### SKILL.md YAML Front-Matter Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/ai-integration.md
Example of a SKILL.md file with YAML front-matter defining skill properties like name, description, and loading mode.
```markdown
---
name: Editorial Style Guide
description: House style rules for all published content
loading_mode: immediate # 'immediate' (default) or 'on_demand'
---
Always use active voice. Avoid passive constructions.
Use Oxford commas in all lists.
Headlines must be in title case.
Quotes require attribution in the same paragraph.
```
--------------------------------
### File Rotation Configuration Examples
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/hub/config/logging.md
Examples of values for maxFileSize and maxFiles to control log file rotation and retention.
```text
Example maxFileSize values:
- 10m - 10 megabytes
- 100m - 100 megabytes
- 1g - 1 gigabyte
Example maxFiles values:
- 7d - 7 days
- 14d - 14 days
- 30d - 30 days
- 10 - Keep 10 files
```
--------------------------------
### Complete Text Menu Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/menus-and-triggers.md
Provides a comprehensive example of a text menu configuration, including multiple buttons for various text manipulation actions.
```yaml
# /SysConfig/ProActions/text.ai-kit.menu.yaml
story:
items:
- type: 'button'
icon: 'fa fa-magic'
title: 'Improve'
flowRef: 'improveSelection'
- type: 'button'
icon: 'fa fa-redo'
title: 'Rewrite'
flowRef: 'rewriteSelection'
- type: 'button'
icon: 'fa fa-compress'
title: 'Shorten'
flowRef: 'shortenSelection'
- type: 'button'
icon: 'fa fa-expand'
title: 'Expand'
flowRef: 'expandSelection'
```
--------------------------------
### Complete Example: Text-to-Speech Toolbar Button Integration
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/swing-integration.md
This comprehensive example demonstrates how to create a custom tab, register a command for text-to-speech functionality, and add a corresponding button to the editor toolbar.
```javascript
// Create tab
eidosmedia.webclient.extensions.editor.tabs.add({
name: "em-tab-proactions",
label: "ProActions",
});
// Register command
eidosmedia.webclient.commands.add({
name: "custom.proactions.tts",
isActive: function (ctx) {
if (ctx.component.getType() === "toolbar") {
return true;
}
return false;
},
isEnabled: function (ctx) {
return true;
},
action: function (ctx, params, callbacks) {
SwingProActions.executeAction(ctx, "proactions.tts");
},
});
// Add button
eidosmedia.webclient.actions.editor.toolbar.addButton({
action: "custom.proactions.tts",
label: "TTS",
icon: "fas fa-podcast",
tabId: "em-tab-proactions",
});
```
--------------------------------
### END Step Examples
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/step-library/steps/END.md
Examples demonstrating various ways to use the END step.
```APIDOC
## END Step Examples
### End flow if condition met
```yaml
- step: END_IF
condition: "{{errorOccurred}}"
```
### End flow with notification
```yaml
- step: END_IF
condition: "{{noDataAvailable}}"
notification:
type: "warning"
message: "No data available for processing"
title: "Flow Terminated"
```
### End flow unconditionally with success notification
```yaml
- step: END
notification:
type: "success"
message: "Processing completed successfully"
title: "Done"
```
```
--------------------------------
### Example Object Action Integration
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/swing-integration.md
Provides an example configuration for an 'Extract Keywords' object action. It includes a description and a flow for extracting keywords using AI.
```yaml
- title: "Extract Keywords"
description: "Extract keywords from the document"
swing:
objectAction:
enable: true
flow:
- step: HUB_COMPLETION
instruction: "Extract 10 relevant keywords from: {textContent}"
response_format: "list"
# ...
```
--------------------------------
### Basic Workflow Structure for Debugging
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/howto/debug-flows.md
Start with a simple workflow structure. Add complexity incrementally to isolate issues. This example shows a basic YAML structure.
```yaml
- step: SCRIPTING
script: |
// Start simple
return flowContext;
```
--------------------------------
### Numeric FOR Loop Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/step-library/steps/FOR.md
Use this snippet to execute a set of steps a specific number of times. Ensure 'var', 'start', and 'end' are defined for numeric loops.
```yaml
- step: FOR
var: "i"
start: 1
end: 5
do:
- step: SET
iteration: "{{ flowContext.i }}"
```
--------------------------------
### YAML Include Path Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/howto/debug-flows.md
Verify include paths for sections. Paths can be absolute (starting with /SysConfig) or relative (using ./ or ../). Ensure the file exists and is readable.
```yaml
# Check if file exists
AI_KIT:
SECTIONS:
- !include /SysConfig/ProActions/sections/my-actions.ai-kit.section.yaml
```
--------------------------------
### Full Flow Example with Variables and Hub Completion
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/howto/debug-flows.md
An example of a complete flow that sets a variable, uses it in a HUB_COMPLETION instruction, and then displays the result in a notification. This illustrates a multi-step process.
```yaml
- title: 'Test Full Flow'
flow:
- step: SET
myVar: "Hello"
- step: HUB_COMPLETION
instruction: "Process: {{ flowContext.myVar }}"
- step: SHOW_NOTIFICATION
message: "{{ flowContext.text }}"
```
--------------------------------
### Configuration Options
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/swing-integration.md
Configuration examples for icons, menus, and error handling within ProActions.
```APIDOC
#### Choose Appropriate Icons
Use FontAwesome icons that clearly represent the action:
```yaml
# Text improvement
icon: "fa fa-magic"
# Compression/shortening
icon: "fa fa-compress"
# Translation
icon: "fa fa-language"
# Generation/creation
icon: "fa fa-lightbulb"
```
#### Combine Integrations for Consistency
Make frequently-used actions available in multiple places:
```yaml
- title: "Generate Headlines"
swing:
inlineMenu:
enable: true
icon: "fa fa-heading"
objectAction:
enable: true
contextMenu:
enable: true
```
#### Handle Errors Gracefully
Use TRY/CATCH in flows to handle failures:
```yaml
flow:
- step: TRY
try:
- step: HUB_COMPLETION
instruction: "Process: {selectedText}"
- step: REPLACE_TEXT
at: CURSOR
catch:
- step: SHOW_NOTIFICATION
message: "Processing failed. Please try again."
type: "error"
```
#### Test in All Contexts
Test your integrations in:
- Report editor
- Story editor
- DWP editor
- Search results
- Explorer view
#### Respect Read-Only Mode
Set `allowReadOnly: false` for actions that modify content:
```yaml
swing:
inlineMenu:
enable: true
allowReadOnly: false # Disable in read-only mode
```
```
--------------------------------
### Hotkeys-js Syntax Examples
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/setup/keyboard-shortcuts.md
Examples of defining keyboard shortcuts using the hotkeys-js syntax for various key combinations.
```javascript
openHotkey: 'ctrl+k'
```
```javascript
openHotkey: 'cmd+k'
```
```javascript
openHotkey: 'alt+p'
```
```javascript
openHotkey: 'shift+space'
```
--------------------------------
### Basic One-Click Menu Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/menus-and-triggers.md
An example of a basic one-click menu item configuration. This specific item is configured to suggest headlines for paragraph elements.
```yaml
story:
items:
- type: 'button'
icon: 'fa fa-list'
title: 'Suggest headlines'
flowRef: 'suggest_headlines'
forContentItem:
- grouphead
forElement:
- p
- dummyText
```
--------------------------------
### Troubleshoot Service Won't Start (Podman)
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/hub/operations/operations-guide.md
Commands to investigate why a ProActions Hub container fails to start or exits immediately when using Podman. This includes checking logs, status, and inspecting the container.
```bash
# Check container logs
podman logs proactionshub
# Check container status
podman ps -a | grep proactionshub
# Inspect container
podman inspect proactionshub
```
--------------------------------
### Complete Inline Menu Action Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/swing-integration.md
A comprehensive example for an 'Improve Selected Text' inline menu action. Includes description, swing configuration, and flow steps for AI-powered text improvement.
```yaml
- title: "Improve Selected Text"
description: "Use AI to improve the selected text"
swing:
inlineMenu:
enable: true
label: "Improve"
icon: "fa fa-magic"
allowReadOnly: false
isEnabled: "{{ ctx.activeDocument.getSelection().getNode().elementName == 'p' }}"
flow:
- step: HUB_COMPLETION
behavior: "You are a writing assistant that improves text clarity and style."
instruction: "Improve this text: {selectedText}"
- step: REPLACE_TEXT
at: CURSOR
```
--------------------------------
### POST Request with JSON Body Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/step-library/steps/REST.md
An example illustrating a POST request with query parameters and a JSON body.
```APIDOC
## POST Request with JSON Body
### Description
This example demonstrates a POST request including query parameters, custom headers, and a JSON request body. Variables from the flow context can be used within these fields.
### Method
POST
### Endpoint
`https://api.example.com/items`
### Parameters
#### Query Parameters
- **query** (string) - Required - The value of the query parameter is resolved from `flowContext.somevar`.
#### Request Body
- **myData** (object) - Required - Contains nested fields, including `supportsAlsoVars` which is resolved from `flowContext.myVar`.
### Request Example
```yaml
- step: REST
url: "https://api.example.com/items"
method: "POST"
parameters:
query: "{{ flowContext.somevar }}"
headers:
Authorization: "Client-ID XXXXX-XXXXXXXXXXXXXXXXXXXXX"
body:
myData:
supportsAlsoVars: "{{ flowContext.myVar }}"
```
### Response
#### Success Response (200)
- **text** (string) - Default textual response if no specific outputs are configured.
#### Response Example
```json
{
"example": "response body"
}
```
```
--------------------------------
### Tools Log Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/hub/config/logging.md
Example JSON structure for tools logs, showing timestamp, level, module, tool ID, URL, and duration.
```json
{
"timestamp": "2024-01-15T10:30:00.123Z",
"level": "info",
"message": "Content extraction completed",
"module": "tools",
"tool": "extract",
"url": "https://example.com/article",
"duration": 789
}
```
--------------------------------
### HTTP Transport Configuration Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/hub/mcp-gateway.md
Example configuration for the HTTP transport, specifying the server URL and custom headers for authentication. Ensure sensitive tokens are managed securely.
```yaml
mcp:
servers:
- name: secure-remote
transport: http
url: https://trusted-mcp.internal.example.com/v1
headers:
Authorization: "Bearer ${SECURE_TOKEN}"
X-API-Key: ${API_KEY}
```
--------------------------------
### Simple USER_SELECT Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/step-library/steps/USER_SELECT.md
Demonstrates a basic USER_SELECT step with a prompt. The list of options can be provided directly or sourced from prior steps or flow context.
```yaml
- step: USER_SELECT
promptText: "Choose an option"
# list can be taken from prior steps or from the flowContext
```
--------------------------------
### Configuration Volume Mount (Read-Only)
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/hub/configuration.md
Example of mounting the configuration file into the container as read-only.
```text
./config.yaml:/usr/src/app/dist/config.yaml:ro
```
--------------------------------
### Service Configuration Examples
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/ai-integration.md
Configure services like HUB, OPENAI_COMPLETION, and AZURE_OPENAI_COMPLETION in your services.yaml file. Specify type, endpoint, target, and model options.
```yaml
HUB:
type: completion
endpoint: '{BASE_URL}/swing/proactions'
target: openai
defaultBehavior: 'You are a helpful assistant for authors.'
options:
temperature: 0.7
max_tokens: 800
OPENAI_COMPLETION:
type: completion
apiKey: sk-...
endpoint: 'https://api.openai.com/v1'
model: gpt-4o
options:
temperature: 0.7
AZURE_OPENAI_COMPLETION:
type: completion
endpoint: 'https://your-resource.openai.azure.com'
apiKey: '...'
deploymentId: 'gpt-4o'
apiVersion: '2024-02-15-preview'
```
--------------------------------
### startsWith Filter Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/getting-started/working-with-variables.md
Returns true if a text string starts with the specified prefix.
```nunjucks
{{ flowContext.slug | startsWith('news-') }}
```
--------------------------------
### SELECTED_OBJECT - Get Selected Content ID
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/step-library/steps/SELECTED_OBJECT.md
This example demonstrates how to retrieve only the ID of the selected content object.
```APIDOC
## SELECTED_OBJECT /api/selected_object
### Description
Retrieves the ID of the currently selected content object.
### Method
GET
### Endpoint
/api/selected_object
### Parameters
#### Query Parameters
- **output** (string) - Optional - Specifies the desired output format. Use 'text' to get only the ID.
### Request Example
```yaml
- step: SELECTED_OBJECT
outputs:
- type: text
name: selectedId
```
### Response
#### Success Response (200)
- **selectedId** (string) - The ID of the selected content object.
```
--------------------------------
### Async Client Adapter Scripting Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/release-notes.md
Demonstrates the use of `async/await` with client adapter methods like `getUserData`, `setUserData`, and `getBasefolder`. This is required for client methods that were previously synchronous.
```yaml
- step: SCRIPTING
mode: async
script: |
const prompts = await client.getUserData('prompts');
prompts.push({ id: 'new', text: 'example' });
await client.setUserData('prompts', prompts);
flowContext.baseFolder = await client.getBasefolder(client.getDocumentId(), 'image');
return flowContext;
```
--------------------------------
### Full Keyboard Shortcut Setup with Instant Actions
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/setup/keyboard-shortcuts.md
This configuration includes both opening Swing ProActions and executing instant actions with different key combinations.
```xml
```
--------------------------------
### SELECTED_OBJECT - Get Selected Content Info
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/step-library/steps/SELECTED_OBJECT.md
This example shows how to retrieve the full information object of the selected content.
```APIDOC
## SELECTED_OBJECT /api/selected_object
### Description
Retrieves the full information object of the currently selected content object.
### Method
GET
### Endpoint
/api/selected_object
### Parameters
#### Query Parameters
- **output** (string) - Optional - Specifies the desired output format. Use 'object' to get the full information.
### Request Example
```yaml
- step: SELECTED_OBJECT
outputs:
- type: object
name: selectedInfo
```
### Response
#### Success Response (200)
- **selectedInfo** (object) - The full information object of the selected content.
```
--------------------------------
### AI Agent Call: Simple Confirmation
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/ai-integration.md
Example of an AI agent calling the `askConfirmation` tool to get a simple Yes/No answer from the user.
```javascript
askConfirmation("Publish this article to production?")
```
--------------------------------
### HUB_MCP_TOOLS - List all MCP servers and tools
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/step-library/steps/HUB_MCP_TOOLS.md
This example demonstrates how to list all available MCP servers and their associated tools using the HUB_MCP_TOOLS step.
```APIDOC
## HUB_MCP_TOOLS - List all MCP servers and tools
### Description
Lists all available tools from an MCP server via the Hub.
### Method
POST
### Endpoint
/em-al-wi/proactions-docs-md
### Parameters
#### Query Parameters
- **server** (string) - Optional - The name of the MCP server to list tools from.
### Request Example
```yaml
- step: HUB_MCP_TOOLS
```
### Response
#### Success Response (200)
- **object** - The list of available tools (and resources/prompts if provided by the Hub API).
#### Response Example
```json
{
"tools": [
{
"name": "tool1",
"description": "Description of tool1"
},
{
"name": "tool2",
"description": "Description of tool2"
}
]
}
```
```
--------------------------------
### Implement Multi-Step Generation Pattern
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/workflow-design.md
This pattern guides users through a multi-step content creation process, starting with requirements gathering and progressing to final generation.
```yaml
- title: 'Guided Article Creation'
flow:
# Step 1: Collect requirements
- step: FORM
form:
topic:
type: text
label: 'Topic'
tone:
type: select
label: 'Tone'
options: [Professional, Casual]
# Step 2: Generate outline
- step: HUB_COMPLETION
instruction: 'Create article outline about {{ flowContext.topic }}'
response_format: 'list'
# Step 3: Let user select sections
- step: USER_SELECT
promptText: 'Choose sections to include:'
# Step 4: Generate full article
- step: HUB_COMPLETION
instruction: 'Write {{ flowContext.tone }} article about {{ flowContext.text }}'
- step: INSERT_TEXT
at: CURSOR
```
--------------------------------
### Using !include Directive for Configuration Files
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/setup/configuration.md
Demonstrates how to split configuration into multiple files using the !include directive with absolute paths. Ensure correct pathing for proper inclusion.
```yaml
AI_KIT:
SERVICES:
!include /SysConfig/ProActions/services.ai-kit.services.yaml
SECTIONS:
- !include /SysConfig/ProActions/sections/headlines.ai-kit.section.yaml
- !include /SysConfig/ProActions/sections/translation.ai-kit.section.yaml
```
--------------------------------
### One-Click Menu Configuration Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/menus-and-triggers.md
Sets up items for the one-click menu, including button details and conditions for display based on content item group and element type.
```yaml
# /SysConfig/ProActions/menu.oneclick.yaml
story:
items:
- type: 'button'
icon: 'fa fa-lightbulb'
title: 'Suggest headlines'
flowRef: 'suggest_headlines'
forContentItem:
- grouphead
forElement:
- p
- dummyText
```
--------------------------------
### Get ProActions Configuration
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/swing-integration.md
Retrieves the complete ProActions configuration object, including details about AI kit sections and services. Useful for debugging or understanding the current setup.
```javascript
const config = aikit.getConfig();
console.log(config.AI_KIT.SECTIONS);
console.log(config.AI_KIT.SERVICES);
```
--------------------------------
### Play Audio from HTTP URL
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/step-library/steps/PLAY_AUDIO.md
This snippet shows how to play audio directly from an HTTP or HTTPS URL. Autoplay is disabled in this example, requiring user interaction to start playback.
```yaml
- step: PLAY_AUDIO
in: "https://example.com/audio.mp3"
autoplay: false
```
--------------------------------
### File Logging Structure Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/hub/config/logging.md
Illustrates the file naming convention for logs when file logging is enabled, including date-based partitioning.
```text
logs/
├── app-access-2024-01-15.log
├── app-error-2024-01-15.log
├── app-aiLink-2024-01-15.log
└── ...
```
--------------------------------
### Simple Input Form Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/forms-and-inputs.md
Demonstrates a basic form with text, number, and select input fields, along with cancel and submit buttons.
```yaml
- title: 'Generate Custom Content'
flow:
- step: FORM
form:
topic:
type: text
label: "Topic"
placeholder: "Enter article topic"
required: true
wordCount:
type: number
label: "Word Count"
min: 100
max: 2000
default: 500
tone:
type: select
label: "Tone"
options:
- Professional
- Casual
- Academic
buttons:
- type: cancel
- type: submit
label: "Generate"
- step: HUB_COMPLETION
instruction: |
Write a {{ flowContext.wordCount }}-word article about {{ flowContext.topic }}
in a {{ flowContext.tone }} tone.
- step: INSERT_TEXT
at: CURSOR
```
--------------------------------
### Browser Interaction Steps
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/getting-started/understanding-steps.md
Examples of browser interaction steps like downloading files, reading, and writing to the clipboard.
```yaml
- step: SET
text: '{{ flowContext.generatedContent }}'
- step: WRITE_CLIPBOARD
```
--------------------------------
### Switch with Button Selection
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/step-library/steps/SWITCH.md
This example demonstrates using a FORM step to capture user input, then using a SWITCH step to execute different actions based on the selection. The 'condition' references the output from the FORM.
```yaml
- step: FORM
form:
selectedAction:
type: 'select'
label: 'Choose action'
options:
- 'translate'
- 'summarize'
- 'improve'
buttons:
- type: 'submit'
- step: SWITCH
condition: "{{ flowContext.selectedAction }}"
cases:
"translate":
- step: DEEPL_TRANSLATE
instruction: "{textContent}"
target_lang: "FR"
"summarize":
- step: HUB_COMPLETION
instruction: "Summarize: {textContent}"
"improve":
- step: HUB_COMPLETION
instruction: "Improve: {textContent}"
"default":
- step: SHOW_NOTIFICATION
message: "No action selected"
```
--------------------------------
### SKILL.md Referencing Documents Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/ai-integration.md
Example SKILL.md demonstrating how to reference external documents using the `read_skill_reference` tool.
```markdown
---
name: Fact Checking Workflow
description: Guidelines and sources for fact-checking articles
---
Before publishing, verify all factual claims against approved sources.
Use read_skill_reference("fact-checking", "source-list.md") to get the
approved source directory.
```
--------------------------------
### XPath Context Specification Examples
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/setup/keyboard-shortcuts.md
Examples of specifying XPath expressions for the `instantActionContext` property, including single and multiple contexts.
```yaml
# Single context
instantActionContext: "/doc/story/body/p"
```
```yaml
# Multiple contexts
instantActionContext: "/doc/story/body/p,/doc/story/headline/p,/doc/story/standfirst/p"
```
--------------------------------
### Detailed Article Extractor Response Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/hub/config/tools.md
An example of a detailed response from the article extractor, including source URL and domain.
```json
{
"title": "How to Configure ProActions Hub",
"description": "A comprehensive guide to configuring ProActions Hub",
"author": "Jane Developer",
"published": "2024-01-15T10:30:00.000Z",
"content": "ProActions Hub is a powerful tool...",
"links": [
"https://docs.example.com",
"https://github.com/example/repo"
],
"image": "https://blog.example.com/images/cover.jpg",
"url": "https://blog.example.com/article-title",
"source": "blog.example.com"
}
```
--------------------------------
### Configure Basic User Interaction Tools
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/ai-integration.md
Enable user interaction tools like `askSingleChoice`, `askMultipleChoice`, and `askConfirmation` by listing them under `builtinTools` in your configuration.
```yaml
- step: HUB_COMPLETION
behavior: 'You are a newsroom assistant'
instruction: 'Help classify and improve this article'
builtinTools:
- askSingleChoice
- askConfirmation
tools:
# AI can now call these tools directly
```
--------------------------------
### Article Extractor Response Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/hub/config/tools.md
Example JSON response from the article extractor tool, containing extracted metadata and content.
```json
{
"title": "Article Title",
"description": "Article description",
"author": "Author Name",
"published": "2024-01-15T10:30:00.000Z",
"content": "Full article text...",
"links": ["https://..."],
"image": "https://example.com/image.jpg"
}
```
--------------------------------
### Backup ProActions Installation
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/setup/installation.md
Use this command to back up your current ProActions installation before updating. Replace {version} with the actual version number.
```bash
mv pro-actions-{version}.js pro-actions-{version}.js_
```
--------------------------------
### MCP Server Configuration Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/hub/mcp-gateway.md
Configure an MCP server with a command, arguments, environment variables for secrets, and connection/tool timeouts. Use environment variables for sensitive credentials like API keys.
```yaml
mcp:
servers:
- name: secure-server
command: npx
args: ['-y', 'my-server']
env:
API_KEY: ${MY_SECRET_KEY}
connectTimeout: 10000
toolTimeout: 30000
```
--------------------------------
### PROMPT Step Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/step-library/ui-steps.md
Use the PROMPT step to display a message to the user and capture their text input. The entered text is stored in the default text output.
```yaml
- step: PROMPT
promptText: "Please enter your name"
```
--------------------------------
### Basic Action Configuration Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/release-notes.md
This snippet shows a basic action configuration with a title and a single step. The `step` property defines the action to be performed.
```yaml
- step: USER_SELECT
enableKeyboardControl: true
promptText: 'Choose an option'
```
--------------------------------
### YouTube Log Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/hub/config/logging.md
Example JSON structure for YouTube logs, including timestamp, level, module, account, video ID, and title.
```json
{
"timestamp": "2024-01-15T10:30:00.123Z",
"level": "info",
"message": "Video uploaded successfully",
"module": "youtube",
"account": "main",
"videoId": "dQw4w9WgXcQ",
"title": "My Video"
}
```
--------------------------------
### Tool Implementation: Steps (Workflow)
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/ai-integration.md
Implement a tool using a sequence of steps, allowing access to client-side methods like `getTextContent()`.
```yaml
tools:
- name: getArticleText
description: 'Retrieves the full article text'
steps:
- step: SET
articleContent: '{{ client.getTextContent() }}'
```
--------------------------------
### Text Log Output Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/hub/config/logging.md
An example of a log entry in the text format, demonstrating a human-readable output with timestamp, level, module, and message.
```text
2024-01-15T10:30:00.123Z [info] [aiLink]: AI request completed
```
--------------------------------
### Minimal Keyboard Shortcut Setup
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/setup/keyboard-shortcuts.md
This minimal XML configuration sets up a basic keyboard shortcut for opening Swing ProActions.
```xml
```
--------------------------------
### Including Text Menu in Main Configuration
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/menus-and-triggers.md
Demonstrates how to include the text menu configuration and other AI Kit components into the main configuration file.
```yaml
# /SysConfig/pro-actions.ai-kit.yaml
AI_KIT:
SERVICES:
!include /SysConfig/ProActions/services.ai-kit.services.yaml
TEXT_MENU:
!include /SysConfig/ProActions/text.ai-kit.menu.yaml
SECTIONS:
- !include /SysConfig/ProActions/sections/text-menu-actions.yaml
```
--------------------------------
### SHOW_RESPONSE Step Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/step-library/ui-steps.md
The SHOW_RESPONSE step presents a user-facing modal with content. It can execute preceding steps and supports rendering content in HTML or Markdown format.
```yaml
- step: SET
text: "Text to show"
- step: SHOW_RESPONSE
```
--------------------------------
### Example ProActions File Structure
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/setup/vscode-setup.md
Illustrates the recommended directory and file organization for ProActions projects, including main configuration, services, menus, libraries, and sections.
```tree
/SysConfig/
├── pro-actions.ai-kit.yaml # Main configuration
└── ProActions/
├── services.ai-kit.services.yaml # Service definitions
├── oneclick.ai-kit.menu.yaml # Oneclick menu
├── slash.ai-kit.menu.yaml # Slash command menu
├── lib/
│ ├── common.ai-kit.module.yaml # Shared block module
│ └── editorial.ai-kit.module.yaml # Section-specific block module
└── sections/
├── headlines.ai-kit.section.yaml
├── translation.ai-kit.section.yaml
└── content.ai-kit.section.yaml
```
--------------------------------
### Test GET Request with cURL
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/hub/config/proxy.md
Use cURL to test a GET request to a proxied endpoint. Replace placeholders with your actual port and target ID.
```bash
# Test GET request
curl http://localhost:${PROACTIONS_HUB_PORT}/proxy/forward/deepl
```
--------------------------------
### REST GET Request with JSON Output
Source: https://context7.com/em-al-wi/proactions-docs-md/llms.txt
Makes a GET request to a REST API, retrieves JSON data, and outputs it into the 'articles' context variable.
```yaml
# GET request with JSON response
- step: REST
url: "https://api.example.com/articles"
method: "GET"
headers:
Authorization: "Bearer {{ flowContext.apiToken }}"
parameters:
limit: 10
category: "{{ flowContext.category }}"
outputs:
- type: json
name: articles
```
--------------------------------
### AI-Link Log Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/hub/config/logging.md
Example JSON structure for AI-Link logs, including timestamp, level, module, target, model, token counts, and request duration.
```json
{
"timestamp": "2024-01-15T10:30:00.123Z",
"level": "info",
"message": "AI request completed",
"module": "aiLink",
"target": "openai",
"provider": "openai",
"model": "gpt-4o-mini",
"promptTokens": 150,
"completionTokens": 250,
"totalTokens": 400,
"duration": 1234
}
```
--------------------------------
### Basic Monitor Usage with On-Demand Enabled
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/flow-monitor.md
Demonstrates enabling the monitor for a specific action when global settings are 'ondemand'. The monitor will only appear for actions explicitly enabling it.
```yaml
- title: 'Process with Monitor'
monitor:
enabled: true
flow:
- step: MONITOR_STATUS
message: 'Starting process...'
type: info
- step: HUB_COMPLETION
instruction: 'Analyze this content...'
- step: MONITOR_STATUS
message: 'Process complete!'
type: success
```
--------------------------------
### Instant Action Configuration
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/basics.md
Configure an action to be executable instantly via a keyboard shortcut based on the cursor's context. Specify valid contexts using `instantActionContext`.
```yaml
- title: 'Quick Improve'
instantActionContext: "/doc/story/body/p,/doc/story/headline/p"
flow:
- step: HUB_COMPLETION
instruction: "Improve: {selectedText}"
- step: REPLACE_TEXT
at: CURSOR
```
--------------------------------
### Avoid Unnecessary Steps in Workflows
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/workflow-design.md
Eliminate redundant operations in workflows to improve efficiency. Compare the 'Good' example with the 'Avoid' example to see how intermediate steps can be consolidated.
```yaml
- title: 'Translate'
flow:
- step: DEEPL_TRANSLATE
instruction: '{selectedText}'
target_lang: 'FR'
- step: REPLACE_TEXT
at: CURSOR
```
```yaml
- title: 'Translate'
flow:
- step: GET_TEXT_CONTENT
at: CURSOR
- step: SET
textToTranslate: '{{ flowContext.selectedText }}'
- step: DEEPL_TRANSLATE
instruction: '{{ flowContext.textToTranslate }}'
- step: SET
translatedText: '{{ flowContext.text }}'
- step: REPLACE_TEXT
at: CURSOR
```
--------------------------------
### Configuration Validation Error Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/hub/configuration.md
An example of a configuration validation error message that might appear in logs, indicating an issue with a specific configuration key, such as 'hub.port' not being a number.
```text
Configuration validation failed: "hub.port" must be a number
```
--------------------------------
### Troubleshooting: Menu doesn't appear
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/menus-and-triggers.md
Confirm that the configuration is included in the main YAML file, the syntax is valid, and file permissions are correct. Check the browser console for errors.
```yaml
# Verify inclusion: !include /SysConfig/ProActions/oneclick.ai-kit.menu.yaml
# Check browser console for errors
# Refresh configuration cache
```
--------------------------------
### Podman Deployment with Custom Servers
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/hub/custom-mcp-servers.md
Deploy ProActions Hub with custom servers using Podman. Mounts the configuration and script directories.
```bash
podman run -d \
-p 3000:3000 \
-v ./config/config.yaml:/usr/src/app/dist/config.yaml \
-v ./my-local-scripts:/usr/src/app/custom-scripts:ro \
artifactory.eidosmedia.sh/docker-releases/proactions/proactions-hub:latest
```
--------------------------------
### Use Clear, Action-Oriented Labels (Good Practice)
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/menus-and-triggers.md
Employ descriptive titles for menu actions to clearly indicate their function. Include icons for better visual identification.
```yaml
# Good
- title: 'Translate to French'
icon: 'fa fa-language'
# Avoid
- title: 'French'
icon: 'fa fa-flag'
```
--------------------------------
### Proxy Log Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/hub/config/logging.md
Example JSON structure for proxy logs, detailing timestamp, level, module, target, target URL, path, status code, and request duration.
```json
{
"timestamp": "2024-01-15T10:30:00.123Z",
"level": "info",
"message": "Proxy request completed",
"module": "proxy",
"target": "deepl",
"targetUrl": "https://api.deepl.com/v2/translate",
"path": "/",
"statusCode": 200,
"duration": 456
}
```
--------------------------------
### Loading States Best Practice
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/swing-integration.md
Illustrates how to provide visual feedback to the user during API calls.
```APIDOC
## Best Practice: Loading States
### Description
Show loading indicators to the user while API calls are in progress to improve user experience.
### Code Example
```javascript
$("#process-button").click(async function () {
const $button = $(this);
$button.prop("disabled", true).text("Processing...");
try {
const result = await aikit.executeChatCompletion("...", { ctx: ctx });
updateUI(result);
} catch (error) {
handleError(error);
} finally {
$button.prop("disabled", false).text("Process");
}
});
```
```
--------------------------------
### Error Log Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/hub/config/logging.md
An example of an error log entry in JSON format, including the error message, error code, stack trace, and contextual information like module and target.
```json
{
"timestamp": "2024-01-15T10:30:00.123Z",
"level": "error",
"message": "Failed to connect to AI provider",
"error": "ECONNREFUSED",
"stack": "Error: ECONNREFUSED...",
"module": "aiLink",
"target": "openai"
}
```
--------------------------------
### Sequential Step Execution Flow
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/getting-started/understanding-steps.md
Demonstrates a basic sequence of steps: getting text content, processing it with a completion model, and showing the response.
```yaml
- step: GET_TEXT_CONTENT
at: CURSOR
- step: HUB_COMPLETION
instruction: 'Summarize: {{ flowContext.text }}'
- step: SHOW_RESPONSE
message: 'Summary complete'
```
--------------------------------
### Basic HUB_COMPLETION Step Configuration
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/step-library/overview.md
Example of configuring a HUB_COMPLETION step to summarize text content. Ensure the 'textContent' input is available in the flow context.
```yaml
- step: HUB_COMPLETION
behavior: "You are a helpful assistant"
instruction: "Summarize this: {textContent}"
outputs:
- type: text
name: summary
```
--------------------------------
### Object Panel HTML Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/swing-integration.md
Example HTML structure for an object panel, including buttons that trigger ProActions via specific IDs. These IDs must match the event listeners in the JavaScript registration.
```html
AI Tools
```
--------------------------------
### JSON Log Output Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/hub/config/logging.md
An example of a log entry in JSON format, showing structured data including timestamp, level, message, and specific details like module, target, and token counts.
```json
{
"timestamp": "2024-01-15T10:30:00.123Z",
"level": "info",
"message": "AI request completed",
"module": "aiLink",
"target": "openai",
"model": "gpt-4o-mini",
"promptTokens": 15,
"completionTokens": 25,
"totalTokens": 40
}
```
--------------------------------
### Using !include for Modular Configuration (Absolute Paths)
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/basics.md
Demonstrates how to use the !include directive with absolute paths to modularize ProActions configuration, importing services, menus, and sections.
```yaml
AI_KIT:
SERVICES:
!include /SysConfig/ProActions/services.ai-kit.services.yaml
TEXT_MENU:
!include /SysConfig/ProActions/text.ai-kit.menu.yaml
ONECLICK_MENU:
!include /SysConfig/ProActions/oneclick.ai-kit.menu.yaml
SECTIONS:
# Content workflows
- !include /SysConfig/ProActions/sections/content/headlines.ai-kit.section.yaml
- !include /SysConfig/ProActions/sections/content/summaries.ai-kit.section.yaml
# Translation workflows
- !include /SysConfig/ProActions/sections/translation/deepl.ai-kit.section.yaml
# Media workflows
- !include /SysConfig/ProActions/sections/media/images.ai-kit.section.yaml
```
--------------------------------
### Access Log Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/hub/config/logging.md
An example of an access log entry in JSON format, detailing HTTP method, URL, status code, response time, IP address, user agent, request ID, and username.
```json
{
"timestamp": "2024-01-15T10:30:00.123Z",
"level": "info",
"message": "POST /v1/chat/completions 200 1234ms",
"method": "POST",
"url": "/v1/chat/completions",
"statusCode": 200,
"responseTime": 1234,
"ip": "192.168.1.100",
"userAgent": "ProActions-Client/1.0",
"requestId": "abc123",
"username": "john.doe"
}
```
--------------------------------
### Pre-filled PROMPT using SET
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/step-library/steps/PROMPT.md
Demonstrates how to pre-fill a prompt's input field using the SET step before displaying the prompt. Useful for editing existing values.
```yaml
- step: SET
text: "Pre-filled value"
- step: PROMPT
promptText: "Edit the pre-filled value"
```
--------------------------------
### Flow-Wide Error Handling with onError (Example 2)
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/workflow-design.md
This example demonstrates `onError` at the action level, acting as a top-level catch for any unhandled error within the flow. It shows how to display a generic error message including the specific error details.
```yaml
- title: 'Process Article'
flow:
- step: HUB_COMPLETION
instruction: '...'
- step: REPLACE_TEXT
at: CURSOR
onError:
- step: SHOW_NOTIFICATION
notificationType: error
message: 'Something went wrong: {{ flowContext.error }}'
```
--------------------------------
### Using !include for Modular Configuration (Relative Paths)
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/basics.md
Shows how to use the !include directive with relative paths (./ and ../) to include configuration files, resolving paths relative to the current file.
```yaml
AI_KIT:
SERVICES:
!include ./ProActions/services.ai-kit.services.yaml
SECTIONS:
- !include ./ProActions/sections/content/headlines.ai-kit.section.yaml
```
--------------------------------
### Generic REST API Integration (GET with Options)
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/getting-started/using-services.md
Configure various options for REST API calls, including method, headers, query parameters, request body, and form data. Supports GET, POST, PUT, DELETE, PATCH methods.
```yaml
- step: REST
url: "https://api.example.com/data"
method: "GET" # GET, POST, PUT, DELETE, PATCH
# Headers
headers:
Authorization: "Bearer {{ flowContext.token }}"
Custom-Header: "value"
# Query parameters
parameters:
param1: "value1"
param2: "{{ flowContext.variable }}"
# Request body (for POST/PUT/PATCH)
body:
key: "value"
data: "{{ flowContext.myData }}"
# Or form data
formData:
field1: "value1"
```
--------------------------------
### Text Menu Configuration Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/menus-and-triggers.md
Configures items for the text menu, specifying button properties like icon, title, and the flow to execute.
```yaml
# /SysConfig/ProActions/text.ai-kit.menu.yaml
story:
items:
- type: 'button'
icon: 'fa fa-magic'
title: 'Improve'
flowRef: 'improveText'
- type: 'button'
icon: 'fa fa-language'
title: 'Translate to French'
flowRef: 'translateFR'
```
--------------------------------
### isNumber Filter Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/getting-started/working-with-variables.md
Returns true if the value is a number.
```nunjucks
{{ flowContext.score | isNumber }}
```
--------------------------------
### Include One-Click Menu in Main Configuration
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/guides/configuration/menus-and-triggers.md
Demonstrates how to integrate the one-click menu configuration into the main AI Kit settings. This ensures the one-click menu is active and recognized.
```yaml
# /SysConfig/pro-actions.ai-kit.yaml
AI_KIT:
SERVICES:
!include /SysConfig/ProActions/services.ai-kit.services.yaml
ONECLICK_MENU:
!include /SysConfig/ProActions/menu.oneclick.yaml
SECTIONS:
- !include /SysConfig/ProActions/sections/headlines.yaml
```
--------------------------------
### Configure File Logging Settings
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/hub/config/logging.md
Set up file logging directory, prefix, rotation, max file size, and max number of files. Rotation is enabled by default.
```yaml
logging:
logDirectory: logs
filePrefix: app
fileRotation: true
maxFileSize: 10m
maxFiles: 14d
```
--------------------------------
### isString Filter Example
Source: https://github.com/em-al-wi/proactions-docs-md/blob/main/getting-started/working-with-variables.md
Returns true if the value is a string.
```nunjucks
{{ flowContext.title | isString }}
```