Actions

Description

Within a Code Node you are able to use the functions of the actions class.

Misc

actions.output / actions.say


Performs a simple output to the contact - similiar to the Say Node.

Parameters

ParameterTypeDescription
textstringThe output text which gets send to the contact
dataanythe output data which gets send to the contact

Returns

void

actions.completeGoal


Adds a defined goal to the completedGoals array in the Input Object.

Parameters

ParameterTypeDescription
keystringname of the goal to add to the completedGoals array

Returns

Promise

actions.setTimezoneOffset


Sets the timezone offset from UTC.

Parameters

ParameterTypeDescription
offsetnumberThe offset in hours

Returns

void

actions.setForwardDatesOnly


Sets the NLU Parser to only detect dates in the future for DATE slots.

Please Note: This setting will take effect on the next input only

Parameters

valuebooleanWhether to only detect future dates for DATE slots

Returns

void

actions.log


Writes a message to the project logs.

Parameters

ParameterTypeDescription
levelstringThe log level, e.g. debug or info
textstringThe message for the logs

Returns

void

actions.think


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.

Returns

void

Context

actions.setContext


❗️

Deprecation Warning

This action will be removed and no longer work in Cognigy.AI Version 4.0. Please use actions.addToContext instead.

Sets the context of a flow to a specified value.

Parameters

ParameterTypeDescription
keystringWhere to store the data in the Context.
*valueanyThe value to store in the Context.

Returns

void

actions.addToContext


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.

Returns

void

actions.getContext


Gets the data from the context by the key.

Parameters

ParameterTypeDescription
keystringWhere to retrieve the data from the context.

Returns

any : The requested context data

actions.resetContext


Resets the context.

Parameters

none

Returns

Promise

actions.removeFromContext


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 move it will remove matching values from that array.

Returns

void

actions.deleteContext


Deletes the key and its values from the conversation's Context.

Parameters

ParameterTypeDescription
keystringThe key in the Context to remove information from

Returns

void

State

actions .setState


Is used to set the current State of this Conversation.

Parameters

ParameterTypeDescription
statestringThe State that should be activated.

Returns

void

actions .getState


Returns the current state.

Parameters

none

Returns

string : The current state.

actions .resetState


Resets the state of the flow to the default state

Parameters

none

Returns

Promise

Lexicon

actions .setKeyphrase


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

Returns

void

actions .addLexiconKeyphrase


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

Returns

Promise

Profile

actions .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.

Parameters

None

Returns

Promise

actions .updateProfile


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.

Returns

Promise

actions .mergeProfile


Is used to merge the profile of the contact who hits the node with another contact profile.

This is useful in an omni-channel 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.

Returns

Promise

actions .deactivateProfile


Is used to deactivate a specific contact profile in case a contact requests it.

Parameters

None

Returns

Promise