Running
npm install
npm start
- Project will be running on
http://localhost:3002
WebView
Control BLiP Chat's webview from your web page. You may need to have some control over BLiP Chat's webview once you have added it to your web page. This script extension allows you to that.
Usage
NPM
Simply install the blip-chat-extension package from the npm registry.
$ npm install blip-chat-extension
Now you just have to import the package and use it:
var blipCards = ; { window { var WebView = } };
Script Import
To import the script just copy and paste the following code:
<script src="https://unpkg.com/blip-chat-extension@1.0.0" type="text/javascript"></script><script> { window { var WebView = } };</script>
You should create an instance of BlipChatExtension
and operate on it.
Closing the WebView
You may need to close BLiP Chat's webview after an event or transaction has finished. To close the webview use the method closeWebView
from the instanced object.
var WebView = WebView
Sending a message to the chatbot
If the chatbot's conversation state has stopped and you need to update that state (after some interaction with your web page, for example) use the method sendMessage
to send a message to the chatbot.
var WebView = // Sending a simple text messageWebView// Sending a media link message WebView
You can send any document supported on blip. To see more go to BLiP Help Center.
If you need to send a complex message, you can send an object with the properties payload
and preview
. They are used to specify what is sent to chatbot and what is shown to user respectively.
Examples
Should you need to send your location to the chatbot but only a simple text like I'm here
is to be shown to the user, you can do it as follows:
var WebView = // Sending Location card to chatbot and showing a text message to userWebView
Or maybe you have some content to be trafficked that the user should not see. For that you should send the object keeping the payload
but omitting the preview
property.
var WebView = // Sending a message to the chatbot that the user will not see it's contentWebView
Override Webview's Close Method
With the method overrideOnClose
you can, for example, guarantee that a form is submitted before the user closes the webview. The function to be executed when the user tries to close the webview is passed as a parameter to the method:
var WebView = WebView
The overrideOnClose
method has a return that determines whether the webview should be closed or not . By returning true
the webview's closing method will proceed normally and by returning false
it will be blocked.
var WebView = WebView
Methods
Methods | Description | Parameters |
---|---|---|
closeWebView | Close the webview | None |
sendMessage | Send a message to bot in name of the user | string or { preview: {}, payload: {} } |
overrideOnClose | Override webview's default close function | function |