Skip to content

Configuration

Matúš Žilinec edited this page Jun 24, 2018 · 12 revisions

Installation

First, install Golem from PyPI. Then, you can use the Golm init script to generate a skeleton chatbot and start it.

pip3 install django-golem        # installs Golem framework
golm init my_bot                 # creates a project in my_bot/
cd my_bot && golm start my_bot   # starts the bot

The web chat app should now be running at localhost.

You can also check out our example project.

Manual installation

Golem runs on top of Django web server as a regular plugin.

You will need:

  • Python 3.6+
  • Django (web server)
  • Celery (asynchronous task runner)
  • Redis (in-memory database)
  • Golem framework

You can install these with pip3 install django redis-server celery django-golem.

Now you can create a skeleton project by running django-admin startproject your_bot in your shell.

You should now have a new project directory. This directory contains manage.py, the script used to run the server and a directory with python code, containing urls.py, settings.py and other files.

Basic setup

First, we will set up endpoints. Open your urls.py and add:

from django.urls import path, include

urlpatterns = [
    # this is where endpoints for facebook, telegram etc. will be ...
    path('chatbot/', include('golem.urls')),
    # ... show the web gui on index page
    path('', include('webgui.urls')),
]

Golem reads all settings from your django settings.py file. Inside it, create a dict like this:

GOLEM_CONFIG = {
    # first the boring config stuff ...
    'REDIS': {
        'HOST': localhost,
        'PORT': 6379,
        'PASSWORD': None,
    },
    'WIT_TOKEN': ,     # get it @ wit.ai
    'FB_PAGE_TOKEN': , # get it @ fb
    'WEBHOOK_SECRET_URL': ,   # any string, used to hide url from 3rd parties
    'WEBHOOK_VERIFY_TOKEN': , # any string, used by fb to verify your identity
    # and now the fun part!
    'BOTS': {
        # list of your dialog flows, see next page for details
        'mybot.bots.greeting.flow',
        'mybot.bots.someother.flow',
    }
}

Don't forget to include golem and webgui in INSTALLED_APPS inside settings.py.

INSTALLED_APPS = [
  ...
  golem,
  webgui,
]

You can now start the chatbot like this:

./manage.py migrate        # first time setup of django database
./manage.py runserver      # start the web server that communicates with chat services
redis-server &             # a fast, in-memory database used by Golem
celery -A your_bot worker  # start the worker threads

If you start the bot now, you should see the testing chat interface on localhost.

Now you can configure integrations with messaging services like Facebook, choose your NLU service and finally write a chatbot.

The next step is to finally start making your chatbot.