The KB Lab Bot has been set up with two components: 1) the Chatbot Builder and 2) A Webhook.
The Chatbot Builder is an open source Content Management System that we built and runs on our server. It allows you to build dialogs with the users of the bot. For instructions on how to install the Chatbot Builder on your own server & how to build dialogs, please see below.
The Chatbot Builder already allows you to build a proper bot that can be used to create a Facebook Messenger or chatbots in other platforms such as your own website. However, if you want your users to be able to request information that is located elsewhere, you will need to build a webhook. A webhook allows you to give custom callbacks on your website or in this case by a bot. Facebook has extensive documentation on how to set-up your own webhook, see this page. We built our own webhook that is connected to the website ‘Geheugen van Nederland’ [Memory of the Netherlands].
How to build your own chatbot using our code
To build your own chatBot we made an open source Content Management System, called the Chatbot Builder. When building this, we were inspired by other chatbot tools such as chatfuel. This code can be used to build a Facebook Messenger bot but is applicable to all sorts of platforms. You could e.g. modify it to build an embedded chatbot widget within your own website. We published our code and documentation on how to install the Chatbot Builder on your computer at Github: https://github.com/KBNLresearch/chatbot-builder-nl. Please note all instructions on the Github page are in Dutch. We are working on an English translation.
How to configure your dialog in the Chatbot Builder
Once you installed the Chatbot Builder on your computer or server, you are ready to start building your own dialogs. Depending on your set-up you will need to log in either in mock modus or with your Facebook account. Once you’re in, you will see the following features:
- Chatbot testen - Open Emulator: this is a built-in Emulator allowing you to test your dialogs
- Welkomstboodschap - Instellen: With this feature you can set up a Welcome message
- Dialogen: This allows you to build the dialogs your bot will have with its users. Please find more info on how to set-up these dialogs below.
- Import/Export: This allows you to import or export the dialogs you built. Once you export your dialogs, you will download your datamodel as JSON. You can validate the export by using e.g. https://jsonlint.com/
The most important feature of the Chatbot Builder is building dialogs. You can do this by following these steps:
- Click on ‘Voeg een dialoog toe’ [‘Add a dialog’]
- Type in what your user might say to the chatbot and click on ‘Voeg een dialoog toe’ [Add a dialog].
- In the next screen, on top you will see the words you typed in. When the words have a blue background, this means the Chatbot Builder will use some Natural Language Processing techniques to recognize the words. When you programmed your bot to e.g. recognize the word ‘Goedendag’ [Goodday], the NLP add-on makes sure the bot also recognizes typos in the word or derived words such as ‘Goedemorgen’ [Good morning] or ‘Goedenmiddag’ [Good afternoon]. For this feature, we used Clips. If you do not want the Chatbot Builder to use this feature, please click on the word and the background will turn into red.
- The next step is adding a reply of the bot. Please click on ‘Voeg een antwoord toe’ [Add a reply].
- You can then choose six types of replies the bot can send: Tekst [Text], Knoppen [Buttons], URL, Webhook, Afbeelding [Image] or Aan het typen [Typing]. Please select one and then the ‘Vertraging ‘ [time of delay]. Since a bot mimics human behaviour, we advise you not to send the answer straight away but build in some time before the answer will be shown. Depending on the type of answer you chose, you can add the answer the bot should give.
If you now want to test whether the bot functions properly, please click on the ‘Open emulator’ button at the left. You can then type in the words that should trigger the dialog and check whether it functions properly.
For a quick overview on how to set-up dialogs, please see this short gif:
How to configure Facebook to start using your bot
The next step is to get your bot up and running. To do this, you will first need a Facebook Developers account which you can set up at https://developers.facebook.com/. You can then add a new app. Once you are in your app dashboard, please add two products on the bottom of the navigation bar: 1) Messenger, and 2) Webhooks.
The following steps can be found at the Facebook documentation section that offers extensive documentation on how to get your bot activated: https://developers.facebook.com/docs/messenger-platform/getting-started
How to bring users to your bot
We have been puzzling quite a while on the entry point to our bot. The Facebook Documentation gives some good advice on entry points and we closely looked at the bots of Dutch Media outlets such as NOS Update & NRC Update. We decided to follow their approach by setting up a dedicated Facebook Page for the KB Lab Bot: https://www.facebook.com/KBLabBot/ This allowed us to set up and test our bot via the ‘Send Messages’ button. Please note that before you go live you will need to have your bot reviewed by Facebook via your Developers account. The review process might take a couple of working days. In our case, the bot was approved within 1 day.