Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 150 additions & 0 deletions extensions/workflow-completion/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
# Workflow Completion Extension

This Cognigy extension provides workflow completion tracking capabilities for your Cognigy flows, allowing you to mark workflows as completed or failed while capturing session metrics.

## Installation

1. Build the extension:
```bash
npm install
npm run build
```

2. Upload the generated `workflow-completion-*.tar.gz` file to your Cognigy.AI instance via **Manage > Extensions > Upload Extension**

## Send Status to CXone Copilot Node

This node appears in the Cognigy node palette as **"Send Status to CXone Copilot"** (type `sendCopilotStatus`). It is a terminal node that marks workflow completion status and captures session metrics.

### Features
- Simple dropdown to mark workflow as "Success" or "Failure"
- Optional JSON data field for custom output data
- Captures session metrics (when available)
- Designed as a terminal node for end-of-flow placement
- Outputs structured data for analytics and reporting
- Silent execution with empty say() message

### Configuration

#### Status Selection
- **Completion Status** (`status`): Dropdown selection between:
- `Success` (default): Marks the workflow as successfully completed
- `Failure`: Marks the workflow as failed or incomplete

#### Additional Data (Optional)
- **Additional Data** (`data`): Optional field to include custom data in the output (typically JSON)
- Value is passed through as provided by the flow
- Only included in the output when non-empty data is provided
- The node does not validate or parse this field; ensure it contains valid JSON if required by downstream consumers

Comment thread
pavelsima marked this conversation as resolved.
### Output

The node outputs data in the following structure:

```json
{
"status": "Complete", // or "Failed" (internal values)
"metrics": {
// Session metrics when available:
// - sessionId: Unique session identifier
// - channel: The channel through which the conversation took place
// - language: The language of the session
// - completionTimestamp: ISO timestamp when the workflow completed
// Empty object {} if metrics are not accessible
},
"data": {
// Optional: Custom data when provided
// Only present if additional data was specified
// Contains whatever structure was supplied (typically JSON)
}
}
```

### Example Usage

1. Place the **Workflow Completion** node at the end of your successful flow path
2. Select "Success" from the dropdown
3. Optionally add custom JSON data in the "Additional Data" field
4. The node will execute `say("")` (empty message) and output completion data

For error handling paths:
1. Place another **Workflow Completion** node at the end of error flows
2. Select "Failure" from the dropdown
3. Optionally include error details in the "Additional Data" field as JSON
4. Use the output data for failure tracking and analytics

#### Additional Data Examples
```json
// Success scenario with user details
{
"userId": "12345",
"completionTime": 1640995200000,
"path": "checkout_flow"
}

// Failure scenario with error details
{
"errorCode": "PAYMENT_FAILED",
"errorMessage": "Credit card declined",
"retryAttempts": 3
}
```

### Use Cases

- **Analytics and Reporting**: Track completion rates across different workflows
- **Performance Monitoring**: Measure session duration and interaction counts
- **Quality Assurance**: Identify failed workflow paths for improvement
- **Business Intelligence**: Export completion data for business metrics
- **A/B Testing**: Compare completion rates between different flow versions

## Testing

This extension uses **Jest** for unit tests.

- **Run all tests**: `npm test`
- **Run tests in watch mode**: `npm run test:watch`

## Troubleshooting

### Common Issues

**Node not appearing in palette**
- Ensure the extension was properly uploaded and enabled
- Check that the extension build completed without errors

**Missing metrics data**
- Some metrics may not be available in all Cognigy environments
- The metrics object will be empty `{}` if session data is not accessible

**Workflow not terminating**
- Ensure the Workflow Completion node is connected as the final node
- Check that no other nodes follow the completion node

## Development

### Building

```bash
npm install
npm run transpile
npm run lint
npm run build # Includes transpile, lint, and zip
```

### Project Structure

```
src/
├── nodes/ # Node implementations (workflowCompletion)
├── test-utils/ # Test utilities and mocks
└── types/ # TypeScript type definitions
```

## License

NiCE

## Author

NiCE
1 change: 1 addition & 0 deletions extensions/workflow-completion/icon.b64
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAC4jAAAuIwF4pT92AAAEM0lEQVR4nO2ayYsVSRCHv6pq9/GiHlxQkRkVDwoOQ9vqyeUP8KKeFGYUdw8OijIwwyieBFcQBAVF0YMggogXUfCiDAMjCC4Hwe2gtgsuONp2v6ckRECQ1Kuq92x9VWX9IIl6WZnxMpaMzIpMqFChQoUKFSpUaA4B0AFEhjaL0OPhfhcCYUK9U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jsaWwThG3lAVgXUvLn+WA5adbksxB4/bFIB9Zh48BbYZ26bNXvklmsF1BPiwTPgADDZO38sFEKjgG4TxfUShVWEo+/kztA6735h2iFpYT3gDXBddn8r5JDDv0ZTGHePg1ptsGxYtssp7VI5qxtvTmwog8VbRVQGa6ehw1yFtwJ/V5auUKFChQoVKpBrfAZOJCzSjD5RGAAAAABJRU5ErkJggg==
Binary file added extensions/workflow-completion/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions extensions/workflow-completion/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/__tests__/**/*.spec.ts'],
moduleFileExtensions: ['ts', 'js', 'json'],
roots: ['<rootDir>/src'],
setupFilesAfterEnv: ['<rootDir>/src/test-utils/jest-setup.ts'],
collectCoverageFrom: [
'src/**/*.{ts,js}',
'!src/**/__tests__/**/*'
],
coverageThreshold: {
global: {
branches: 80,
functions: 90,
lines: 90,
statements: 90
}
}
};


Loading