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. Deploying on Heroku
  7. Examples
  8. Motivation
  9. License
  10. Contributing

API View

If you need a django_dialogflow as a API endpoint, then you will need to add below steps to your

urlpatterns = [
    url(r'chat/$', chat_view, name='chat'),
    url(r'^$', index_view, name='index'),

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

In order to persists your data you need to create the necessary django_dialogflow tables.

For generating schema migrations, you have to run these steps.

$ python migrate django_dialogflow

Production your Bot

Configuring Dialogflow

To comunicate with Dialogflow you need get a client access token,

Then go to update your client_access_token in

# Dialogflow settings
    'client_access_token': 'e5dc21cab6df451c866bf5efacb40178',


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

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


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 as suggested below



python runserver

Further documentation on Dialogflow can be found here


If you are trying use django_dialogflow as app,

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

To install using pip :

$ pip install django-dialogflow

and then add it to your installed apps in your


Configuring Webservice

If you want to host your Django app, then 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.

Some basic Heroku deployment instrction are found below.


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.

Deploying on Heroku

Here are some of the steps to lauch your Django app with Heroku

Build your app and run it locally

pip install -r requirements.txt
Downloading/unpacking ...
Successfully installed Django dj-database-url dj-static django-toolbelt gunicorn psycopg2 static3
Cleaning up...

To run your application locally,

heroku local web
11:48:19 web.1  | started with pid 36084
11:48:19 web.1  | 2014-07-17 11:48:19 [36084] [INFO] Starting gunicorn 19.0.0
11:48:19 web.1  | 2014-07-17 11:48:19 [36084] [INFO] Listening at: (36084)
11:48:19 web.1  | 2014-07-17 11:48:19 [36084] [INFO] Using worker: sync
11:48:19 web.1  | 2014-07-17 11:48:19 [36087] [INFO] Booting worker with pid: 36087

Your app should now be avaliable and running on http://localhost:5000/.

Deploy your application on Heroku

git add .

git commit -m "Added a Procfile."

heroku login
Enter your Heroku credentials.

heroku create
Creating intense-falls-9163... done, stack is cedar |
Git remote heroku added

git push heroku master
-----> Python app detected
-----> Launching... done, v7 deployed to Heroku

Much more detailed information can be found here

Using the development version

You can clone the git repository by doing the following:

$ git clone git://


All examples are located here Github repo



Licensed under MIT


Development of django_dialogflow happens at Github:

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.

Share this project: