Chatbot and Artificial Intelligence

Introduction

The Integria IMS chatbot is made up of two services: a conversation or chat server (with its WEB client) and a conversational artificial intelligence engine (optional). The artificial intelligence engine can be used to learn from the information entered into the Integria IMS knowledge base to provide quick answers to user questions.

It allows three operating modes:

  • Automatic: It uses machine learning models to automatically provide feedback to the user based on prior learning.
  • Manual : An Integria IMS operator responds to the user through the chat interface.
  • Mixed: Integria IMS assists the operator by showing possible answers to the user's questions.

The architecture consists of three fundamental elements:

  • The chat client, with which the user interacts.
  • The chat server, with which the operator interacts.
  • The prediction engine, which offers answers for the user's questions.

Both the client and the chat server are part of an Integria IMS Enterprise installation. To add predictive capabilities to Hybrid Helpdesk install and activate the Prediction Engine as described in the following sections.

Chat server installation

By default it is installed when using the cloud installation method. To activate it, go to Chat, Setup option and activate it:

Note that you must configure the URL of the webservice with the public URL of your Integria IMS installation, as it is configured in the main section of the Setup:If when you access Setup, you activate it and it does not work, reproduce the Node installation steps in your Setup:

curl -SsL http://firefly.artica.es/projects/integria/integria_deploy_enterprise.sh | sh
curl -sL https://rpm.nodesource.com/setup_12.x | sh
yum install -y nodejs
npm i -g pm2
cd /var/www/html/integria/extras/chat_server
npm update
pm2 start server.js

To leave the service running when the machine restarts, edit the file:

/etc/systemd/system/integria-chat.service

And add the following content:

[Unit]
Description=Integria-Chat-Server
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/node server
Restart=always
# Consider creating a dedicated user for Wiki.js here:
User=root
Environment=NODE_ENV=production
WorkingDirectory=/var/www/html/integria/extras/chat_server
[Install]
WantedBy=multi-user.target

Then run these commands:

systemctl daemon-reload
systemctl start integria-chat.service
systemctl enable integria-chat

Configure access to the chat server database.

Edit the file:

/var/www/html/integria/extras/chat_server/config/config.js

And modify the necessary parameters of the database:

Install the artificial intelligence engine

Run the following commands as root (super user) on your Integria IMS installation:

yum install python3 python36-Cython
wget http://xxxxxx/prediction_engine-latest.tgz
tar xvzf prediction_engine-latest.tgz
cd prediction_engine
./install.sh
service prediction_engine.service restart

This will activate the service on port 6000/tcp.

AI settings

AI is configured separately on each channel. To do this, go to SupportChatChannel Management and edit the configuration of a channel:

  • IA url: URL where the the artificial intelligence engine listens to the webservice. It must be in format
HTTP://DIR_IP
  • IA Port: By default 6000. You shouldn't change it unless you've had to do a port forward somewhere in between.
  • AI mode:

It allows three operating modes:

  • Automatic: It uses machine learning models to automatically provide feedback to the user based on prior learning.
  • Manual: An Integria IMS operator responds to the user through the chat interface.
  • Mixed: Integria IMS assists the operator by showing possible answers to the user's questions.
  • Initial response time: Seconds in which the AI will answer the first user request.
  • Response time between conversations: Response time between question and question once the conversation has started.
  • Progress bar timeout: Time that the system will allow the operator to choose an answer from those provided before automatically answering the best option.
  • Certainly threshold: Degree of uncertainty supported by the AI when choosing an option from those offered. The value must be between 0 and 1. 100% means 100% certainty, 0.1 means 10%. You can see the degree of certainty of the possible answers on the screen, to start testing try a value of 0.5.

AI/Learning Engine Customization

Before making any customization, it is recommended to back up the current models:

cp -r /opt/prediction_engine/models /opt/prediction_engine/models.bak

To restore the models from the backup run:

cp -f /opt/prediction_engine/models.bak/\* /opt/prediction_engine/models/

Questions and Answers (Knowledge Base)

The question and answer model will be trained from a CSV file with the following format:

Language code;Question;Answer

For instance:

"en";"question 1";"answer 1"
"en";"question 2";"answer 2"
"en";"question 1";"answer 1"
"en";"question 2";"answer 2"
…

It can be obtained automatically from Integria IMS database with the commands:

rm -f /opt/prediction_engine/data/integria_kb.zip 2>/dev/null
echo "SELECT id_language AS lang, title as question, data as answer FROM integria.tkb_data INTO OUTFILE '/opt/prediction_engine/data/integria_kb.csv' FIELDS TERMINATED BY ';' ENCLOSED BY '\"' LINES TERMINATED BY '\n';" | mysql -u integria -p integria && zip -j /opt/prediction_engine/data/integria_kb.zip /opt/prediction_engine/data/integria_kb.csv

To update the models, run:

cd /opt/prediction_engine/src
python kb_train.pyc

Dialogues (conversational)

The conversational model from YAML files with the following structure:

categories:
- category 1
- category 2
- …
conversations:
- - text 1
- text 2
- …
- - text 1
- text 2
- text 3
- …
…

The .yaml files (the name of the file is not important) should be placed in the directory:

/opt/prediction_engine/data/chat_xx

Where xx is the ISO code of the language to be updated (e.g., en is for English).

To update the models, run:

cd /opt/prediction_engine/src
python chat_train.pyc

How to use the chat

The Integria chatbot uses channels to define different places where to have conversations between operators (Integria IMS users with special permissions to manage conversations) and normal users (“normal” Integria IMS users or simple anonymous visitors, if they use the chat from outside Integria IMS).

Manage a channel

To do this go to SupportChatManage channel:

Add operators to the channel

The channel must have at least one operator, who will be the one who can answer users' chat requests. You may add any user with chat operator permissions and assign to it a description, an avatar (different from its user profile) and the languages in which it can answer chats.

Click on the operator icon to add a user and then the add operator button:

Use the screen to define an operator (in this example the user admin):Once added, other users will be able to start a chat:

Channel operators

In order for operators to receive audible notifications in the event that a user opens a chat, they must be on the chat control screen. It is accessed via SupportChatView chat. It will take you to a screen like this:

In there you can see the status of all chats. The operator will enter one of those chats and interact with the other party:

In the event that the chat is opened by an internal user, it will tell us which user it is. If a ticket is opened from an active incident.

Use chat outside of Integria IMS

You may want to use the chat outside the Integria IMS interface, for example on your website or in another application. Use the star icon to show you the JavaScript code snippet to embed in your application:

Copy and paste that code on your website and refresh the page.

Note that the URL that is included in the code is the URL that you have defined as the public URL in the chat server options. This URL must be accessible from where users access, in most cases, that means that it must be a public Internet URL.

Example of a static HTML page including the chat:

When getting into this page, the chat bubble will be seen:

And the conversation by clicking on the icon at the bottom right:

Go back to Integria IMS documentation index.