<script src="https://blitsproduction.z6.web.core.windows.net/chat/production/latest/bundle.js"></script>
Once the script loads, you will have access to the Blits external chat via the function: window.BlitsBotChat
.
data.window.BlitsBotChat.init({
botId: "YOURBOTID",
code: "YOURSNIPPETCODE",
userId: "YOURUSERID"
})
The userId is optional.
window.BlitsBotChat.render({
botId: "YOURBOTID",
code: "YOURSNIPPETCODE",
userId: "YOURUSERID"
},
document.getElementById("CHATELEMENTID"))
window.BlitsBotChat.getDirectLine()
window.BlitsBotChat.open()
window.BlitsBotChat.close()
If you want to get rid of the chat, use the destroy function.Window.BlitsBotChat.destroy()
window.BlitsBotChat.init({
dlToken: "YOURDIRECTLINE_TOKEN"
})
If you want to use predefined settings, you can pass them under settings.
window.BlitsBotChat.init({
settings: { YOUR_SETTINGS }
})
Here is a list of the settings:
title: string;
avatar: string;
bubbleIcon: string;
defaultChatScreen: 'small' | 'big'
position: 'top-left' | 'top-center' | 'top-right' | 'center-center' | 'bottom-left' | 'bottom-center' | 'bottom-right'
startOpened: boolean;
isMainColor: boolean;
mainColor: string;
isMainTextColor: boolean;
mainTextColor: string;
hasPopupMessages: boolean;
popupMessages: {
message: string;
delay: number; // in seconds
}[];
hasButton: boolean;
closeWithoutButton: boolean;
hasUploadButton: boolean;
hasMicButton: boolean;
hasPoweredBy: boolean;
You also have the ability to run multiple chat instances at the same time. You just need to pass in an id for each instance. If you don’t provide an id, it defaults to and empty string "".
window.BlitsBotChat.init({
dlToken: "YOURDIRECTLINE_TOKEN"
})
window.BlitsBotChat.render({
id: "second",
botId: "YOURBOTID",
code: "YOURSNIPPETCODE"
})
window.BlitsBotChat.init({
id: "third",
botId: "YOURBOTID",
code: "YOURSNIPPETCODE"
})
When calling the other functions (getDirectLine, destroy, etc.), you will have to provide an id to target a specific chat instance. If you don’t provide an id, it defaults to an empty string "".
window.BlitsBotChat.getDirectLine("second")
window.BlitsBotChat.open() // Opens the chat without id (the first one)
window.BlitsBotChat.open("third") // Opens the chat with id "third"
If you want to use the test version of your flows, you need to pass in useStagingVersion and set it to true.
window.BlitsBotChat.init({
useStagingVersion: true
})
If you want to start/test a subflow function, you can pass in the subflow name under flowName.
window.BlitsBotChat.init({ flowName: "YOURSUBFLOWNAME" })