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
api.output / api.say
api.output / api.say
Executes a basic output to the contact, similar to the functionality of the Say Node.Parameters
Returnsvoid
Parameter | Type | Description |
---|---|---|
text | string | The output text that is sent to the contact. |
data | any | The output data that is sent to the contact |
api.completeGoal
api.completeGoal
Completes the goal in Insights.Parameters
Returns
Parameter | Type | Description |
---|---|---|
key | string | The name of the goal that will be completed in Insights. |
Promise<void>
api.setTimezoneOffset
api.setTimezoneOffset
Sets the time zone offset from UTC.Parameters
Returns
Parameter | Type | Description |
---|---|---|
offset | number | The time offset in hours. |
void
api.logDebugMessage / api.logDebugError
api.logDebugMessage / api.logDebugError
Sends a debug info or error message. Only visible in the Interaction Panel’s Debug Mode.Parameters
Returns
Parameter | Type | Description |
---|---|---|
message | string | The debug message text. |
header | string | The Header text for the debug message. This parameter is optional. |
void
api.log
api.log
Writes a message to the Project logs.Parameters
Returns
Parameter | Type | Description |
---|---|---|
level | string | The log level, for example, debug or info . |
text | string | The message for the logs. |
void
(Deprecated) api.think
(Deprecated) api.think
Both
actions.think
and api.think
have been deprecated in Cognigy.AI v4.98. The removal date is June 2025. Use api.thinkV2
instead.Parameter | Type | Description |
---|---|---|
text | string | A simulated message text from the user. |
data | any | Simulated message data from the user. |
void
api.thinkV2
api.thinkV2
Is used to re-execute the Flow within one invocation.The Flow will stop and then restart executing at the Start Node.Parameters
Returns
Parameter | Type | Description |
---|---|---|
text | string | A simulated message text from the user. |
data | any | Simulated message data from the user. |
void
Context
api.addToContext
api.addToContext
Is used to simplify storing information into the conversation’s Context.Parameters
Returns
Parameter | Type | Description |
---|---|---|
key | string | Where to store the data in the Context. |
value | string | The value to store in the Context. |
mode | string | In simple mode, will replace existing values, in array mode, it will store information in an array and push new results into that array. |
void
api.getContext
api.getContext
Gets the data from the context by the key.Parameters
Returns
Parameter | Type | Description |
---|---|---|
key | string | Where to retrieve the data from the context. |
any
: The requested context dataapi.getConversationTranscript
api.getConversationTranscript
Retrieves the current conversation transcript, including the last 10 user inputs and the associated outputs from the AI Agent.Parameters
Example Options:ReturnsEither the JSON array of conversation entries or the string representation.Example JSON:Example string:
Parameter | Type | Description |
---|---|---|
mode | string | - json — returns an array of conversation entries. This option is default. - string — returns a stringified version of the transcript. |
options | object | Options to be passed to the function. The example is presented below. |
api.resetContext
api.resetContext
Resets the context.ParametersnoneReturns
Promise
api.removeFromContext
api.removeFromContext
Removes information from the conversation’s Context.Parameters
Returns
Parameter | Type | Description |
---|---|---|
key | string | The key in the Context to remove information from |
value | string | The value to remove (in array mode) |
mode | string | In simple mode will remove the property completely, in array mode it will remove matching values from that array. |
void
api.deleteContext
api.deleteContext
Deletes the key and its values from the conversation’s Context.Parameters
Returns
Parameter | Type | Description |
---|---|---|
key | string | The key in the Context to remove information from |
void
State
api.setState
api.setState
Is used to set the current State of this Conversation.Parameters
Returns
Parameter | Type | Description |
---|---|---|
state | string | The State that should be activated. |
void
api.getState
api.getState
Returns the current state.ParametersnoneReturns
string
: The current state.api.resetState
api.resetState
Resets the state of the flow to the default stateParametersnoneReturns
Promise<string>
Lexicon
api.setKeyphrase
api.setKeyphrase
Parameters
Returns
Parameter | Type | Description |
---|---|---|
keyphrase | string | The Keyphrase you want to set |
tags | string[] | Tags you want to attach to the Keyphrase |
synonyms (optional) | string[] | Synonyms you want to attach to the Keyphrase |
void
api.addLexiconKeyphrase
api.addLexiconKeyphrase
Adds a new Keyphrase to a Lexicon.Parameters
Returns
Parameter | Type | Description |
---|---|---|
lexiconId | string | The ID of the Lexicon you want to update |
keyphrase | string | The Keyphrase you want to add to the Lexicon |
tags | any | Tags you want to attach to the Keyphrase. |
synonyms | any | Synonyms you want to attach to the Keyphrase |
Promise<string>
Profile
api.activateProfile
api.activateProfile
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.ParametersNoneReturns
Promise<any>
api.updateProfile
api.updateProfile
Is used to update the users’ Contact Profile.Parameters
Returns
Parameter | Type | Description |
---|---|---|
key | string | Which field in the user’s Contact Profile to update. |
value | string | The value you want to set. |
Promise<any>
api.mergeProfile
api.mergeProfile
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
Returns
Parameter | Type | Description |
---|---|---|
contactId | string | The id of the contact you want to merge with the current contact who hit the Node. |
Promise<any>
api.deactivateProfile
api.deactivateProfile
Is used to deactivate a specific contact profile in case a contact requests it.ParametersNoneReturns
Promise<any>