Reputation: 159
I'm developing an assistant (bot) with Dialogflow, and i have this Django project where I have to extract data and then expose it through the bot, this is going to be stored in a local platform.
I worked with Dialogflow and it's integration before but with Node.js and Javascript, with Django (python) is a brand new challenge and I'm confused.
Until now I have the following:
I add a url for a webhook, right now this works locally only, like this:
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
import dialogflow
@csrf_exempt
def webhook(request):
return HttpResponse('Works like a charm!')
and in urls.py I have:
url(r'^webhook$', views.webhook, name='webhook')
And that's all I don't know how to proceed after this, I'm blocked and I don't know how yto make the integration and what's missing, any recommendations?
Upvotes: 2
Views: 3447
Reputation: 846
Steps
url-endpoint
and view
for displaying purpose of your html file say bot.html
. dialogflow
agent
as per you requirement.agent
provided by your djangoserver
which is routed with localtunnel's
public IP
(for developement purpose use localtunnel like ngrok to your django's
server
) fulfillment
of agent
. Hey you can refer this LINK using that you just need to
url-endpoint
and view
say /chatbot
which will accepts your text send by bot by AJAX
request. This text
is then passes to parameter texts
in that above functions in link. But make some changes in that functions like without printing fulfillment text
just return it.url-endpoint
/chatbot
return the response as fulfillmentText
return by that function in link.django-models
as tables in normal database, for that check the models - docs.
then you can access data by using models.objects.all()
etc.Upvotes: 3