- Chat Widget API
Callback function invoked when widget code is loaded but chat window is not rendered yet.
You can return false to stop the widget initialization.
window.BE_API=window.BE_API||{};window.BE_API.onBeforeLoad=function(){// return false};Callback function invoked when widget code is loaded and chat window is rendered.
window.BE_API=window.BE_API||{};window.BE_API.onLoad=function(){// ...};Callback function invoked after destroy() API method call.
window.BE_API=window.BE_API||{};window.BE_API.onDestroy=function(){// ...};Callback function invoked after resetSession() API method call.
window.BE_API=window.BE_API||{};window.BE_API.onSessionReset=function(){// ...};Callback function invoked when the chat window is opened.
window.BE_API=window.BE_API||{};window.BE_API.onChatWindowOpen=function(){// ...};Callback function invoked when the chat window is closed.
window.BE_API=window.BE_API||{};window.BE_API.onChatWindowClose=function(){// ...};Callback function invoked when the chat window is hidden.
window.BE_API=window.BE_API||{};window.BE_API.onChatWindowHide=function(){// ...};Callback function invoked after query result.
window.BE_API=window.BE_API||{};window.BE_API.onMessage=function(result){console.log(result)};Callback function invoked after the conversation starts.
window.BE_API=window.BE_API||{};window.BE_API.onConversationStart=function(){// ...};Callback function invoked after the conversation ends.
window.BE_API=window.BE_API||{};window.BE_API.onConversationEnd=function(){// ...};Callback function invoked after the moment window is opened.
window.BE_API=window.BE_API||{};window.BE_API.onMomentOpen=function(){// ...};Callback function invoked after the moment window is closed.
window.BE_API=window.BE_API||{};window.BE_API.onMomentClose=function(){// ...};Callback function invoked after the moment window is loaded.
window.BE_API=window.BE_API||{};window.BE_API.onMomentLoad=function(){// ...};Create chat widget if does not exist
window.BE_API=window.BE_API||{};window.BE_API.onLoad=function(){window.BE_API.create();};Destroy chat widget if exist
window.BE_API=window.BE_API||{};window.BE_API.onLoad=function(){window.BE_API.destroy();};Open the chat window, should be used only inside window.BE_API.onLoad callback
window.BE_API=window.BE_API||{};window.BE_API.onLoad=function(){window.BE_API.openChatWindow();};Close the chat window, should be used only inside window.BE_API.onLoad callback
window.BE_API=window.BE_API||{};window.BE_API.onLoad=function(){window.BE_API.closeChatWindow();};Hide the chat window, should be used only inside window.BE_API.onLoad callback
window.BE_API=window.BE_API||{};window.BE_API.onLoad=function(){window.BE_API.hideChatWindow();};Should be used only inside window.BE_API.onLoad callback.
Returns true if the chat window is open.
window.BE_API=window.BE_API||{};window.BE_API.onLoad=function(){window.BE_API.isChatWindowOpened();};Should be used only inside window.BE_API.onLoad callback.
Returns true if the chat window is closed.
window.BE_API=window.BE_API||{};window.BE_API.onLoad=function(){window.BE_API.isChatWindowClosed();};isChatWindowHidden
Should be used only inside window.BE_API.onLoad callback.
Returns true if the chat window is hidden.
window.BE_API=window.BE_API||{};window.BE_API.onLoad=function(){window.BE_API.isChatWindowHidden();};Returns true if the chat is initialized.
window.BE_API=window.BE_API||{};window.BE_API.onLoad=function(){window.BE_API.isInitialized();};Reset current session and recreate widget.
window.BE_API=window.BE_API||{};window.BE_API.onLoad=function(){window.BE_API.resetSession();};Send a message as visitor.
| parameter | type | description |
|---|---|---|
payload.message | String(1, 256) required | Message |
payload.postback | String(1, 256) | Postback |
window.BE_API=window.BE_API||{};window.BE_API.onLoad=()=>{window.BE_API.sendMessage({message: 'message',postback: 'postback'})}Only available for old builder scenarios.
Trigger the specific interaction.
| parameter | type | description |
|---|---|---|
payload | String(1, 50) required | Trigger name |
window.BE_API=window.BE_API||{};window.BE_API.onLoad=()=>{window.BE_API.sendTrigger('custom_trigger')}Open moment.
| parameter | type | description |
|---|---|---|
payload.url | String(1, 2048) required | Url |
payload.height | String(full, tall, compact) | Height |
window.BE_API=window.BE_API||{};window.BE_API.onLoad=()=>{window.BE_API.openMoment({url: 'https://exampledomain.com',height: 'tall'})}Closes opened "moment"
Set your custom attributes that will be sent to the query. Each method call will overwrite existing parameters. Read more about attributes here: https://www.chatbot.com/docs/talk-with-bot/#parameters
| parameter | type | description |
|---|---|---|
Object | Object( Entry Object(1, 99) ) required | Object with entries |
| parameter | type | description |
|---|---|---|
key | String(1, 128) | Attribute name |
value | String(1, 1024) | Attribute value |
window.BE_API=window.BE_API||{};window.BE_API.onLoad=()=>{window.BE_API.setSessionAttributes({email: 'support@chatbot.com',name: 'ChatBot Support'})}Set user attributes. Read more about user attributes here:
https://www.chatbot.com/docs/users#update-user
| parameter | type | description |
|---|---|---|
Object | Object( Entry Object(1, 99) ) required | Object with entries |
| parameter | type | description |
|---|---|---|
key | String(1, 128) | Attribute name |
value | String(1, 1024) | Attribute value |
window.BE_API=window.BE_API||{};window.BE_API.onLoad=()=>{window.BE_API.setUserAttributes({email: 'support@chatbot.com',name: 'ChatBot Support'})}Returns the data of the current user.
Ends an active conversation.
Hides active greeting
Shows greeting.
| parameter | type | description |
|---|---|---|
message | String(1, 256) required | Greeting message |
window.BE_API=window.BE_API||{};window.BE_API.onLoad=()=>{window.BE_API.showGreeting('Greeting message')}