/openchatbot-webclient

WebChat to be embedded in a web page for communicating to an open ChatBot compatible bot

Primary LanguageCSSApache License 2.0Apache-2.0

WebChat Client for Open ChatBot compatible bots

openchatbot-client is a webchat box compatible with Open ChatBot format created by Alliance For Open ChatBot.

WebChat box

Setup

1 - Define your Open ChatBot API EndPoint in script/appocb.js (line 21), example:

    let apiEndPoint = "https://openchatbot.io/api/v1.0/ask"

2 - Set the path of this webclient on your webpage in sripts/importocb.js (line 21), example:

    let webClientURL = 'https:\/\/metaboto.com/openchatbot-webclient\/'

3 - Import your the chatbox by adding the url of appocb.js at the bottom of your webpage (just before the </body> tag):

<script src="scripts/appocb.js" async></script>

This could be the full URL path.

Important note

Because of the use of ajax for getting content from API Endpoint, Open ChatBot json format result should be embedded within a function. So the recommended architecture is to have a proxy website between your ChatBox and the formal open Chatbot API so that content returned to the ChatBox is embedded within a function.

The ChatBox expected embedding function name is parseocbAnswer

So ChatBox would call your website proxy API with a callback parameter giving the function name like so:

curl "https://metaboto.com/api/metaboto/rest/v2.0/ask?userId=2371aeb8-58d2-41bc-8382-1a205b0cbd2d&query=%40doungdoung%20hello&callback=parseocbAnswer"

And response would look’s like:

parseocbAnswer({"meta": {"authors": ["Olivier HO-A-CHUCK"], "botName": "OpenChatBot MetaBoto", "copyright": "Copyright 2020 metaboto.com", "version": "3.9"}, "response": {"query": "@doungdoung hello", "text": "I'm DoungDoung bot. Your query is\"hello\".", "timestamp": 1604170101.301502, "userId": "2371aeb8-58d2-41bc-8382-1a205b0cbd2d"}, "status": {"code": 200, "message": "success"}})

Demo

You can test this box on metaboto.com.

Call any ChatBot compatible Open ChatBot that have declared their API enpoint using DomainBots standard.

For instance, test "@doungdoung hello", or "@openchatbot what time is it". Both sites have referenced their bots on their domain name.