Class: AskAndMap

Composites. AskAndMap

Sends the message based on prompt or view properties. image is an html file name under images folder. imageDataArrayName is the composite field name for an array object that contains data for the images. Once sent, waits for a response and then directs the flow to the child found according to the intents/entities map. Selects by message intent & entities the children. A context is created for each child. Contexts may have an expected intentId (a string or a regex) and entities, or a helper:true that would occur as default, if no matching intent was found If execution has a context already, it will continue to tick the current child, unless a bottom-up context search changes the selected child. If no child is selected, Helper child is entered every tick. On a timeout (user haven't answered in runningTimeoutSec) the timeout child is entered. If there's no timeout child, resort to default timeout behaviour (see BaseNode). Node is closed when no more children are running. The entities from last child are mapped to the parent, and all contexts are cleared. The target is mapped to the expected intents and entities. If more than one entity of a certain name, an entity array will be created.

new AskAndMap()

Members


parameters :Object

Node parameters
Type:
  • Object
Properties:
Name Type Description
parameters
Properties
Name Type Description
prompt ExpressionString | Object | Array.<ExpressionString> | Array.<TextObject> a textual message to the user. can contains an array for random messages. can contain an object with "language" keys.
cyclePrompts boolean if true, will show the prompts cyclicly. false: will stay on the last prompt forever.
view ExpressionString | Object a file name of a view, or a view JSON object, to be used instead of the prompt in order to send native json
image ExpressionString an html string or a file name, that is rendered as an image to send the user
imageDataArrayName MemoryField composite (message./global./context./volatile./local.) field name for an array object that contains data for the images
contexts Array.<ContextItem> an array of contexts, each consists of expected entities, intents and more (ContextItem)
replayActionOnReturnFromContextSwitch boolean if false, this node is not closed and re-opened when return from context switch

Methods


contextChildren()

the context children are all the children

contextProperties()

get the properties of all contexts on the contextmanager node

currentContextChild(tick)

get current context child
Parameters:
Name Type Description
tick *

findTimeoutChild()

find the first child that doesnt have any intent or entities

handleTimeout(tick)

selects a timeout child if exists
Parameters:
Name Type Description
tick Tick

tick(tick, target)

map entities and tick down The context can be searched only below a certain point in the tree. If the conversation is at a certain context, and the context is switched to a different context, then that switch point is the place to start. otherwise, we dont have a context yet, so we search from the top
Parameters:
Name Type Description
tick Tick
target *

tickMessagePromise(tick [, fieldName])

send a message method. output a message asynchrously
Parameters:
Name Type Argument Description
tick Tick
fieldName string <optional>
to use when building a message. ,instead of prompt
Returns:
A state constant.
Type
Promise

validators()

defines validation methods to execute at the editor; if one of them fails, a dashed red border is displayed for the node
Returns:
Type
Array.<Validator>

wasEntityUsed(target, ett, searchDirection)

for AskAndMap, return true if entity was used, period, regardless of the direction (for ContextSelector on downwards direction you can use for mappings even if used )
Parameters:
Name Type Argument Description
target Target
ett * : entity
searchDirection string <nullable>
"upwards" or "downwards"
Returns:
Type
boolean