het.oosten
het.oosten

Reputation: 885

Access webhook information from Dialogflow in Django

I have configured Dialogflow to make a POST request after a name is asked. When I view the information in an online request viewer I can see the information I want in the Query strings section:

> {   "responseId": "045c0d0b-7b5b-448e...",  
> "queryResult": {
>     "queryText": "rob",
>     "parameters": {
>       "last-name": "lastname",
>       "given-name": "Rob"
>     },

In Django however, I cannot find this information. I tried to save the full request and request.META in the database.

The received request on my server looks like:

{'QUERY_STRING': '', 'REQUEST_METHOD': 'POST', 'CONTENT_TYPE': 'application/json', 'CONTENT_LENGTH': '5323', 'REQUEST_URI': '/folder', 'PATH_INFO': '/folder', 'DOCUMENT_ROOT': '/home/info/domains/mysite.info/private_html', 'SERVER_PROTOCOL': 'HTTP/1.1', 'HTTPS': 'on', 'REMOTE_ADDR': '64.233.172.250', 'REMOTE_PORT': '53451', 'SERVER_PORT': '443', 'SERVER_NAME': 'mysite.info', 'HTTP_CONTENT_TYPE': 'application/json', 'HTTP_HOST': 'www.mysite.info', 'HTTP_CONTENT_LENGTH': '5323', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_ACCEPT': '/', 'HTTP_USER_AGENT': 'Google-Dialogflow', 'HTTP_ACCEPT_ENCODING': 'gzip,deflate,br', 'wsgi.input': , 'wsgi.file_wrapper': , 'wsgi.version': (1, 0), 'wsgi.errors': <_io.TextIOWrapper name=2 mode='w' encoding='UTF-8'>, 'wsgi.run_once': False, 'wsgi.multithread': False, 'wsgi.multiprocess': True, 'wsgi.url_scheme': 'https', 'uwsgi.version': b'2.0.18', 'uwsgi.node': b'server.mysite.info', 'SCRIPT_NAME': ''}

I use Nginx with Uwsgi

How do I access the full information in Django?

Upvotes: 0

Views: 59

Answers (1)

het.oosten
het.oosten

Reputation: 885

I should have used request.body in the view. There is no need to use custom headers in Dialogflow. All needed information is in the request.

Upvotes: 0

Related Questions