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 6 Next »

The login directive enables the admin users to add a login button to your chatbot flow. The button click redirects the user to 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;

Render Login page in the chat bubble

You can make use of the HTML directive and load the Login page within the Chat bubble.

You should know the URL of the login page for your instance.

The easiest way to get the URL is to use the login directive and copy the URL of the login tab (this will be opened in a new tab) when you click the login button.

Sample code

msg.payload.orbita.directive = [{
    type: "html5",
    options: {
        template: '500x600',
        url :"https://environment.orbita.cloud:8443/oauth/login?response_type=code&redirect_uri=https://environment.orbita.cloud:8443/oeapi/bot/support&scope=personaldata&client_id=*****"
    },
    loginSuccessUtterance: 'success'
}]

The loginSuccessUtterance: 'Intent_Name', will invoke the Intent when you click on the Sign-In button.

  File Modified
  • No labels