### Example Full Configuration File Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/configuration.md Provides a comprehensive example of a config.json file, including API key, agent ID, base URL, and other settings. ```json { "apiKey": "your-api-key-here", "agent": "5f5618bce35138ed3ab9ab9a", "baseUrl": "https://api-trial.cognigy.ai", "agentDir": "./agent", "knowledgeAIStoreDir": "./knowledge-ai-store", "playbookTimeoutSeconds": 10, "maxNumberOfTokens": 2048 } ``` -------------------------------- ### Push Flow Example Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/push.md Example of how to push a flow resource to Cognigy.AI, including confirmation. ```typescript // Push a flow with confirmation await push({ resourceType: 'flow', resourceName: 'myFlow', options: { forceYes: false } }); ``` -------------------------------- ### Minimal Configuration File Example Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/configuration.md Illustrates the minimum required fields for a valid config.json file. ```json { "apiKey": "your-api-key-here", "agent": "agent-project-id", "baseUrl": "https://api-trial.cognigy.ai", "agentDir": "./agent" } ``` -------------------------------- ### Example config.json File Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/configuration.md This is an example of a config.json file used to configure the Cognigy CLI. It includes essential properties like API key, agent ID, and base URL. ```json { "apiKey": "your-cognigy-api-key", "agent": "your-agent-project-id", "baseUrl": "https://api-trial.cognigy.ai", "agentDir": "./agent", "knowledgeAIStoreDir": "./knowledge-ai-store", "playbookTimeoutSeconds": 10, "maxNumberOfTokens": 2048 } ``` -------------------------------- ### Install Cognigy CLI Globally Source: https://github.com/cognigy/cognigy-cli/blob/main/README.md Installs the Cognigy.AI CLI globally using npm. This allows you to use the `cognigy` command from any directory. ```bash npm install -g @cognigy/cognigy-cli ``` -------------------------------- ### Minimal config.json Example Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/README.md This JSON configuration file contains the minimum required settings for the Cognigy CLI. ```json { "apiKey": "your-api-key", "agent": "agent-project-id", "baseUrl": "https://api-trial.cognigy.ai", "agentDir": "./agent" } ``` -------------------------------- ### Push Lexicon Example Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/push.md Example of pushing a lexicon resource to Cognigy.AI with confirmation, timeout, and custom timeout handling. ```typescript // Push lexicon with timeout await push({ resourceType: 'lexicon', resourceName: 'myLexicon', options: { forceYes: true, timeout: '60000' } }); ``` -------------------------------- ### Initialize and Clone with Cognigy CLI Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/configuration.md Use 'cognigy init' for interactive setup and validation, or 'cognigy clone' which validates configuration before cloning a project. ```bash cognigy init # Interactive setup with validation cognigy clone # Validates configuration before cloning ``` -------------------------------- ### Configuration Precedence Example Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/configuration.md Demonstrates how command-line options, environment variables, and config files interact to determine the final configuration values. Command-line options have the highest precedence. ```bash # config.json has agentDir: "./agent" # CAI_AGENTDIR env var is "./agent-prod" # Command line specifies: -c ./config-prod.json with agentDir: "./agent-custom" # Result: agentDir will be "./agent-custom" (config-prod.json wins) ``` -------------------------------- ### Start Progress Bar Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/utilities.md Initializes and starts a progress bar. Call this function to begin tracking the progress of an operation. ```typescript export const startProgressBar = (total: number): void ``` -------------------------------- ### Run Playbooks from Default File Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/other-commands.md Executes playbooks using the default './playbooks.json' file. This is the simplest way to start a playbook run. ```typescript await run({ resourceType: 'playbooks' }); ``` -------------------------------- ### Push Endpoint Example Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/push.md Example of pushing an endpoint resource to Cognigy.AI without confirmation and with a specified timeout. ```typescript // Push endpoint without confirmation await push({ resourceType: 'endpoint', resourceName: 'myEndpoint', options: { forceYes: true, timeout: '30000' } }); ``` -------------------------------- ### Example .gitignore Content Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/configuration.md This snippet shows common configuration files that should be ignored by Git to prevent accidental commits of sensitive information like API keys. ```gitignore config.json .env ``` -------------------------------- ### Cognigy CLI Pull Usage Examples Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/pull.md Demonstrates how to use the pull function to download various resource types from Cognigy.AI, with and without confirmation. ```typescript // Pull a flow with confirmation await pull({ resourceType: 'flow', resourceName: 'myFlow', forceYes: false }); // Pull endpoint without confirmation await pull({ resourceType: 'endpoint', resourceName: 'myEndpoint', forceYes: true }); // Pull all locales await pull({ resourceType: 'locales', forceYes: true }); // Pull AI agent await pull({ resourceType: 'aiAgent', resourceName: 'myAgent', forceYes: false }); ``` -------------------------------- ### Example Cognigy ctext file format Source: https://github.com/cognigy/cognigy-cli/blob/main/KNOWLEDGE-AI-README.md Demonstrates the expected paragraph separation for cognigy ctext files used for ingestion. ```plaintext Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Aenean mi nulla, fermentum id finibus nec, lacinia nec ipsum. Nullam rhoncus augue in magna vulputate, ac porttitor justo posuere. Integer at risus ut libero scelerisque vehicula a eget sapien. Integer feugiat nulla leo, a elementum arcu consequat at. In hac habitasse platea dictumst. Ut ut sem condimentum, tempus enim vel, maximus est. Suspendisse commodo interdum ullamcorper. In pulvinar quam ut elementum tempus. Maecenas feugiat risus ac magna tincidunt maximus. Ut vestibulum congue elit ac finibus. Vivamus aliquet auctor risus, vel euismod felis pulvinar sit amet. Cras nec molestie enim, in ultricies justo. Integer a pretium dui. Cras in bibendum velit, a laoreet metus. Vestibulum orci enim, rutrum nec quam in, iaculis hendrerit eros. Maecenas ultrices, felis at luctus fringilla, elit risus auctor erat, sit amet posuere nunc augue sed elit. Nam tempus ipsum magna, et semper ipsum rhoncus condimentum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam feugiat vehicula magna. Praesent magna mi, lobortis et dolor mattis, tempus malesuada lacus. Nam ut eros vitae metus iaculis tristique. ``` -------------------------------- ### Get Help for Cognigy CLI Commands Source: https://github.com/cognigy/cognigy-cli/blob/main/README.md Displays help information for any Cognigy CLI command. Use the `-h` flag with the main command or a specific subcommand. ```bash cognigy -h ``` ```bash cognigy -h ``` -------------------------------- ### Translate Flow to German with Google Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/localization.md Example of translating a flow from English to German using Google Translate. This example translates both intents and node content. ```typescript // Translate flow from English to German using Google await translate({ resourceType: 'flow', resourceName: 'myFlow', options: { localeName: 'de_DE', fromLanguage: 'en', toLanguage: 'de', translator: 'google', apiKey: 'AIzaSyD....', translateIntents: true, translateNodes: true } }); ``` -------------------------------- ### Example Transformer Structure Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/endpoints.md Illustrates the basic structure of a transformer TypeScript file used for endpoint-specific request and response transformations. ```typescript // transformer.ts - stored as plain TypeScript code export const transform = (request: any) => { // Custom transformation logic return transformedRequest; }; ``` -------------------------------- ### Translate Intent Example Sentence Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/localization.md Translates a single example sentence for an intent. Similar to translateFlowNode but specifically for intent examples. ```typescript export const translateIntentExampleSentence = async ( intentId: string, sentence: string, translator: string, apiKey: string, sourceLanguage: string, targetLanguage: string ): Promise ``` -------------------------------- ### Using Multiple Configuration Files Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/configuration.md Shows how to specify different configuration files for development, staging, and production environments using the -c flag. ```bash # Development cognigy clone -c ./config-dev.json # Staging cognigy clone -c ./config-staging.json # Production cognigy clone -c ./config-prod.json ``` -------------------------------- ### Create a Snapshot Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/INDEX.md Creates a snapshot of the project with a given name and description. ```bash cognigy create snapshot mySnapshot "Description" ``` -------------------------------- ### Initialize New Cognigy.AI CLI Project Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/other-commands.md Use the `init` command to set up a new Cognigy.AI CLI project. It prompts for essential configuration details like API keys and agent IDs, then saves them to a JSON file. ```typescript await init(); ``` -------------------------------- ### translateIntentExampleSentence() Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/localization.md Translates intent example sentences using a specified translation service and API key. ```APIDOC ## translateIntentExampleSentence() ### Description Translates intent example sentences. ### Method `async` ### Parameters #### Path Parameters - **intentId** (string) - Required - Identifier of the intent - **sentence** (string) - Required - The example sentence to translate - **translator** (string) - Required - Translation service name - **apiKey** (string) - Required - API key for service - **sourceLanguage** (string) - Required - Source language code - **targetLanguage** (string) - Required - Target language code ### Return Type `string` - Translated text ``` -------------------------------- ### Example Return Value for pullLocales Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/localization.md Illustrates the structure of the locale data returned by the `pullLocales` function. ```typescript [ { _id: "locale_id_1", name: "en_US", nluLanguage: "en", fallbackLocaleReference: null }, { _id: "locale_id_2", name: "de_DE", nluLanguage: "de", fallbackLocaleReference: "locale_id_1" } ] ``` -------------------------------- ### Create a CognigyAI knowledge store Source: https://github.com/cognigy/cognigy-cli/blob/main/KNOWLEDGE-AI-README.md Use this command to create a new knowledge store bound to your project. The command output includes a JSON object with details, including the knowledge store ID. ```bash cognigy knowledge-ai create source --projectId --language --name --description ``` -------------------------------- ### Initialize a New Cognigy.AI CLI Project Source: https://github.com/cognigy/cognigy-cli/blob/main/README.md Initializes a new Cognigy.AI CLI project. This command typically creates a `config.json` file to store your project's configuration. ```bash cognigy init ``` -------------------------------- ### Other Commands - Initialization, Comparison, Training, Execution Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/INDEX.md Specialized operations for initializing new CLI projects, comparing resources, training NLU models, creating snapshots or locales, running playbooks, and restoring agent configurations. ```APIDOC ## init() ### Description Initializes a new Cognigy CLI project. ### Method Not specified (CLI command). ### Endpoint Not applicable. ### Parameters None specified. ### Request Example ``` init my-new-project ``` ### Response Not specified. ``` ```APIDOC ## diff() ### Description Compares local resources against remote resources on Cognigy.AI. ### Method Not specified (CLI command). ### Endpoint Not applicable. ### Parameters None specified. ### Request Example ``` diff ``` ### Response Not specified. ``` ```APIDOC ## train() ### Description Trains the NLU model for an agent or specific flows. ### Method Not specified (CLI command). ### Endpoint Not applicable. ### Parameters None specified. ### Request Example ``` train --agent my-agent ``` ### Response Not specified. ``` ```APIDOC ## create() ### Description Creates snapshots or locales for an agent. ### Method Not specified (CLI command). ### Endpoint Not applicable. ### Parameters None specified. ### Request Example ``` create snapshot --agent my-agent --name v1.0 create locale --agent my-agent --locale es-ES ``` ### Response Not specified. ``` ```APIDOC ## run() ### Description Executes playbooks in batch. ### Method Not specified (CLI command). ### Endpoint Not applicable. ### Parameters None specified. ### Request Example ``` run playbook --file playbooks.yaml ``` ### Response Not specified. ``` ```APIDOC ## restore() ### Description Restores an entire agent or specific resource types from a backup. ### Method Not specified (CLI command). ### Endpoint Not applicable. ### Parameters None specified. ### Request Example ``` restore agent --name backup-v1.0 ``` ### Response Not specified. ``` -------------------------------- ### Generate config.json using CLI Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/configuration.md Use the 'cognigy init' command to generate a default config.json file in your project directory. ```bash cognigy init ``` -------------------------------- ### Translate Nodes to Spanish with DeepL Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/localization.md Example of translating only the nodes of a flow to Spanish using DeepL. This snippet demonstrates a targeted translation. ```typescript // Translate only nodes to Spanish using DeepL await translate({ resourceType: 'flow', resourceName: 'myFlow', options: { localeName: 'es_ES', fromLanguage: 'en', toLanguage: 'es', translator: 'deepl', apiKey: 'xxxxx-xxxxx', translateNodes: true } }); ``` -------------------------------- ### Upload Extension with Cognigy CLI Source: https://github.com/cognigy/cognigy-cli/blob/main/FAQ.md Upload an extension to a specified project in Cognigy.AI. Requires the project ID and a URL to the extension package. ```bash cognigy execute uploadExtension -d '{"projectId": "myProjectId", "url": "url-where-my-extension.tar.gz-is-placed" }' ``` -------------------------------- ### Create Knowledge Store Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/knowledge-ai.md Creates a new Knowledge AI Store. Requires the store name, an optional description, and the project ID. ```typescript export const createKnowledgeStore = async ( name: string, description?: string, projectId: string ): Promise ``` -------------------------------- ### Pull Locales from Cognigy.AI Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/localization.md Fetches locale definitions from Cognigy.AI, with an option to cache the results. Use this to get a list of all available locales in your project. ```typescript export const pullLocales = async ( cacheTime: number = 10 ): Promise ``` -------------------------------- ### clone() Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/clone.md Clones a full Virtual Agent project to disk or clones specific resource types. It verifies the project, prompts for confirmation (unless forceYes is true), and then clones the specified resources. ```APIDOC ## clone() ### Description Clones a full Virtual Agent project to disk or clones specific resource types. It verifies the project, prompts for confirmation (unless forceYes is true), and then clones the specified resources. ### Method `clone` (function) ### Parameters #### Parameters - **resourceType** (string) - Optional - Default: 'agent' - The type of resources to clone: 'agent' (all), 'flows', 'endpoints', 'lexicons', or 'aiAgents' - **forceYes** (boolean) - Optional - Default: false - Skips confirmation prompts and overwrites all content without asking ### Return Type `Promise` - Resolves when cloning is complete, rejects if project verification fails or user aborts ### Throws - `Error` - If project cannot be verified on Cognigy.AI - `Error` - If API key is invalid or base URL is incorrect ### Behavior 1. Verifies project exists on Cognigy.AI using credentials from configuration 2. Prompts user for confirmation unless `forceYes` is true 3. Cleans and recreates the agent directory 4. Clones resources based on `resourceType`: - **'agent'**: Clones flows (33%), endpoints (33%), lexicons (33%), and AI agents - **'flows'**: Clones all flows in the agent - **'endpoints'**: Clones all endpoints in the agent - **'lexicons'**: Clones all lexicons in the agent - **'aiAgents'**: Clones all AI agents in the agent ### Usage Example ```typescript // Clone entire agent await clone({ forceYes: true }); // Clone only flows with confirmation await clone({ resourceType: 'flows' }); // Clone endpoints without confirmation await clone({ resourceType: 'endpoints', forceYes: true }); ``` ``` -------------------------------- ### checkCreateDir() Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/utilities.md Creates a specified directory and any necessary parent directories if they do not already exist. ```APIDOC ## checkCreateDir(dir: string) ### Description Creates directory and all parent directories if they don't exist. ### Method N/A (Function Call) ### Endpoint N/A ### Parameters #### Path Parameters - **dir** (string) - Required - Directory path (absolute or relative) ### Return Type `Promise` ``` -------------------------------- ### IHttpAdapter Interface Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/types.md Defines the contract for HTTP adapters used by the Cognigy REST API client. It specifies methods for making various HTTP requests (GET, POST, PUT, DELETE) and a general request method. ```APIDOC ## Interface: IHttpAdapter ### Description Defines the methods for making HTTP requests to the Cognigy API. This interface is implemented by concrete adapter classes to handle communication. ### Methods - **request(httpRequest: IHttpRequest, client: TRestAPIClient, retries?: number): Promise** - Makes a generic HTTP request. - **get(request: IHttpRequest, client: TRestAPIClient): Promise** - Makes an HTTP GET request. - **post(request: IHttpRequest, client: TRestAPIClient): Promise** - Makes an HTTP POST request. - **put(request: IHttpRequest, client: TRestAPIClient): Promise** - Makes an HTTP PUT request. - **delete(request: IHttpRequest, client: TRestAPIClient): Promise** - Makes an HTTP DELETE request. ### Usage Custom HTTP adapter implementation for the Cognigy API client. ``` -------------------------------- ### Index Extensions with Cognigy CLI Source: https://github.com/cognigy/cognigy-cli/blob/main/FAQ.md List all available extensions in the Cognigy.AI platform or filter by project identifier. ```bash cognigy execute indexExtensions ``` ```bash cognigy execute indexExtensions -d '{"projectId": "myProjectId"}' ``` -------------------------------- ### Configure Knowledge AI Store Directory Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/configuration.md Specify the directory for storing Knowledge AI resources, including extracted documents and indexed content. Defaults to './knowledge-ai'. ```json { "knowledgeAIStoreDir": "./knowledge-ai-store" } ``` -------------------------------- ### Train a Flow Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/INDEX.md Initiates the training process for a specified flow. ```bash cognigy train flow flowName ``` -------------------------------- ### create Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/other-commands.md Creates new Snapshots or Locales on Cognigy.AI. It handles resource type validation, creation, and optional file packaging/downloading. ```APIDOC ## create Creates new Snapshots or Locales on Cognigy.AI. ### Function Signature ```typescript export const create = async ({ resourceType, resourceName, description, timeout, skipDownload = false, fallbackLocale, nluLanguage, }): Promise ``` ### Parameters | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | resourceType | string | — | Type: 'snapshot' or 'locale' | | resourceName | string | — | Name for new resource | | description | string | — | Description (snapshots only) | | timeout | number (optional) | 100000 | Timeout in milliseconds | | skipDownload | boolean | false | Skip downloading snapshot file | | fallbackLocale | string (optional) | — | Fallback locale ID for new locale | | nluLanguage | string (optional) | — | NLU language for new locale | ### Return Type `Promise` - Resolves when resource is created ### Throws - Exits if project verification fails - Exits if resource type is invalid ### Snapshot Creation 1. Initiates snapshot creation on Cognigy.AI 2. Waits for snapshot to be ready (polling with timeout) 3. Optionally packages and downloads snapshot file 4. Stores as `.csnap` file in `agent/snapshots/` directory ### Locale Creation 1. Creates new locale with fallback parent 2. Sets NLU language if provided 3. Refreshes local locales cache ### Usage Example ```typescript // Create snapshot with download await create({ resourceType: 'snapshot', resourceName: 'snapshot_v1', description: 'Release v1 snapshot', timeout: 60000, skipDownload: false }); // Create snapshot without download await create({ resourceType: 'snapshot', resourceName: 'snapshot_v2', skipDownload: true }); // Create locale await create({ resourceType: 'locale', resourceName: 'de_DE', fallbackLocale: 'en_US', nluLanguage: 'de' }); ``` ``` -------------------------------- ### Create Knowledge Source Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/knowledge-ai.md Creates a new Knowledge AI Source. Requires store ID, source name, source type, and project ID. ```typescript export const createKnowledgeSource = async ( storeId: string, name: string, sourceType: string, projectId: string ): Promise ``` -------------------------------- ### Create Agent Snapshot Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/README.md Command to create a snapshot of the agent. The second argument is a description for the snapshot. ```bash cognigy create snapshot mySnapshot "Release v1.0" ``` -------------------------------- ### Create Cognigy Snapshot Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/other-commands.md Use this command to create a snapshot of your agent. You can choose to download the snapshot file or skip it. A description and custom timeout can also be provided. ```typescript await create({ resourceType: 'snapshot', resourceName: 'snapshot_v1', description: 'Release v1 snapshot', timeout: 60000, skipDownload: false }); ``` ```typescript await create({ resourceType: 'snapshot', resourceName: 'snapshot_v2', skipDownload: true }); ``` -------------------------------- ### Ingest documents into a knowledge store Source: https://github.com/cognigy/cognigy-cli/blob/main/KNOWLEDGE-AI-README.md Ingest a single .ctxt file or all .ctxt files from a directory into your knowledge store. You can specify the knowledge store by its ID or by its name if the JSON configuration file is present. ```bash cognigy knowledge-ai ingest --projectId --language --knowledgeStoreId 64467681d8170fe52ead079d --input ``` ```bash cognigy knowledge-ai ingest --name --input ``` -------------------------------- ### createKnowledgeStore Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/knowledge-ai.md Creates a new Knowledge AI Store with a specified name, optional description, and project ID. ```APIDOC ## createKnowledgeStore ### Description Creates a new Knowledge AI Store. ### Method Not applicable (SDK function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **name** (string) - Required - Name of the store to create - **description** (string) - Optional - Store description - **projectId** (string) - Required - Project ID where store should be created ### Return Type `IKnowledgeStore` - Created store object with ID and metadata ``` -------------------------------- ### Command-Line Options for Configuration Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/configuration.md Override configuration settings for specific commands using command-line options. This allows for flexible, per-command configuration. ```bash cognigy clone -c ./config-prod.json ``` ```bash cognigy push flow myFlow -y # forceYes flag ``` ```bash cognigy train flow myFlow -t 30000 # custom timeout ``` -------------------------------- ### indexAll() Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/utilities.md A pagination helper that automatically fetches all items across multiple pages, handling cursor-based pagination and returning combined results without pagination info. It fetches up to 100 items per page. ```APIDOC ## indexAll() ### Description Pagination helper that fetches all items across pages. Handles cursor-based pagination automatically and fetches up to 100 items per page, returning combined results without pagination info. ### Signature ```typescript export const indexAll = (indexFn: TIndexFn) => (query: TParams) => Promise ``` ### Usage ```typescript const allFlows = await indexAll(CognigyClient.indexFlows)({ projectId: CONFIG.agent }); // allFlows.items contains all items across all pages ``` ``` -------------------------------- ### Index Knowledge Sources Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/knowledge-ai.md Lists all Knowledge AI Sources within a store. Supports optional pagination and filter queries. Returns a list of sources with pagination information. ```typescript export const indexKnowledgeSources = async ( storeId: string, projectId: string, query?: IIndexQuery ): Promise ``` -------------------------------- ### Utilities Module Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/INDEX.md Provides essential helper functions for configuration, API communication, and validation. Includes utilities for managing configuration, interacting with the Cognigy REST API, and validating project structures. ```APIDOC ## CONFIG ### Description Global configuration object for the CLI. ### Method Not applicable (configuration object). ### Endpoint Not applicable. ### Parameters Not applicable. ### Request Example ```javascript // Accessing configuration console.log(CONFIG.apiKey); ``` ### Response Not applicable. ``` ```APIDOC ## CognigyClient ### Description Cognigy REST API client with built-in retry mechanisms. ### Method Not specified (class constructor). ### Endpoint Not applicable (client object). ### Parameters None specified. ### Request Example ```javascript const client = new CognigyClient({ apiKey: 'YOUR_API_KEY' }); client.getAgent('agent-id').then(agent => console.log(agent)); ``` ### Response Not specified. ``` ```APIDOC ## RestAdapter ### Description Custom HTTP adapter for API communication. ### Method Not specified (class). ### Endpoint Not applicable. ### Parameters None specified. ### Request Example ```javascript const adapter = new RestAdapter(); adapter.post('/some/endpoint', { data: '...' }); ``` ### Response Not specified. ``` ```APIDOC ## checkAgentDir() ### Description Validates if an agent directory exists. ### Method Not specified (CLI function). ### Endpoint Not applicable. ### Parameters None specified. ### Request Example ``` checkAgentDir('./my-agent-folder'); ``` ### Response Not specified. ``` ```APIDOC ## checkCreateDir() ### Description Creates a directory, including any necessary parent directories. ### Method Not specified (CLI function). ### Endpoint Not applicable. ### Parameters None specified. ### Request Example ``` checkCreateDir('./path/to/new/directory'); ``` ### Response Not specified. ``` ```APIDOC ## removeCreateDir() ### Description Removes and then recreates a directory. ### Method Not specified (CLI function). ### Endpoint Not applicable. ### Parameters None specified. ### Request Example ``` removeCreateDir('./temp-folder'); ``` ### Response Not specified. ``` ```APIDOC ## checkResourceDir() ### Description Validates if a resource directory exists. ### Method Not specified (CLI function). ### Endpoint Not applicable. ### Parameters None specified. ### Request Example ``` checkResourceDir('./resources'); ``` ### Response Not specified. ``` ```APIDOC ## checkProject() ### Description Validates the project structure on Cognigy.AI. ### Method Not specified (CLI function). ### Endpoint Not applicable. ### Parameters None specified. ### Request Example ``` checkProject('./my-agent-folder'); ``` ### Response Not specified. ``` ```APIDOC ## checkTask() ### Description Polls a task until its completion. ### Method Not specified (CLI function). ### Endpoint Not applicable. ### Parameters None specified. ### Request Example ``` checkTask('task-id').then(result => console.log('Task completed:', result)); ``` ### Response Not specified. ``` ```APIDOC ## checkLocale() ### Description Validates if a locale exists. ### Method Not specified (CLI function). ### Endpoint Not applicable. ### Parameters None specified. ### Request Example ``` checkLocale('en-US'); ``` ### Response Not specified. ``` ```APIDOC ## indexAll() ### Description Fetches all paginated items from an API endpoint. ### Method Not specified (CLI function). ### Endpoint Not applicable. ### Parameters None specified. ### Request Example ``` indexAll('/agents').then(agents => console.log(agents)); ``` ### Response Not specified. ``` ```APIDOC ## startProgressBar(), addToProgressBar(), endProgressBar() ### Description Utilities for tracking and displaying progress during long-running operations. ### Method Not specified (CLI functions). ### Endpoint Not applicable. ### Parameters None specified. ### Request Example ```javascript startProgressBar('Downloading...'); // ... operations ... addToProgressBar(50); // ... operations ... endProgressBar(); ``` ### Response Not specified. ``` ```APIDOC ## delay() ### Description An asynchronous delay utility function. ### Method Not specified (CLI function). ### Endpoint Not applicable. ### Parameters None specified. ### Request Example ```javascript async function myAsyncFunc() { console.log('Waiting...'); await delay(1000); console.log('Done waiting.'); } ``` ### Response Not specified. ``` ```APIDOC ## upperFirst() ### Description Capitalizes the first letter of a string. ### Method Not specified (CLI function). ### Endpoint Not applicable. ### Parameters None specified. ### Request Example ```javascript const capitalized = upperFirst('hello world'); // 'Hello world' ``` ### Response Not specified. ``` -------------------------------- ### Clone a Virtual Agent from Cognigy.AI Source: https://github.com/cognigy/cognigy-cli/blob/main/README.md Clones a Virtual Agent project from Cognigy.AI to your local disk. By default, it clones the entire agent, including AI Agents. ```bash cognigy clone ``` -------------------------------- ### Run Playbooks Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/INDEX.md Executes playbooks within the Cognigy project. ```bash cognigy run playbooks ``` -------------------------------- ### Environment Variables for Configuration Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/configuration.md Set these environment variables to configure the Cognigy CLI. Environment variables take precedence over file-based configuration. ```bash export CAI_APIKEY="your-cognigy-api-key" export CAI_AGENT="your-agent-project-id" export CAI_BASEURL="https://api-trial.cognigy.ai" export CAI_AGENTDIR="./agent" export KNOWLEDGE_AI_STORE_DIR="./knowledge-ai-store" export CAI_PLAYBOOK_TIMEOUT_SECONDS="10" export MAX_NUMBER_OF_TOKENS="2048" ``` -------------------------------- ### Configure Agent Directory Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/configuration.md Define the local file system directory for storing and synchronizing agent resources with Cognigy.AI. ```json { "agentDir": "./agent" } ``` -------------------------------- ### indexKnowledgeStores Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/knowledge-ai.md Lists all Knowledge AI Stores for a given project, with optional query parameters for pagination and filtering. ```APIDOC ## indexKnowledgeStores ### Description Lists all Knowledge AI Stores for a project. ### Method Not applicable (SDK function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **projectId** (string) - Required - Project ID - **query** (object) - Optional - Pagination and filter query ### Return Type `IKnowledgeStoreIndexResult` - List of stores with pagination info ``` -------------------------------- ### Index Knowledge Stores Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/knowledge-ai.md Lists all Knowledge AI Stores within a project. Accepts the project ID and an optional query for pagination and filtering. ```typescript export const indexKnowledgeStores = async ( projectId: string, query?: IIndexQuery ): Promise ``` -------------------------------- ### Cognigy CLI Command Pattern Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/INDEX.md All Cognigy CLI commands follow a consistent pattern. Use this as a general template for executing any CLI command. ```bash cognigy [options] ``` -------------------------------- ### Run Playbooks Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/README.md Command to execute playbooks defined in a JSON file. Specify the path to the playbooks file. ```bash cognigy run playbooks ./playbooks.json ``` -------------------------------- ### indexKnowledgeSources Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/knowledge-ai.md Lists all Knowledge AI Sources in a store, with support for pagination and filtering. ```APIDOC ## indexKnowledgeSources ### Description Lists all Knowledge AI Sources in a store. ### Method GET ### Endpoint /stores/{storeId}/projects/{projectId}/knowledge-sources ### Parameters #### Path Parameters - **storeId** (string) - Required - ID of the parent store - **projectId** (string) - Required - Project ID #### Query Parameters - **query** (object) - Optional - Pagination and filter query ### Response #### Success Response (200) - **IKnowledgeSourceIndexResult** - List of sources with pagination info ``` -------------------------------- ### ingestFile() Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/knowledge-ai.md Ingests an extracted content file into a Knowledge Store. It takes the store ID, source ID, file path, project ID, and an optional chunk size as parameters. ```APIDOC ## ingestFile() ### Description Ingests an extracted content file into a Knowledge Store. It takes the store ID, source ID, file path, project ID, and an optional chunk size as parameters. ### Method ```typescript export const ingestFile = async ( storeId: string, sourceId: string, filePath: string, projectId: string, chunkSize?: number ): Promise ``` ### Parameters #### Path Parameters - **storeId** (string) - Required - ID of the Knowledge Store - **sourceId** (string) - Required - ID of the Knowledge Source - **filePath** (string) - Required - Path to extracted content file - **projectId** (string) - Required - Project ID - **chunkSize** (number) - Optional - Number of chunks to ingest per request ### Return Type `IIngestResult` - Ingestion result with processed chunk count ``` -------------------------------- ### cloneFlows Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/flows.md Clones all Cognigy Flows from the agent to disk. It creates a 'flows' directory and pulls flows in parallel chunks, updating a progress bar. ```APIDOC ## cloneFlows() ### Description Clones all Cognigy Flows from the agent to disk. This operation creates a `flows` directory, fetches flows using pagination, and pulls them in parallel chunks, updating a progress bar. ### Method `async cloneFlows(availableProgress: number): Promise` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```typescript await cloneFlows(50); ``` ### Response #### Success Response (200) `Promise` - Resolves when all flows are cloned. #### Response Example None ``` -------------------------------- ### Compare Resources Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/INDEX.md Compares resources, such as flows, using their IDs. ```bash cognigy diff flow flowId ``` -------------------------------- ### Create Directory Recursively Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/utilities.md Creates a specified directory along with any necessary parent directories if they do not already exist. This is useful for setting up project structures. ```typescript export const checkCreateDir = async (dir: string): Promise ``` -------------------------------- ### Core Resource Management - Clone Module Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/INDEX.md Clones entire Virtual Agent projects or specific resource types to disk. The `clone()` function allows for selective cloning of agents, flows, endpoints, lexicons, or AI agents. ```APIDOC ## clone() ### Description Clones entire Virtual Agent projects or specific resource types to disk. ### Method Not specified (assumed to be a function call within the CLI context). ### Endpoint Not applicable (CLI function). ### Parameters None explicitly defined in the source, but implies parameters for specifying what to clone (agent, flows, endpoints, lexicons, AI agents). ### Request Example ``` clone({ type: 'agent', name: 'my-agent' }) ``` ### Response Not specified. ``` -------------------------------- ### Clone All Lexicons Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/lexicons.md Use this function to clone all lexicons from the agent to the local disk. It manages directory creation, fetches lexicons in parallel chunks, and updates a progress bar. ```typescript export const cloneLexicons = async ( availableProgress: number ): Promise ``` -------------------------------- ### progressBar Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/utilities.md Utilities for displaying operation progress using a progress bar. ```APIDOC ## progressBar ### Description Progress bar utilities for displaying operation progress. ### Functions #### startProgressBar() Initializes and starts a progress bar. ```typescript export const startProgressBar = (total: number): void ``` #### addToProgressBar() Increments progress bar by specified amount. ```typescript export const addToProgressBar = (increment: number): void ``` #### endProgressBar() Completes and displays final progress bar. ```typescript export const endProgressBar = (): void ``` ``` -------------------------------- ### Configuration Document Standards Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/COMPLETION_REPORT.txt Standards for documenting configuration options in the Cognigy CLI. ```APIDOC ## Configuration Document Structure Configuration documentation for the Cognigy CLI follows these standards: ### Properties Table - Name of the configuration property. - Corresponding environment variable name. - Data type. - Default value. - Description of the property. ### Detailed Property Explanations - In-depth explanations for each configuration property. ### Configuration Methods - Description of different approaches to configure the CLI. ### Priority/Precedence Rules - Explanation of how configuration values are prioritized. ### Example Config Files - Examples of configuration files. ### Best Practices - Recommendations for effective configuration. ### Troubleshooting Guide - Guidance for resolving common configuration issues. ``` -------------------------------- ### Run Playbooks with Cognigy CLI Source: https://github.com/cognigy/cognigy-cli/blob/main/README.md Schedules runs of one or more playbooks and checks their status. It can use a default './playbooks.json' file or a specified file. The format requires playbookId, entrypoint, flowId, and localeId. ```json [ { "playbookId": "", "entrypoint": "", // snapshot ID or agent ID (if no snapshot is used) "flowId": "", // this is the flow reference ID "localeId": "" // this is the locale reference ID }, { "playbookId": "", "entrypoint": "", "flowId": "", "localeId": "" } ] ``` -------------------------------- ### Clone Virtual Agent or Resources Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/clone.md Use this function to clone an entire virtual agent project or specific resource types to your local disk. It handles verification, confirmation prompts, and directory recreation. Ensure your Cognigy.AI credentials and base URL are correctly configured. ```typescript export const clone = async ({ resourceType = 'agent', forceYes = false, }): Promise ``` ```typescript // Clone entire agent await clone({ forceYes: true }); ``` ```typescript // Clone only flows with confirmation await clone({ resourceType: 'flows' }); ``` ```typescript // Clone endpoints without confirmation await clone({ resourceType: 'endpoints', forceYes: true }); ``` -------------------------------- ### Upload Knowledge Source File Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/knowledge-ai.md Uploads a file to a Knowledge AI Source. Supports various file formats including PDF, TXT, CSV, JSON, DOCX, EPUB, MD, and SRT. Returns upload result with file ID and status. ```typescript export const uploadKnowledgeSourceFile = async ( storeId: string, sourceId: string, filePath: string, projectId: string ): Promise ``` -------------------------------- ### Compare Local Resources with Cognigy.AI Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/other-commands.md The `diff` command compares local project resources against their remote versions on Cognigy.AI. It supports full resource comparison or node-by-node comparison for flows. ```typescript // Full comparison of a flow await diff('flow', 'flowId', 'full'); ``` ```typescript // Node-by-node comparison await diff('flow', 'flowId', 'node'); ``` ```typescript // Compare endpoint await diff('endpoint', 'endpointId'); ``` -------------------------------- ### Check Token Size of a Document Source: https://github.com/cognigy/cognigy-cli/blob/main/KNOWLEDGE-AI-README.md Use this command to determine the token size of a given document. Ensure you replace `path_to_input_file` with the actual file path. ```bash cognigy knowledge-ai size -i path_to_input_file ``` -------------------------------- ### handleSize() Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/knowledge-ai.md Analyzes and handles document size issues. It analyzes file size and token count, splits oversized files if needed, and returns an analysis report with recommendations. ```APIDOC ## handleSize() ### Description Analyzes and handles document size issues. It analyzes file size and token count, splits oversized files if needed, and returns an analysis report with recommendations. ### Method ```typescript export const handleSize = async ( filePath: string, options: ISizeHandleOptions ): Promise ``` ### Parameters #### Path Parameters - **filePath** (string) - Required - Path to file to analyze - **options** (object) - Required - Size handling options ### Behavior - Analyzes file size and token count - Splits oversized files if needed - Returns analysis report with recommendations ``` -------------------------------- ### Force Use of a Specific Configuration File Source: https://github.com/cognigy/cognigy-cli/blob/main/README.md Forces the Cognigy CLI to use a configuration file other than the default `./config.json`. Use the `-c` or `--config` flag followed by the path to the desired configuration file. ```bash cognigy -c ./config2.json ``` ```bash cognigy --config ./config2.json ``` -------------------------------- ### createKnowledgeSource Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/knowledge-ai.md Creates a new Knowledge AI Source within a store. This allows you to add new data sources to your project. ```APIDOC ## createKnowledgeSource ### Description Creates a new Knowledge AI Source within a store. ### Method POST ### Endpoint /stores/{storeId}/projects/{projectId}/knowledge-sources ### Parameters #### Path Parameters - **storeId** (string) - Required - ID of the parent store - **projectId** (string) - Required - Project ID #### Request Body - **name** (string) - Required - Name of the source - **sourceType** (string) - Required - Type of source (url, file, text, etc.) ### Response #### Success Response (200) - **IKnowledgeSource** - Created source object ``` -------------------------------- ### DeepL Translator Options Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/localization.md Configure options for using DeepL Translator. Provide your DeepL API key obtained from a free or pro account. ```typescript options: { translator: 'deepl', apiKey: 'your-deepl-api-key', // DeepL API key from free or pro account } ``` -------------------------------- ### Configure Playbook Timeout Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/configuration.md Set the timeout in seconds for checking playbook run status. The default is 10 seconds. ```json { "playbookTimeoutSeconds": 30 } ``` -------------------------------- ### Check Cognigy CLI Environment Variables Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/configuration.md Verify that the required Cognigy CLI environment variables are set. These are essential for the CLI to authenticate and connect to Cognigy.AI. ```bash # Check environment variables echo $CAI_APIKEY echo $CAI_AGENT echo $CAI_BASEURL echo $CAI_AGENTDIR ``` -------------------------------- ### Execute Command with Cognigy CLI Source: https://github.com/cognigy/cognigy-cli/blob/main/FAQ.md General command to execute various operations within Cognigy.AI. Arguments must be passed as a valid JSON string. ```bash cognigy execute -l ``` ```bash cognigy execute readFlow -d {"flowId": "myFlowId"} ``` -------------------------------- ### cloneLexicons() Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/lexicons.md Clones all Cognigy Lexicons from the agent to disk. This function creates a 'lexicons' directory, fetches all lexicons for the agent, and pulls them in parallel chunks, updating a progress bar. ```APIDOC ## cloneLexicons() ### Description Clones all Cognigy Lexicons from the agent to disk. This function creates a 'lexicons' directory, fetches all lexicons for the agent, and pulls them in parallel chunks, updating a progress bar. ### Method `async` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **availableProgress** (number) - Required - Percentage of progress bar to allocate to this operation (0-100) ### Return Type `Promise` - Resolves when all lexicons are cloned. ``` -------------------------------- ### checkProject() Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/api-reference/utilities.md Validates the existence of the project on Cognigy.AI using the configured credentials. The CLI will exit if credentials are invalid or the agent ID does not exist. ```APIDOC ## checkProject() ### Description Validates project exists on Cognigy.AI using configured credentials. ### Method N/A (Function Call) ### Endpoint N/A ### Parameters None ### Throws - Exits if API key or base URL is invalid - Exits if agent ID doesn't exist ### Return Type `Promise` ``` -------------------------------- ### Core Resource Management - Push Module Source: https://github.com/cognigy/cognigy-cli/blob/main/_autodocs/INDEX.md Pushes individual resources from disk to Cognigy.AI. The `push()` function is used to upload flows, endpoints, lexicons, or AI agents. ```APIDOC ## push() ### Description Pushes individual resources from disk to Cognigy.AI. ### Method Not specified (assumed to be a function call within the CLI context). ### Endpoint Not applicable (CLI function). ### Parameters None explicitly defined in the source, but implies parameters for specifying which resources to push (flows, endpoints, lexicons, AI agents). ### Request Example ``` push({ type: 'lexicon', name: 'greetings' }) ``` ### Response Not specified. ```