Versions Compared

Key

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

As a Flow Studio designer, you would want the user to fill an HTML form, or ask for the user to log-in, or send a carousel while executing the Flow studio. In such cases, you can use the Custom Control in the Flow Studio to literally come out of the Flow Studio flow and execute your business logic using a function node in the Experience Designer.

Table of Contents
excludeRelated Articles

If you want to continue the Flow Studio flow after executing the Custom Control, you have to connect the output from the function node to the Flow Manager node in the Experience Designer as shown in the screenshot below.

...

When execution reaches a Flow Studio Flow's Custom control, Orbita directs the response to the 3rd pin of the Flow Manager node in Experience Designer. (See Flow Manager Node documentation for more information.)

When you drag the Custom control to the Flow Studio canvas, you can see a name field and the control's ID. In Experience Designer, developers can write code that executes when the Custom control is reached.

...

You can also configure your logic for a Custom Control based on its Name.

A Hook event lets you use the name of the Custom Control (in the Flow studio) to call whichever function is registered with that name in Experience Designer.

You can use the Hook events if you have reusable functions in your conversation flow.

To configure Custom Control Name for hook data

  1. In Experience Designer, design a flow as shown.

    Image Added

  2. The Hook-Data function node contains the below code

...

  1. to enable the hook to fire the custom logic based on the Custom Control Name.

    Code Block
    try {
        const _ = global.get('lodash');
            controlId = msg.payload.session.attributes.orbitaSession.flowInfo.controlId,
            controlName = msg.payload.session.attributes.orbitaSession.flowInfo.controlName,
            hookName = controlName.indexOf(":") > - 1 ? controlName.substr(0, controlName.indexOf(":")) : controlName,
            args =

...

  1.  controlName.indexOf(":") > -1 ?
                

...

  1. [msg,
              

...

  1.  

...

  1.  

...

  1.  ...controlName.substr(controlName.indexOf(":") + 1).split("|")
                   

...

  1.  .

...

  1. map(arg =

...

  1. > arg.trim())
                    

...

  1. .filter(arg => !!

...

  1. arg)
                 

...

  1.    .map(arg => arg === "null" ? null 

...

  1. : 

...

  1. arg)] :
    

...

  1.             [msg];
     

...

  1.    msg.payload.externalHook = {
            data: hookName
        }
    

...

  1.  

...

  1.    if (hookName) {
           

...

  1.  const hook = 

...

  1. global.get("hooks")[hookName];
    
            

...

  1. msg.hookResult

...

  1.  = 

...

  1. {
        

...

  1.  

...

  1.  

...

  1.  

...

  1.      hookFound: !!hook
            };
          

...

  1.  

...

  1.  

...

  1. 
    

...

  1.  

...

  1.        
            if (hook) {
       

...

  1.  

...

  1.         

...

  1. hook.apply(null, args);
            } else {
                msg.hookResult.executionSuccess = false;
                msg.hookResult.error = `Could not 

...

  1. find hook 

...

  1. '${

...

  1. hookName}'`;
            
                node.warn(`Could not 

...

  1. find hook 

...

  1. '${

...

  1. hookName}'`);
            
                return msg;
            }
        }
        
    } catch (error) {
        msg.hookResult.executionSuccess = false;
        msg.hookResult.error = error;
        
        node.warn(`Error executing hook`);
        node.

...

  1. error(error);
        
        return msg;
    }

  2. To set up the Hook Events, you need to initialize the hooks. The Settings / Hooks Initialize function node is used to register the hook condition so that the Hook-Data function knows what to do with it.

    Code Block
    const settings = global.get("settings") || {};
    settings.emptyString = '';
    global.set("settings", settings);
    
    const hooks = global.get("hooks");
    global.set("hooks", hooks || {}

...

  1. );
    
    return msg;

  2. You will register your Hook Event with an Inject node. All the Inject nodes in this flow have the same configuration.

    Image Added

  3. When the Custom control named HTMLDirective gets called in Flow studio, the function node named HTML form Hook will be called.

    Image Added

    Code Block
    global.get("hooks").HTMLDirective = msg => {
        node.send(msg);
    };

  4. The next function node calls the HTML form and it is subsequently connected back to the Flow Manager node to continue the conversation flow.

Related Articles

Filter by label (Content by label)
showLabelsfalse
max5
showSpacefalse
cqllabel in ( "flow-studio" , "experience-designer" )