Skip to main content

Installation

This section covers setting up the AI Studio release on your machine.

Prerequisites

  • Machine with 4 CPUs and 16 GB RAM
  • PostgreSQL database (9.* or above)
  • NGINX
    It is bundled only with the Windows distribution.
  • Python 3.9.6
    Python 3.9.6 along with all the dependencies is bundled with our distribution for Windows and Linux.
  • ngrok (a tool that allows you to tunnel from a public URL to your application running locally) Needed only if you want to see end-to-end integration with AutomationEdge and try out integration of your chatbot with MS-Teams

PostgreSQL Installation

Install the PostgreSQL database on your machine, if it isn't already installed. Create two databases (schemas) with names aistudio and aistudiobot respectively. The former is to be used by the AI Studio engine and the latter by chatbot web service.

This document doesn't cover PostgreSQL database installation on Windows, Linux, or Mac.

Installation on Windows

Download AI Studio Distribution

Distribution for Windows also includes bundled Python 3.9.6 with all the required package dependencies.

  • Click The download link to register and download AI Studio distribution for Windows.

  • Unzip the aistudio-windows.zip file in the drive of your choice. Instructions below assume that you have extracted the zip under D:\. This should give you a directory aistudio with underlying directories as shown below.

    D:\aistudio-packages\
    └── AIStudio
    ├── engine
    ├── python
    └── Chatbot-Webservice
    ├── cognibot
    ├── python
    └── UI

Start AI Studio Engine

Open .env file inside the folder D:\aistudio-packages\AIStudio\engine in the editor of your choice. Its default contents are as shown below.

AISTUDIO_DB_ENGINE=django_postgrespool2
AISTUDIO_DB_NAME=aistudio
AISTUDIO_DB_USER=postgres
AISTUDIO_DB_PASS=Admin@123
AISTUDIO_DB_HOST=localhost
AISTUDIO_DB_PORT=5432

Replace the AISTUDIO_DB_PASS setting with your Postgres password. However, if you installed the PostgreSQL server with different settings, make sure that all of these parameters have the correct values. Now execute these commands in the Command Prompt.

In case you are using Windows, ensure to uncomment line number 38 in the .env file.

SCHEDULER_LOCK_TYPE=Database
note

Set the AISTUDIO_HOME environment variable by going to your system properties. Set the path as D:\aistudio-packages\AIStudio\python\Lib . You can change the directory according to the drive you have extracted your AIStudio in. You may have to restart your system after setting the environment variable.

  • cd D:\aistudio-packages\AIstudio\engine
  • D:\aistudio-packages\AIstudio\python\python.exe manage.pyc migrate  This command generates all the database tables needed for AI Studio engine.
  • D:\aistudio-packages\AIstudio\python\python.exe manage.pyc runserver localhost:8000  This command starts the AI Studio engine on port 8000. You can specify an alternative port in the command above if port 8000 is currently being used by another program. However, in order to avoid additional setup modifications, we strongly advise running it on port 8000.

Ngrok Setup

As explained in Integration with AutomationEdge sub-section of Architecture section of the document, one of the popular options for exposing a web service running on local machine over internet is ngrok. Download the right version of ngrok for your operating system and run it with command ngrok http 3978. This tells ngrok to expose service running on port 3978 over internet.

img alt

When you run the ngrok command, as seen in the above image, 1 is the URL you can use to monitor the traffic going through ngrok tunnel and 2 is the public https end-point of your tunneled service. You will use this value to set setting CHATBOT_URL as explained in the next section.

Start Cognibot Web Service

Open .env file inside the folder D:\Chatbot-Webservice\cognibot in the editor of your choice. Its relevant default contents are as shown below.

AISTUDIOBOT_DB_ENGINE=django_postgrespool2
AISTUDIOBOT_DB_NAME=aistudiobot
AISTUDIOBOT_DB_USER=postgres
AISTUDIOBOT_DB_PASS=Admin@123
AISTUDIOBOT_DB_HOST=localhost
AISTUDIOBOT_DB_PORT=5432

Replace the AISTUDIO_DB_PASS setting with your Postgres password. However, if you installed the PostgreSQL server with different settings, make sure that all of these parameters have the correct values. Now execute these commands in the Command Prompt.

Also update below setting in the .env file and in place of <NGROK https end-point>, put the value of the public https end-point as was explained in the previous section.

CHATBOT_URL=<NGROK https end-point>/api/reply
note

Set the CHATBOT_WEB_SERVICE_HOME environment variable by going to your system properties. Set the path as D:\aistudio-packages\Chatbot-Webservice\python\Lib . You can change the directory according to the drive you have extracted your AIStudio in. You may have to restart your system after setting the environment variable.

Now execute these commands.

  • cd D:\aistudio-packages\Chatbot-Webservice\cognibot
  • D:\aistudio-packages\Chatbot-Webservice\python\python.exe manage.pyc migrate  This command generates all the database tables needed for chatbot web service.
  • D:\aistudio-packages\Chatbot-Webservice\python\python.exe manage.pyc runserver localhost:3978  This command starts cognibot web service on port 3978. Again, we strongly suggest running it on port 3978 in order to avoid further configuration changes.

Running NGINX

You will now run the NGINX web server which will host the AI Studio UI and a sample website which hosts the web chat channel. NGINX which we have bundled runs on port 8008, which can be changed in D:\aistudio\UI\conf\nginx.conf file. Just double click on D:\aistudio\UI\nginx.exe file. You can now access AI Studio UI application at http://localhost:8008/aistudio.

AI Studio login credentials

Username : user_1
Password : pass_1

To see how to embed web chat in an existing website, you can access http://localhost:8008/webchat.

Installation on Linux

A note on Linux distros

AI Studio Linux distribution has been tested on Ubuntu 18.04 LTS and Ubuntu 20.04 LTS. For your specific Linux distro, you might have set up Python 3.9 on your own.

Download AI Studio Distribution

  • Head over to the download link to register and download AI Studio distribution for Linux.

  • Unzip the aistudio-linux.zip file in the drive of your choice. Instructions below assume that you have extracted the zip under /home/heman. This should give you a directory aistudio with underlying directories as shown below.

    /home/user
    └── aistudio-packages
    ├── AIStudio
    ├── AIEngine
    ├── Chatbot-Webservice
    └── UI

Start AI Studio Engine

Open .env file inside the folder /home/user/aistudio-packages/AIStudio/engine in the editor of your choice. Its default contents are as shown below.

AISTUDIO_DB_ENGINE=django_postgrespool2
AISTUDIO_DB_NAME=aistudio
AISTUDIO_DB_USER=postgres
AISTUDIO_DB_PASS=Admin@123
AISTUDIO_DB_HOST=localhost
AISTUDIO_DB_PORT=5432

Replace the AISTUDIO_DB_PASS setting with your Postgres password. However, if you installed the PostgreSQL server with different settings, make sure that all of these parameters have the correct values. Now execute these commands in the Command Prompt.

  • cd /home/user/aistudio-packages/AIStudio/engine
  • export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/user/aistudio-packages/AIStudio/python/lib  This command adds libraries shipped with Python package to LD_LIBRARY_PATH.
  • /home/user/aistudio-packages/AIStudio/python/bin/python3.9 manage.pyc migrate  This command generates all the database tables needed for AI Studio engine.
  • /home/user/aistudio-packages/python/bin/python3.9 -m gunicorn --threads 25 aistudio.wsgi:application  This command starts the AI Studio engine on port 8000. If you already have an application running on port 8000, you can specify a different port in the command above. But we strongly suggest running it on port 8000 in order to avoid further configuration changes.

Ngrok Setup

As explained in Integration with AutomationEdge sub-section of Architecture section of the document, one of the popular options for exposing a web service running on local machine over internet is ngrok. Download the right version of ngrok for your operating system and run it with command ngrok http 3978. This tells ngrok to expose service running on port 3978 over internet.

img alt

When you run the ngrok command, as seen in the above image, 1 is the URL you can use to monitor the traffic going through ngrok tunnel and 2 is the public https end-point of your tunneled service. You will use this value to set setting CHATBOT_URL as explained in the next section.

Start Cognibot Web Service

Open .env file inside the folder /home/user/aistudio-packages/Chatbot-Webservice/cognibot in the editor of your choice. Its relevant default contents are as shown below.

AISTUDIOBOT_DB_ENGINE=django_postgrespool2
AISTUDIOBOT_DB_NAME=aistudiobot
AISTUDIOBOT_DB_USER=postgres
AISTUDIOBOT_DB_PASS=Admin@123
AISTUDIOBOT_DB_HOST=localhost
AISTUDIOBOT_DB_PORT=5432

Replace the AISTUDIO_DB_PASS setting with your Postgres password. However, if you installed the PostgreSQL server with different settings, make sure that all of these parameters have the correct values. Now execute these commands in the Command Prompt.

Also update below setting in the .env file and in place of <NGROK https end-point>, put the value of the public https end-point as was explained in the previous section.

CHATBOT_URL=<NGROK https end-point>/api/reply

Now execute these commands.

  • cd /home/user/aistudio-packages/Chatbot-Webservice/cognibot*
  • export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/heman/aistudio/python/lib  This command adds libraries shipped with Python package to LD_LIBRARY_PATH.
  • /home/user/aistudio-packages/aistudio/python/bin/python3.9 manage.py migrate  This command generates all the database tables needed for chatbot web service.
  • /home/heman/aistudio/python/bin/python3.9 -m daphne -p 3978 webchat_channel.routing:application  This command starts cognibot web service on port 3978. Again, we strongly suggest running it on port 3978 in order to avoid further configuration changes.

Deploying AI Studio UI on NGINX

Install NGINX web server on your machine if it isn't already running or installed. Copy two directories /home/heman/aistudio/ui/html/aistudio and /home/heman/aistudio/ui/html/webchat to your NGINX default public folder (possibley/var/www/html). Once done, you will be able to access AI Studio UI at http://localhost/aistudio assuming NGINX is running on port 80. You will also have to modify appropriate NGINX configuration file (possibly /etc/nginx/sites-enabled/default) and put below content in it.

server {
location ^~ /aistudio {
root /var/www/html;
try_files $uri $uri/ /aistudio/index.html =404;
}
location /webchat {
root /var/www/html;
try_files $uri $uri/ /webchat/index.html =404;
}
location /api {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://localhost:8000;
}
}

First two sections location ^~ /aistudio { and location /webchat { tell NGINX to do URL rewriting as both are React (single page) applications using Browser Routing.
AI Studio UI is a React application and makes REST calls to AI Studio engine which, as we saw earlier, is running on port 8000. In order to avoid CORS issues, last part of above configuration tells NGINX to proxy REST requests to AI Studio engine running at http://localhost:8000.

With NGINX properly configured and running, you can access AI Studio UI at http://localhost/aistudio and use below credentials to log in.

AI Studio login credentials

Username : user_1
Password : pass_1

Chatbot Configuration

  • Click Chatbots sub menu from the left panel.
  • Click IT from the Bots list. This is a sample bot which we will take a look at in more detail later.
  • On the Bot Overview page, verify the NLU Project Details and KM Project details. You will notice the assigned projects for both are the same names we imported earlier.
  • Edit the following details by clicking menu ( img alt )
    Details

    Connector Service URL : http://localhost:3978/v3/directline
    Bot token : secret

This is the connector service as explained in the Architecture section which enables web chat to connect to the chatbot web service.