Django Dialogflow is a web client to chat.
- API View
- Sync your database
- Production your BOT
- Installation
- Configuring Webservice
- Deploying on Heroku
- Examples
- Motivation
- License
- Contributing
If you need a django_dialogflow as a API endpoint, then you will need to add below steps 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
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 manage.py migrate django_dialogflow
To comunicate with Dialogflow you need get a client access token,
Then go to settings.py update your client_access_token
in settings.py
# Dialogflow settings
DIALOGFLOW = {
'client_access_token': 'e5dc21cab6df451c866bf5efacb40178',
}
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']
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',
)
python manage.py runserver 0.0.0.0:8000
Further documentation on Dialogflow can be found here https://dialogflow.com/
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 settings.py:
INSTALLED_APPS = (
...
'django_dialogflow',
...
)
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.
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.
Here are some of the steps to lauch your Django app with Heroku
pip install -r requirements.txt
Downloading/unpacking ...
...
Successfully installed Django dj-database-url dj-static django-toolbelt gunicorn psycopg2 static3
Cleaning up...
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: http://0.0.0.0:5000 (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/.
git add .
git commit -m "Added a Procfile."
heroku login
Enter your Heroku credentials.
...
heroku create
Creating intense-falls-9163... done, stack is cedar
http://intense-falls-9163.herokuapp.com/ | [email protected]:intense-falls-9163.git
Git remote heroku added
git push heroku master
...
-----> Python app detected
...
-----> Launching... done, v7
https://intense-falls-9163.herokuapp.com/ deployed to Heroku
Much more detailed information can be found here https://devcenter.heroku.com/articles/deploying-python
You can clone the git repository by doing the following:
$ git clone git://github.com/vkosuri/django-dialogflow.git
All examples are located here Github repo
https://github.com/gunthercox/django_chatterbot
Licensed under MIT
Development of django_dialogflow happens at Github: http://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.