Skip to main content
Updated in 2025.24 In a Code Node, you can use the functions of the api classes. These functions are also available in Extension Nodes. For example, you can use the api object to execute api.say().
Previously, you could use both 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.
Parses CognigyScript text or conditions.ParametersReturnsPromise<any>Example
Evaluates a CognigyScript expression and returns a 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.ParametersReturnsPromise<string>Example
Parses and renders a text string containing CognigyScript expressions. Each CognigyScript expression, for example, {{cc.userName}}, is evaluated using the current execution context.ParametersReturnsPromise<string>Example

Contact Profiles

Use these functions to activate, deactivate, delete, merge, and update Contact Profiles during a conversation.
Activates the Contact Profile. Call this function to reactivate read and write operations on a previously deactivated Contact Profile.ParametersNoneReturnsPromise<any>Example
Adds an entry to the memories array of the Profile object.ParametersReturnsvoidExample
Deactivates the Contact Profile. While the Contact Profile is deactivated, no data can be read from or written to the Contact Profile.ParametersNoneReturnsPromise<any>Example
Permanently deletes the Contact Profile from the system.ParametersNoneReturnsPromise<any>Example
Merges the current Contact Profile with another one. This function is useful for combining duplicate Contact Profiles or moving data between users.ParametersReturnsPromise<any>Example
Updates a value in the current Contact Profile.ParametersReturnsPromise<any>Example

Context Object

Use these functions to read, write, and reset the Context object so you can store and manipulate conversation-scoped data across Nodes.
Adds a value to the Context object, either replacing an existing value or appending to it as an array.ParametersReturnsvoidExample
Deletes the key and its value from the Context object.ParametersReturnsvoidExample
Retrieves data from the specified key in the Context object.ParametersReturnsany: The requested context data.Example
Retrieves the current conversation transcript, including the last 10 user inputs and the associated outputs from the AI Agent.ParametersReturnsEither the JSON array of conversation entries or the string representation.JSON:
String:
ExampleJSON:
String:
Removes information from the Context object either by deleting a key entirely or by removing specific entries from an array stored at that key.ParametersReturnsvoidExample
Resets the Context object for the current conversation. All keys and values added during the conversation are removed.ParametersNoneReturnsvoidExample
Sets the value for a specific key in the Context object, replacing any existing value.ParametersReturnsvoidExample

Encoding 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.
Base64 decodes a given string.ParametersReturnsstring: The decoded string as UTF-8.Example
Base64 encodes a given string.ParametersReturnsstring: The base64 encoded string.Example

Execution 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.
Adds a conditional Entrypoint for the current conversation.If {condition} is met within the next {retentionTime} inputs, Flow execution starts at {entrypoint}.ParametersReturnsvoidExample
Clears any active overrides for the next Node in the Flow.This function is useful when you’ve changed the next Node using the api.setNextNode function, and you want to return to the default Flow behavior.ParametersNoneReturnsvoidExample
Sets the Node with the given 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.ParametersReturnsvoidExample
Stops the execution of the Flow.ParametersNoneReturnsvoidExample
Restarts Flow execution with a simulated input using the provided text and data.ParametersReturnsvoidExample

Input 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.
Adds a key-value pair to the Input object.ParametersReturnsvoidExample
Executes a basic output to the contact, similar to the Say Node.Parameters
_cognigy is an internal parameter and not part of the public API. This parameter is unsupported and may change without notice.
ReturnsvoidExample

Logging and Monitoring

Use these functions to write Project logs, send debug messages, inspect LLM token usage, track analytics steps, and configure sensitive logging behavior.
Completes the task. The information that the task has been completed is recorded and is available in Cognigy Insights and the Cognigy.AI OData endpoint.ParametersReturnsPromise<void>Example
Forwards an error to the Ops Center Error page. Automatically sets the component to Flow and the subcomponent to FlowNodeExecution.ParametersReturnsvoidExample
Retrieves the LLM token usage information for the current session.ParametersNoneReturns
Example
Writes a message to the Project logs.ParametersReturnsvoidExample
Sends a debug message. The message is visible only in the Interaction Panel with activated debug mode.ParametersReturnsvoidExample
Configures masking of sensitive data in logs, analytics, and conversation content for the session.ParametersReturnsvoidExample
Tracks a custom analytics step for the session. Useful for monitoring user interactions or workflow progress.ParametersReturnsvoidExample

States (deprecated)

As of Cognigy.AI 2026.7.0, States are deprecated. The removal of States is planned for Cognigy.AI 2026.12.0. Before the removal, delete your States and retrain your NLU model so it no longer uses state-based Intent masking. For alternative approaches to control Intent recognition, use Intent Conditions.
Use these functions to get, set, and reset the conversation State of a Flow.
Returns the current State of the conversation.ParametersNoneReturnsstringExample
Resets the State of the Flow to the initial State.ParametersNoneReturnsPromise<string>Example
Updates the conversation State to a specified State.ParametersReturnsvoidExample

xApps

Use these functions to manage conversations with xApps.
Updates the state of the xApp Session for the current conversation. Only works if an xApp Session was started beforehand.ParametersReturnsvoidExample

Other

Use these functions to manage conversation behavior, such as adding Keyphrases, handling handovers, and localization settings.
Adds a new Keyphrase to a Lexicon.ParametersReturnsPromise<string>Example
Evaluates a condition based on a rule configuration that follows the 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.ParametersReturnsPromise<boolean>Example
Initiates a handover to a human agent or another system.ParametersReturnsPromise<void>Example
Sets the Reference ID to specify which Locale is used for localization.ParametersReturnsvoidExample
Sets a rating for the conversation to prefill a rating prompt with a specific value or update it based on other actions or user inputs. Using this function, you can collect feedback at specific steps.ParametersReturnsvoidExample
Sets the time zone offset from UTC for the session, allowing time-related data to be interpreted correctly. You can view the applied time zone in the Input object under input.currentTime.timezoneOffset.ParametersReturnsvoidExample

More Information

Last modified on June 24, 2026