Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

The login directive enables the admin users to add a login button to your chatbot flow. The button click redirects the user to the Orbita’s user login page in a new tab. If the user successfully logs in, the login tab closes automatically.

In the below example, we will use the flow studio and prompt the user to login to continue chatting with the chatbot.

Flow studio

We will create a flow studio flow and add a custom control followed by a single input node at the beginning of the flow (as shown below) to prompt the user to login.

Then we add an Evaluate node to check if the user logged in successfully.
If true, the flow continues
If anything else, the flow ends with an authentication error message.

Experience Designer

Use the below code in a function node to enable the login directive as shown below.

if(!msg.payload.orbita) {
msg.payload.orbita = {};
}
if(!msg.payload.orbita.directive) {
msg.payload.orbita.directive = [];
}
msg.payload.orbita.directive.push({
    type: 'login', 
    successUtterance: 'success', 
    html: `<button class="smrtBtn chattheme chatthemeborderbuttons">Login</button>`
})
msg.payload.logoutUrls = [{
    'type': 'window', 
    url:'http://localhost:3030/oauth/logout?'
}]; 

return msg;

You have to set a session variable to know if a user successfully logged in. Use the below code in the function node.

msg.orbita.session.isLogin = true;
return msg;
  File Modified
  • No labels