Git Product home page Git Product logo

chat-widget's Introduction

Chat Widget API

Hooks

onBeforeLoad

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
};

onLoad

Callback function invoked when widget code is loaded and chat window is rendered.

window.BE_API = window.BE_API || {};

window.BE_API.onLoad = function () {
    // ...
};

onCreate

Callback function invoked after create() API method call.

window.BE_API = window.BE_API || {};

window.BE_API.onCreate = function () {
    // ...
};

onDestroy

Callback function invoked after destroy() API method call.

window.BE_API = window.BE_API || {};

window.BE_API.onDestroy = function () {
    // ...
};

onChatWindowOpen

Callback function invoked when the chat window is opened.

window.BE_API = window.BE_API || {};

window.BE_API.onChatWindowOpen = function () {
    // ...
};

onChatWindowClose

Callback function invoked when the chat window is closed.

window.BE_API = window.BE_API || {};

window.BE_API.onChatWindowClose = function () {
    // ...
};

onChatWindowHide

Callback function invoked when the chat window is hidden.

window.BE_API = window.BE_API || {};

window.BE_API.onChatWindowHide = function () {
    // ...
};

onMessage

Callback function invoked after query result.

window.BE_API = window.BE_API || {};

window.BE_API.onMessage = function (result) {
    console.log(result)
};

onStartConversation

Callback function invoked after the conversation starts.

window.BE_API = window.BE_API || {};

window.BE_API.onStartConversation = function () {
    // ...
};

Methods

create

Create chat widget if does not exist

window.BE_API = window.BE_API || {};

window.BE_API.onLoad = function () {
    window.BE_API.create();
};

destroy

Destroy chat widget if exist

window.BE_API = window.BE_API || {};

window.BE_API.onLoad = function () {
    window.BE_API.destroy();
};

isInitialized

Returns true if the chat is initialized.

window.BE_API = window.BE_API || {};

window.BE_API.onLoad = function () {
    window.BE_API.isInitialized();
};

resetSession

Reset current session and recreate widget.

window.BE_API = window.BE_API || {};

window.BE_API.onLoad = function () {
    window.BE_API.resetSession();
};

openChat

Deprecated, use: openChatWindow

openChatWindow

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();
};

closeChat

Deprecated, use: closeChatWindow

closeChatWindow

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();
};

hideChatWindow

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();
};

isChatWindowOpened

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();
};

isChatWindowClosed

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();
};

setUserParameters

Deprecated, use: setUserAttributes

setUserAttributes

Set user attributes. Read more about user attributes here:

https://www.chatbot.com/docs/users#update-user

Payload

parameter type description
Object Object( Entry Object(1, 99) ) required Object with entries

Entry Object

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: '[email protected]',
        name: 'Botengine Support'
    })
}

setCustomParameters

Deprecated, use: setSessionAttributes

setSessionAttributes

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.botengine.ai/docs/talk-with-bot#parameters

Payload

parameter type description
Object Object( Entry Object(1, 99) ) required Object with entries

Entry Object

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: '[email protected]',
        name: 'Botengine Support'
    })
}

sendMessage

Send a message as visitor.

Payload
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'
    })
}

sendTrigger

Trigger the specific interaction.

Payload

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')
}

chat-widget's People

Contributors

dzabrzenski avatar hstaniszewski avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.