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 invoking login intent will enable the login directive in 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.
...
Create Intents
You can create intents from the Project Side navigation menu > Create > Intent Library.
...
In this example, we have used two intents Login and Loginsuccess.
Login Intent
In this example, the Login intent is used to invoke the Login Directive.
...
Loginsuccess Intent
In this example, the Loginsuccess intent is triggered after the user logs in successfully.
...
This intent should contain success as one of its utterances.
Experience Designer
In the Experience Designer, design a flow as shown below.
...
Use the below code in a the function node to enable use the login directive as shown below.
...
Code Block |
---|
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.
Code Block |
---|
msg.payload.orbita.session.isLoginstate = true;"Login" return msg; |
...
Customizing the login button
How to get inline login
You can make use of the HTML directive and load the Login page within the Chat bubble. to get inline login in the Chatbot. See, HTML Directive
...
You should know the login page URL of the login page for your instance.
The easiest way to get the URL is to use Use the login directive and copy click the login button. Copy the URL of the login tab (this will be opened opens in a new tab) when you click the login button.and place it in the URL property in the code below.
Place this sample code in a function node and connect it as shown in the screenshot.
...
Sample code
Code Block |
---|
if(!msg.payload.orbita) { msg.payload.orbita = {}; } if(!msg.payload.orbita.directive) { msg.payload.orbita.directive = []; } msg.payload.orbita.directive = [{ type: "html5", options: { template: '500x600450x500', 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=*****<Login page URL of your Instance>" }, loginSuccessUtterance: 'success' }] msg.payload.orbita.state = "Login" return msg; |
You can use successUtterance: 'Intent_Namesuccess'
or loginSuccessUtterance: 'Intent_Namesuccess',
to invoke the Intent after the HTML content (Login page) is rendered.
Attachments | ||||||||
---|---|---|---|---|---|---|---|---|
|
Related articles
Filter by label (Content by label) | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...