Skip to main content

Chat Bot Script

Embed the below script into your website to get the chat widget. Also, include the chat bot script dependency jquery library in your site head tag.

<script src="https://code.jquery.com/jquery-3.4.1.min.js"> </script>

Widget Script

<script>
if (!sessionStorage.userId) {
sessionStorage.userId = new Date().getTime();
}

window.a8bot = {
appConfig: {
isFloatingIcon: true,
showAfterInterval: "icon",
/*"icon" || "chat" || "notify"*/
notifyText: "",
initTime: 1000,
/*ms*/
sessionDuration: "1 day"
/*"1 year" || "2 months" || "4 days" || "6 hours" || "8 minutes"*/
},
cusInfo: {
appKey: "<AppKey>",
displayName: "<UserName>",
orgId: "<OrgID>",
botHandle: "<BotHandle>",
userId: "<UserID>",
email: "<EmailID>"
}
};

var script = document.createElement("script");
script.type = "text/javascript";
script.id = "a8_chat_widget";
script.src = "<HostedURL>";

document.body.appendChild(script);
</script>

In the above script, replace the following fields wherever necessary.

  • AppKey
  • UserName
  • OrgID
  • BotHandle
  • UserID
  • EmailID
  • HostedURL

isFloatingIcon

This to decide whether the chat icon should be dragable or not. If it is true you can drag, if it is false then you can't drag.

showAfterInterval

This to decide what we want on chat initiation.

icon

Chat icon will be loaded without notification.

chat

Chat widget will be opened directly.

notify

If notify is given, chat icon will be loaded with the notification. We can add a text in notifyText. That text will be displayed in the notification bubble.

initTime

The duration to load chat icon after the site has been opened.

sessionDuration

This is to decide the duration of a chat conversation in the widget. Default session duration is 15 minutes. We can change the session duration as per client's requirement.

Format of session duration: "1 year" or "2 months" or "4 days" or "6 hours" or "8 minutes"

appKey

Corresponding bot's app key.

displayName

The user name to be displayed in the chat.

orgId

Corresponding bot's organisation id.

botHandle

Corresponding bot's bot handle name.

userId

For the User ID of a particular client's users, we can use either sessionStorage.userId or localStorage.userId. If a same chat is opened in multiple tabs of a single browser, then localStorage.userId local will create a same chat session in all the tabs and sessionStorage.userId will create an unique chat session of that particular chat in each tab of the same browser.

This is possible only in cases where that user Ids are provided by us.

email

Email ID of the particular client's users.

HostedURL

Chat hosted url for loading the chat widget.

Logger

Logger feature is implemented in chat widget. Logger levels are error | debug | verbose. Default logger level is error.

If you want to change the logger level on run time. Open the browser console and set localStorage.loggerLevel = debug. Refresh the browser tab and the logs will appear on the console.

Log Levels

error is high level logs.

debug is mid level logs.

verbose is low level logs.