Skip to content

vkosuri/django-dialogflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django Dialogflow

Package Version Build Status

Django Dialogflow is a web client to chat.

Table of contents

  1. API View
  2. Sync your database
  3. Production your BOT
  4. Installation
  5. Configuring Webservice
  6. Examples
  7. Motivationl
  8. License
  9. Contributing

API View

If you need a django_dialogflow API endpoint you will want to add the following to your urls.py

urlpatterns = [
    url(r'chat/$', chat_view, name='chat'),
    url(r'^$', index_view, name='index'),
    url(r'^admin/', admin.site.urls),
]

The endpoint expects a JSON request with the following data:

{"text": "My input statement"}

See detailed example how retrieve end point translated information app.html

Sync your database

You will then want to create the necessary tables. If you generating schema migrations, you'll want to run:

$ python manage.py migrate django_dialogflow

Production your Bot

Configuring Dialogflow

To configure Dialogflow client access token, go settings.py

# Dialogflow settings
DIALOGFLOW = {
    'client_access_token': 'e5dc21cab6df451c866bf5efacb40178',
}

ALLOWD_HOSTS

Modify Django Allowed hosts to access your application everywhere, to do this modify settings.py as suggested below

ALLOWED_HOSTS = ['A.B.C.D', 'localhost']

CORS_ORIGIN_WHITELIST

Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources (e.g. fonts) on a web page to be requested from another domain outside the domain from which the first resource was served.

To do this modify settings.py as suggested below

CORS_ORIGIN_WHITELIST = (
    'A.B.C.D:9000',
)

Deploy

python manage.py runserver 0.0.0.0:8000

Further documentation on getting set up with Django and ChatterBot can be found in the ChatterBot documentation

Installation

If you are trying django_dialogflow as app,

Then you could install django-dialogflow either via the Python Package Index (PyPI) or from source.

To install using pip :

$ pip install django-dialogflow

and then add it to your installed apps:

INSTALLED_APPS = (
    ...
    'django_dialogflow',
    ...
)

Configuring Webservice

If you want to host your Django app, you need to choose a method through which it will be hosted. There are a few free services that you can use to do this such as Heroku and PythonAnyWhere.

WSGI

A common method for serving Python web applications involves using a Web Server Gateway Interface (WSGI) package.

Gunicorn is a great choice for a WSGI server. They have detailed documentation and installation instructions on their website.

Hosting static files

There are numerous ways to host static files for your Django application. One extreemly easy way to do this is by using WhiteNoise, a python package designed to make it possible to serve static files from just about any web application.

Using the development version

You can clone the git repository by doing the following:

$ git clone git:https://github.com/vkosuri/django-dialogflow.git

Examples

All examples are located here Github repo

Motivation

https://github.com/gunthercox/django_chatterbot

LICENSE

Licensed under MIT

Contributing

Development of django_dialogflow happens at Github: http:https://github.com/vkosuri/django-dialogflow

You are highly encouraged to participate in the development. If you don't like Github (for some reason) you're welcome to send regular patches.