-
Notifications
You must be signed in to change notification settings - Fork 59
Feature/workflow completion #890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pavelsima
wants to merge
11
commits into
Cognigy:master
Choose a base branch
from
pavelsima:feature/workflow-completion
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5684ce9
Updated readme - CXone Authenticated Call node
pavelsima 4a9b769
Use raw http request - CXone Authenticated Call node
pavelsima bdcba38
Workflow completion extension
pavelsima f7c7c9a
Workflow completion extension
pavelsima 8b2e320
Workflow completion extension
pavelsima 2e515d6
Workflow completion extension
pavelsima 21798d4
Revert unneded changes
pavelsima 731e6af
Revert unneded changes
pavelsima 72efad5
Revert unneded changes
pavelsima 0053647
Revert unneded changes
pavelsima 4865c84
Address PR review comments: fix docs, version mismatch, and error han…
pavelsima File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
|
||
| ### 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAC4jAAAuIwF4pT92AAAEM0lEQVR4nO2ayYsVSRCHv6pq9/GiHlxQkRkVDwoOQ9vqyeUP8KKeFGYUdw8OijIwwyieBFcQBAVF0YMggogXUfCiDAMjCC4Hwe2gtgsuONp2v6ckRECQ1Kuq92x9VWX9IIl6WZnxMpaMzIpMqFChQoUKFSpUaA4B0AFEhjaL0OPhfhcCYUK9U0wagn7g0TaEQscCy4G/gc3AHBm4liw8pgMbgR3AGmCK9z53CIWuAl4Cn4C6FPd8DhgtbeKUoHVDgYNAr+Hh6HtgZ4vT6ZsJv9oMutcrrv4q8EMDJejvk9K2z+vfJ/V7vP9sOwLj9k/M4D+Z4hTSI89bpb21pD4vkjYfjeUtD8e3BszOkxIioctkoGptv6hS/onhoYIcTeGh9bu8/24rIqF/pQy+JvQeMKLBNLjSwIN8JZ6R9m55zI0CNmVUwB0JdFYBSs9nVMCxPCpgrhHUn79WMadi5q/y+MPEgDgFaP1vXr+2IxB6VgbYYwJWzQj/AeiKUYD2Hwc8NMIqjz4j/I2ElQTDO6n0+2YqEDpGgpx1efUGJ8DKGOHtoB3mA8+9vkofAD8n8GgrAqHDgW3AfzLgu8BpoDPDwPXdj8Ah4LZ4xE1gtyy1WXg4T5oITIgprn4IXwmBGZybnyOBYTHvkmBddBAwChiQgYfWzwC6ZTfqPOmFKd3iib+bMfY7AmFs51nUpMuGMYPzefrQ9gu8aRO3ivz5rVaR4AsDTjP9VQFLjLB1r2gw3uD1KQU6hG5J2I9oYHZKKp0CIqFHEhSg02KW16fwCIxA/3rW9oV/JatBLpfSVqGC/CR5g7ggqAHQLc8DpX2us0utzP+1Cd8SWne8bO5vLXkxgwJWlE0BodAuI2RcMsXR/4GpXr/CI/SSKUnWv1y2uR8K7TQpt6Qd4Lqyuv+FBOurQh5n/JgqXORf32Dd962/v0zWj4T+ArxOcH2tc22mlcX6kVDnzrdSrK/b4b1lE36kHLIkJVBVKY8kQVL46N9h0m7XUoS379xRXaHnfmgGP1PS6o2+9nzXd0nawlo+8qzm9vlvmrD8ffPVVwgFBOZihc0EzTR7/FqK8Hom4TZFC/Ps+qGx8IAGg3Tp7xNmh6cprkbC103g+zXPwicpZZJchrhk5nGa1f02XzXj2x8I5PaHc9HFcoPksGRyPngWTbO6ekatCMKHQt2a/DTlwyWL4Dba9xTB7UOhE+SQwgqrN0DslZo0l+81G515eRfeV4B/9pe1aG7f3jsaWwThG3lAVgXUvLn+WA5adbksxB4/bFIB9Zh48BbYZ26bNXvklmsF1BPiwTPgADDZO38sFEKjgG4TxfUShVWEo+/kztA6735h2iFpYT3gDXBddn8r5JDDv0ZTGHePg1ptsGxYtssp7VI5qxtvTmwog8VbRVQGa6ehw1yFtwJ/V5auUKFChQoVKpBrfAZOJCzSjD5RGAAAAABJRU5ErkJggg== |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } | ||
| } | ||
| }; | ||
|
|
||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.