Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The Flow Manager module adds a standard flow studio manager implementation with capabilities for randomized content and the registration and execution of hooks via Custom nodes in flow studio flows.

Table of Contents

Dependencies

The Flow Manager module is dependent on the following modules:

Methods

changeFlow

Clears the flow session and redirects the user to the specified flow.

...

  • msg (string): The Node-RED message object.

  • flowId (string): The ID of the flow to switch to.

Returns: Nothing.

Anchor
handle
handle
handle

Passes a request back to the flow manager node to be handled.

...

  • msg (string): The Node-RED message object.

Returns: Nothing.

registerHook

Registers a hook for retrieval and execution.

...

  • key (string): The key that the hook will be retrieved by and executed (see Execution of Hooks).

  • hook (function): The hook handler function (see Hook Requirements).

  • module (string, optional): The module key if this hook is specific to a particular module context.

Returns: Nothing.

getHook

Retrieves a hook by key for execution.

...

Returns: The hook, if a match is found, nothing otherwise.

setCurrentModule

Sets the key of the currently active module in session.

...

  • msg (object): The Node-RED message object.

  • moduleKey (string): The key of the currently active module.

getCurrentModule

Returns the key of the currently active module in session.

...

  • msg (object): The Node-RED message object.

clearCurrentModule

Clears the key of the currently active module from session.

...

  • msg (object): The Node-RED message object.

Standard Hooks

error

Records an error of type “Flow Studio”

...

  • msg (object): The Node-RED message object.

  • error (string): The error message.

  • handleResponse (boolean, default = true): Whether or not the message should be handled by the Flow Manager module (true) or if the flow should continue on.

disableKeyboard

Disables keyboard input in the Chatbot module.

...

  • msg (object): The Node-RED message object.

enableKeyboard

Enables keyboard input in the Chatbot module.

...

  • msg (object): The Node-RED message object.

disableAudio

Disables audio in the Chatbot module.

...

  • msg (object): The Node-RED message object.

enableAudio

Enables audio in the Chatbot module.

...

  • msg (object): The Node-RED message object.

setWpm

Sets a dynamic word per minute based wait time in the Chatbot module.

...

  • msg (object): The Node-RED message object.

  • wpm (string): The desired word per minute rate.

setCurrentModule

Sets the key of the currently active module in session.

...

  • msg (object): The Node-RED message object.

  • moduleKey (string): The key of the currently active module.

getCurrentModule

Gets the key of the currently active module from session and sets it as msg.currentModule.

...

  • msg (object): The Node-RED message object.

clearCurrentModule

Clears the key of the currently active module from session.

...

  • msg (object): The Node-RED message object.

trackFlow

Invokes the currently registered trackFlow handler, passing it the message object and current flow name.

...

  • msg (object): The Node-RED message object.

Anchor
hook-requirements
hook-requirements
Hook Requirements

The only strict requirement for a hook is that it must be a function.

...

Any parameters after msg will have any additional parameters from the hook execution applied in order (see Parameters).

Anchor
execution-of-hooks
execution-of-hooks
Execution of Hooks

Hooks are executed through Custom nodes in flow studio flows. To execute a hook, just change the name of the Custom node to the name of the hook you want to invoke:

...

The msg object will be passed automatically as the first parameter to the hook.

Anchor
module-context
module-context
Module Context

Hooks for a module can be namespaced by specifying the optional module parameter when registering them.

...

Info

This allows for the behavior of root level hooks established by other modules to be overridden in a particular module context, if needed.

Anchor
parameters
parameters
Parameters

The following is an example of specifying additional parameters:

...

In the above example for the starRating hook (see Input Controls) the hook function signature is:

...

Note

The values will be applied as strings. The hook is responsible for doing any necessary parsing of additional parameters from strings to other types.

Button Injection

An array of button choices (in the appropriate format for the Orbita button directive) set in session at msg.orbita.session.modules.flowManager.injectedButtons will be included in the next response generated by the Flow Manager module, and cleared from session.

Handlers

Handlers for the following events can be registered by calling flowManager.registerHandler and passing it the handler key:

beforeIntraFlowResponse

This handler is executed immediately after pin 1 of the flow manager node produces an output, and before response randomization and button injection. The handler can be asynchronous and modifications made to the msg object by the handler will be carried forward.

...

  • msg (object): The Node-RED message object.

beforeEndFlowResponse

This handler is executed immediately after pin 2 of the flow manager node produces an output, and before response randomization and button injection. The handler can be asynchronous and modifications made to the msg object by the handler will be carried forward.

...

  • msg (object): The Node-RED message object.

Anchor
trackFlow
trackFlow
trackFlow

This handler is executed when the trackFlow hook is invoked.

...