Skip to main content
In a Code Node, you can use the functions of the api classes. These functions are also available in Extensions. You can use the api object to, for example, execute api.say().
Previously, you could use both actions and api. Now, only api is supported. Use api functions for all implementations.

General

Executes a basic output to the contact, similar to the functionality of the Say Node.Parameters
ParameterTypeDescription
textstringThe output text that is sent to the contact.
dataanyThe output data that is sent to the contact
Returnsvoid
Completes the goal in Insights.Parameters
ParameterTypeDescription
keystringThe name of the goal that will be completed in Insights.
ReturnsPromise<void>
Sets the time zone offset from UTC.Parameters
ParameterTypeDescription
offsetnumberThe time offset in hours.
Returnsvoid
Sends a debug info or error message. Only visible in the Interaction Panel’s Debug Mode.Parameters
ParameterTypeDescription
messagestringThe debug message text.
headerstringThe Header text for the debug message. This parameter is optional.
Returnsvoid
Writes a message to the Project logs.Parameters
ParameterTypeDescription
levelstringThe log level, for example, debug or info.
textstringThe message for the logs.
Returnsvoid
Both actions.think and api.think have been deprecated in Cognigy.AI v4.98. The removal date is June 2025. Use api.thinkV2 instead.
Is used to re-execute the Flow within one invocation.The Flow will stop and then restart executing at the Start Node.Parameters
ParameterTypeDescription
textstringA simulated message text from the user.
dataanySimulated message data from the user.
Returnsvoid
Is used to re-execute the Flow within one invocation.The Flow will stop and then restart executing at the Start Node.Parameters
ParameterTypeDescription
textstringA simulated message text from the user.
dataanySimulated message data from the user.
Returnsvoid

Context

Is used to simplify storing information into the conversation’s Context.Parameters
ParameterTypeDescription
keystringWhere to store the data in the Context.
valuestringThe value to store in the Context.
modestringIn simple mode, will replace existing values, in array mode, it will store information in an array and push new results into that array.
Returnsvoid
Gets the data from the context by the key.Parameters
ParameterTypeDescription
keystringWhere to retrieve the data from the context.
Returnsany: The requested context data
Retrieves the current conversation transcript, including the last 10 user inputs and the associated outputs from the AI Agent.Parameters
ParameterTypeDescription
modestring- json — returns an array of conversation entries. This option is default.
- string — returns a stringified version of the transcript.
optionsobjectOptions to be passed to the function. The example is presented below.
Example Options:
{
    "turnLimit": 3 // the number of turns to return
}
ReturnsEither the JSON array of conversation entries or the string representation.Example JSON:
[
    { "source":"user", "text":"hello" },
    { "source":"bot", "text":"You said: hello" },
    { "source":"user", "text":"you are an ai agent" },
    { "source":"bot", "text":"You said: you are an ai agent" },
    { "source":"user", "text":"show transcript" }
]
Example string:
- USER: hello
- BOT: You said: hello
- USER: you are an ai agent
- BOT: You said: you are an ai agent
- USER: show transcript
Resets the context.ParametersnoneReturnsPromise
Removes information from the conversation’s Context.Parameters
ParameterTypeDescription
keystringThe key in the Context to remove information from
valuestringThe value to remove (in array mode)
modestringIn simple mode will remove the property completely, in array mode it will remove matching values from that array.
Returnsvoid
Deletes the key and its values from the conversation’s Context.Parameters
ParameterTypeDescription
keystringThe key in the Context to remove information from
Returnsvoid

State

Is used to set the current State of this Conversation.Parameters
ParameterTypeDescription
statestringThe State that should be activated.
Returnsvoid
Returns the current state.ParametersnoneReturnsstring: The current state.
Resets the state of the flow to the default stateParametersnoneReturnsPromise<string>

Lexicon

Parameters
ParameterTypeDescription
keyphrasestringThe Keyphrase you want to set
tagsstring[]Tags you want to attach to the Keyphrase
synonyms (optional)string[]Synonyms you want to attach to the Keyphrase
Returnsvoid
Adds a new Keyphrase to a Lexicon.Parameters
ParameterTypeDescription
lexiconIdstringThe ID of the Lexicon you want to update
keyphrasestringThe Keyphrase you want to add to the Lexicon
tagsanyTags you want to attach to the Keyphrase.
synonymsanySynonyms you want to attach to the Keyphrase
ReturnsPromise<string>

Profile

Is used to reactivate a profile that has been deactivated, in case the user disabled data collection by mistake or wants to allow data collection again.ParametersNoneReturnsPromise<any>
Is used to update the users’ Contact Profile.Parameters
ParameterTypeDescription
keystringWhich field in the user’s Contact Profile to update.
valuestringThe value you want to set.
ReturnsPromise<any>
Is used to merge the profile of the contact who hits the Node with another contact profile.This is useful in an omnichannel environment, where a contact can talk to your Flow on different platforms, but wants to be recognized as the same person on all platforms.Parameters
ParameterTypeDescription
contactIdstringThe id of the contact you want to merge with the current contact who hit the Node.
ReturnsPromise<any>
Is used to deactivate a specific contact profile in case a contact requests it.ParametersNoneReturnsPromise<any>
I