WebRTC Kite Chatbot SDK
Jun 21, 2021 00:15
This document explains how to install WebRTC Kite Chatbot
Created: February 2021
Min. WMS version: WMS 5.02
Wildix WebRTC Kite bot SDK is a sample bot. Web developers can work on it to customize it to different scenarios.
The current implementation can be used out of the box for the following use cases:
- Provide an automated response to external WebRTC Kite users in case no agent is available during working hours (e.g. "All agents are busy at the moment, please try again later")
- Provide an automated response to external WebRTC Kite uses in case they contacted the call group outside of the working hours (e.g. "Our offices are closed, please try again during the working hours: Monday through Friday from 9 AM till 6 PM").
Web developers can extend the behavior of the bot to use it in more complicated scenarios, for example, provide predefined options to the WebRTC Kite users from which they can choose, etc.
Web developers can find all the necessary information here: https://github.com/Wildix/kite-xmpp-bot
This document explains the expected behavior and use cases of the basic implementation (out of the box) and the information on how to install the SDK.
The sample bot has the following behavior:
- A new user is created on the PBX (Business license required); this user acts as a chatbot
- The chatbot user can be added to one or more call groups
- In case no agent replies within the specified timeout (1 minute by default) during working hours, the chatbot provides a certain predefined response; in case no agent replies within the same timeout during non-working hours, the chatbot provides a different predefined response
- It's possible to modify the static files in the SDK directory to specify the working hours/ non-working hours and the response messages from the chatbot
- WMS version: starting from WMS 5.02.20210127
- Business license or higher (assigned to the chatbox user)
- Last stable version of Node.js
- Create a new user for the chatbot with extension 777999 (by default) and assign it a Business license.
- Add this user to one or more call groups used for WebRTC Kite
- Download (and unzip) the SDK from https://github.com/Wildix/kite-xmpp-bot
Run the following command from the Terminal/ Command Prompt to install all the required libraries in the file:
Edit config parameters in the file wbot/app/config.js:
- domain: change to the PBX domain
- xmppService: change service parameter to the PBX domain, e.g. 'xmpp://elenacloud.wildin.com:443'
- username and password: change to your chatbox user's extension and web password (by default the chatbox extension is 777999)
Run the bot using the command:
Customize the behavior of the chatbox
To customize the behavior of the chatbot, you need to work on the following files in the SDK:
- To change predefined responses, edit the *.txt files located in app/responders/staticfiles
- To edit the working hours and create interactive responses, edit the file responder.js located in the same directory (basic JS knowledge is required)
Responder public methods (app/responders/responder.js):
hello(id, userdata): if this method returns a string, it is used as bot welcome message for user
- id: string representation of Kite user JID (e.g. "email@example.com)
- user data: object, represents a new connection from a WebRTC Kite user; has two fields: name and email
- say(id, message): if this method returns a string, it is used as bot answer
Below you can find an example of chatbox behavior customization.
During working hours, the chatbot should propose options: "Dear username, type "events" to learn about our upcoming events, or type "address" to get our physical address". In case the user types "events", the bot should reply with the list of upcoming events. In case the user types "address", the bot should send the physical address. In case the user types something else, the bot should respond "Sorry, I did not understand you".
- Modify the content of the file workinghours.txt located in app/responders/staticfiles (e.g.: Type "events" for the information about upcoming events. Type "address" to know our physical address.)
- Add the needed static *.txt files to app/responders/staticfiles. These files will be used as responses in case user types "events" or "address" (e.g. events.txt: Here are our upcoming events: Summit 2022; address.txt: Our address is...)
- Add address and events with the path to these newly created files to the config.js file located in the app directory
- Modify the responder.js file located in the same directory. To realize the scenario described above you need to work on the "say(id, message)" method. Here is an example of the modified file: