api classes. These functions are also available in Extension Nodes. For example, you can use the api object to execute api.say().
actions and api. Now, only api is supported. Use api functions for all implementations.CognigyScript
Use these functions to parse and evaluate CognigyScript expressions in text or conditions at run-time.api.parseCognigyScript
api.parseCognigyScript
| Parameter | Type | Description |
|---|---|---|
| text | string | The text containing CognigyScript expressions. |
| condition | boolean | The CognigyScript condition to evaluate. |
stringExampleapi.parseCognigyScriptCondition
api.parseCognigyScriptCondition
true or false value.CognigyScript allows you to embed expressions like {{context.value > 5}} within strings. This function extracts and evaluates such an expression, used in logic checks for Flows, conditions, or custom functions.This function is useful for dynamically checking conditions at run-time based on session data and information from the Input, Context, or Profile objects.Parameters| Parameter | Type | Description |
|---|---|---|
| condition | string | The CognigyScript condition to evaluate. |
stringExampleapi.parseCognigyScriptText
api.parseCognigyScriptText
{{cc.userName}}, is evaluated using the current execution context.Parameters| Parameter | Type | Description |
|---|---|---|
| text | string | The text containing CognigyScript expressions. |
stringExampleContact Profiles
Use these functions to activate, deactivate, delete, merge, and update Contact Profiles during a conversation.api.activateProfile
api.activateProfile
voidExampleapi.addContactMemory
api.addContactMemory
memories array of the Profile object.Parameters| Parameter | Type | Description |
|---|---|---|
| memory | string | The text to add as a new entry in the memories array of the Profile object. |
voidExampleapi.deactivateProfile
api.deactivateProfile
voidExampleapi.deleteProfile
api.deleteProfile
voidExampleapi.mergeProfile
api.mergeProfile
| Parameter | Type | Description |
|---|---|---|
| contactId | string | The ID of the Contact Profile to merge into. |
voidExampleapi.updateProfile
api.updateProfile
| Parameter | Type | Description |
|---|---|---|
| key | string | The key of the Contact Profile field to update. |
| value | any | The value to set for the specified key. |
voidExampleContext Object
Use these functions to read, write, and reset the Context object so you can store and manipulate conversation-scoped data across Nodes.api.addToContext
api.addToContext
| Parameter | Type | Description |
|---|---|---|
| key | string | The key to add to the Context object. |
| value | any | The value to assign to the key. |
| mode | string | Determines how the value is added:
|
voidExampleapi.deleteContext
api.deleteContext
| Parameter | Type | Description |
|---|---|---|
| key | string | The key in the Context object to remove. |
voidExampleapi.getContext
api.getContext
| Parameter | Type | Description |
|---|---|---|
| key | string | The key to retrieve the data from the Context object. |
any: The requested context data.Exampleapi.getConversationTranscript
api.getConversationTranscript
| Parameter | Type | Description |
|---|---|---|
| mode | string | This parameter is optional. Specifies the format of the returned transcript:
|
| options | object | This parameter is optional. An object to configure the retrieved transcript data. |
| options.turnLimit | number | This parameter is optional. Limits the transcript to the most recent N conversational turns. If the parameter is omitted, the full transcript is returned. |
api.removeFromContext
api.removeFromContext
| Parameter | Type | Description |
|---|---|---|
| key | string | The key in the Context object to remove information from. |
| value | any | The value to remove when using "array" mode. Ignored in "simple" mode. |
| mode | string | Determines how the removal is performed:
|
voidExampleapi.resetContext
api.resetContext
voidExampleapi.setContext
api.setContext
| Parameter | Type | Description |
|---|---|---|
| key | string | The key in the Context object to set. |
| value | any | The value to set for the key. |
voidExampleEncoding and Decoding
Use these functions to handle string encoding and decoding, such as converting text to Base64 for safe transmission or decoding Base64 strings back to UTF-8.api.base64Decode
api.base64Decode
| Parameter | Type | Description |
|---|---|---|
| data | string | The string to be decoded. |
string: The decoded string as UTF-8.Exampleapi.base64Encode
api.base64Encode
| Parameter | Type | Description |
|---|---|---|
| data | string | The string to be encoded. |
string: The base64 encoded string.ExampleExecution Control
Use these functions to control Flow execution, including adding conditional Entrypoints, jumping to specific Nodes or Flows, resetting overrides, stopping execution, and simulating new inputs.api.addConditionalEntrypoint
api.addConditionalEntrypoint
{condition} is met within the next {retentionTime} inputs, Flow execution starts at {entrypoint}.Parameters| Parameter | Type | Description |
|---|---|---|
| entrypoint | string | The ID of the Node to execute when the condition evaluates to true. |
| retentionTime | number | The number of times this conditional Entrypoint can trigger before it is automatically removed. |
| condition | string | A string expression evaluated. For example, input.text.includes('@') checks if the user input contains @. |
voidExampleapi.resetNextNodes
api.resetNextNodes
api.setNextNode function, and you want to return to the default Flow behavior.ParametersNoneReturnsvoidExampleapi.setNextNode
api.setNextNode
nodeId to be executed immediately after the current one.
This function is used by If and Lookup Nodes to select child Nodes based on their configuration.Parameters| Parameter | Type | Description |
|---|---|---|
| nodeId | string | The ID of the Node to execute next. |
| newFlowId | string | The ID of the Flow containing the target Node. This parameter is optional and is required if the target Node is in a different Flow. |
voidExampleapi.stopExecution
api.stopExecution
voidExampleapi.thinkV2
api.thinkV2
| Parameter | Type | Description |
|---|---|---|
| text | string | A simulated input text |
| data | object | A simulated input data object with optional fields and additional keys |
voidExampleInput and Output
Use these functions to enrich the Input object and send text or data responses to the user from a Code or Extension Node.api.addToInput
api.addToInput
| Parameter | Type | Description |
|---|---|---|
| key | string | The key to add to the Input object. |
| value | string | The value to assign to the key. |
voidExampleapi.output / api.say
api.output / api.say
| Parameter | Type | Description |
|---|---|---|
| text | string | The output text that is sent to the user. |
| data | any | The output data that is sent to the user. |
voidExampleLogging and Monitoring
Use these functions to write Project logs, send debug messages, inspect LLM token usage, track analytics steps, and configure sensitive logging behavior.api.completeGoal
api.completeGoal
| Parameter | Type | Description |
|---|---|---|
| name | string | The name of the task. |
voidExampleapi.emitToOpsCenter
api.emitToOpsCenter
Flow and the subcomponent to FlowNodeExecution.Parameters| Parameter | Type | Description |
|---|---|---|
| title | string | The title of the error to log. |
| projectId | string | The ID of the Project where the error occurs. |
voidExampleapi.getLLMTokenUsageForSession
api.getLLMTokenUsageForSession
api.log
api.log
| Parameter | Type | Description |
|---|---|---|
| level | string | The log level. Cognigy.AI includes the following log levels:
|
| text | string | The message to write to the logs. |
voidExampleapi.logDebugMessage / api.logDebugError
api.logDebugMessage / api.logDebugError
| Parameter | Type | Description |
|---|---|---|
| message | string / object | The debug message to log. When logging an object, use JSON.stringify to make it readable in the Interaction Panel. |
| header | string | An optional label or header for the log message, used to categorize it in the debug panel. |
voidExampleapi.setSensitiveLoggingSettings
api.setSensitiveLoggingSettings
| Parameter | Type | Description |
|---|---|---|
| maskLogging | boolean | Masks sensitive information in system logs on the Logs page. Replaces fields like userId, text, and data with asterisks to protect user privacy. |
| maskAnalytics | boolean | Masks sensitive information in Input, Insights, and Analytics (inputText, inputData, userLanguageText, and user IP). Disables the Intent Trainer because input text isn’t stored. Can selectively ignore analytics using a Code Node. |
| maskIPAddress | boolean | This parameter is optional. Masks the user’s IP address in the Input object, Insights, and Analytics. IP addresses are replaced with asterisks and aren’t available via OData Analytics. |
| disableConversations | boolean | Disables logging of conversation content entirely. No conversation data will be stored. |
| disableIntentTrainer | boolean | This parameter is optional. Disables logging for the Intent Trainer, preventing user input from being stored or used for training intents. |
| traceId | string | This parameter is optional. A unique ID for tracing this API call. Helps track requests in logs and diagnostics without affecting masking or logging behavior. |
voidExampleapi.trackAnalyticsStep
api.trackAnalyticsStep
| Parameter | Type | Description |
|---|---|---|
| stepLabel | string | The label of the analytics step to track. |
voidExampleStates
Use these functions to get, set, and reset the conversation State of a Flow.api.getState
api.getState
stringExampleapi.resetState
api.resetState
voidExampleapi.setState
api.setState
| Parameter | Type | Description |
|---|---|---|
| state | string | The State that should be activated. |
voidExamplexApps
Use these functions to manage conversations with xApps.api.setAppState
api.setAppState
| Parameter | Type | Description |
|---|---|---|
| appTemplateId | string | The xApp template identifier. Can be a URL to a hosted xApp template, generic-html to load inline HTML with the xApp Page SDK, or null to close the active xApp Page. |
| appTemplateData | object | The data payload passed to the xApp Page. For generic-html, this must include an html field containing the HTML to render. |
voidExampleOther
Use these functions to manage conversation behavior, such as adding Keyphrases, handling handovers, and localization settings.api.addLexiconKeyphrase
api.addLexiconKeyphrase
| Parameter | Type | Description |
|---|---|---|
| lexiconId | string | The ID of the Lexicon to which the Keyphrase will be added. |
| keyphrase | string | The primary phrase to add to the Lexicon. |
| tags | string[] | An array of strings used to categorize or filter the Keyphrase. |
| synonyms | string[] | An array of strings representing alternative phrases that should be recognized as the same Keyphrase. |
| data | object | This parameter is optional. The custom data associated with the Keyphrase. |
voidExampleapi.evaluateRule
api.evaluateRule
left, operand, right pattern. This function works similarly to the If Node. The left value is compared with the right value using the specified operator, for example, !=, >, includes. If the condition evaluates to true, the associated logic or transition is executed.Parameters| Parameter | Type | Description |
|---|---|---|
| left | string | The primary value to be evaluated. |
| operand | string | The comparison operator used to evaluate the relationship between the left and right values. Supported operators:
|
| right | string | The reference value to compare against the left value. This parameter is ignored for operators that check only the state of the left value, such as exists, nexists, isyes, and isno. |
booleanExampleapi.handover
api.handover
| Parameter | Type | Description |
|---|---|---|
| text | string | The message to send to the user. |
| cancelIntent | string | The Intent that will be triggered if the user cancels the handover. |
| unavailable | string | The message shown to the user if no agent is available. |
| unsupportedChannel | string | The message shown if the current channel doesn’t support handover. |
| quickReply | string | The text for a quick reply button offered to the user. |
| chatwootInboxId | string | The ID of the Chatwoot inbox where the conversation should be routed. |
| liveAgentInboxId | string | The ID of the Live Agent inbox where the conversation should be routed. |
voidExampleapi.setLocaleReferenceId
api.setLocaleReferenceId
| Parameter | Type | Description |
|---|---|---|
| localeReferenceID | string | The Locale Reference ID to set. |
voidExampleapi.setRating
api.setRating
| Parameter | Type | Description |
|---|---|---|
| rating | number | The rating for the conversation: -1 for negative or 1 for positive. |
| comment | string | Additional information about the rating. |
voidExampleapi.setTimezoneOffset
api.setTimezoneOffset
input.currentTime.timezoneOffset.Parameters| Parameter | Type | Description |
|---|---|---|
| offset | number | The time offset in hours. |
voidExample