How to use Login Directive

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, invoking Login intent will trigger the Login Directive in the chatbot.

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.

The Loginsuccess 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 the function node to use the login directive.

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="loginButton">Login</button>` }) msg.payload.orbita.state = "Login" return msg;

Customizing the login button

You can customize the login button by using CSS to style it.

Go to the Bot Manager flow > Bot View template Node > Custom CSS tab, and place the below code.

.loginButton { border: none; color: white; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; margin: 4px 2px; cursor: pointer; background-color: #4CAF50; }

Ensure the class name loginButton matches the one used in the Login Directive code for the login button.

How to get Inline login

You can make use of the HTML directive to get Inline login in the Chatbot. See, HTML Directive

For the inline login, you should note the login page URL of your instance.

To get the login page URL of your instance, use the Login Directive and click the Login button. Copy the URL of the login tab (opens in a new tab) 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

if(!msg.payload.orbita) { msg.payload.orbita = {}; } if(!msg.payload.orbita.directive) { msg.payload.orbita.directive = []; } msg.payload.orbita.directive = [{ type: "html5", options: { template: '450x500', url :"<Login page URL of your Instance>" }, loginSuccessUtterance: 'success' }] msg.payload.orbita.state = "Login" return msg;

You should use the loginSuccessUtterance: 'success', to invoke the Loginsuccess Intent after the HTML content (Login page) is rendered.

The line msg.payload.orbita.state = "Login" is optional.

If you choose not to use state, you should remove the state in the Loginsuccess Intent. See, How do I use state?

The Login Directive and the Inline Login are combined in a single flow in the below attachment.

  File Modified

File Login_Directive.json

Mar 11, 2021 by Rajkiran Alla

Related articles

Â