treethought / flask-assistant

Framework for Building Virtual Assistants with Dialogflow and python
Apache License 2.0
379 stars 101 forks source link

"KeyError: 'result'" in core.py, line 285 #103

Closed JohannesMaier closed 5 years ago

JohannesMaier commented 6 years ago

I made a google action and connected it to my python-flask webhook. After receiving the json-data from google I got the Error which can be seen in the title

Json send by google action (schematic):

{  
   'responseId':'xxxxxxxxxxxxxx',
   'queryResult':{  
      'queryText':'xxxxxxxxxxxxxx',
      'action':'xxxxxxxxxxxxxx',
      'parameters':{  
         'xxxxxxxxxxxxxx':'xxxxxxxxxxxxxx',
         'xxxxxxxxxxxxxx':'xxxxxxxxxxxxxx',
         'xxxxxxxxxxxxxx':'xxxxxxxxxxxxxx'
      },
      'allRequiredParamsPresent':True,
      'fulfillmentText':'xxxxxxxxxxxxxx',
      'fulfillmentMessages':[  
         {  
            'text':{  
               'text':[  
                  'xxxxxxxxxxxxxx'
               ]
            }
         }
      ],
      'outputContexts':[  
         {  
            'name':'xxxxxxxxxxxxxx',
            'lifespanCount':5,
            'parameters':{  
               'xxxxxxxxxxxxxx':'xxxxxxxxxxxxxx',
               'xxxxxxxxxxxxxx.original':'xxxxxxxxxxxxxx',
               'xxxxxxxxxxxxxx.original':'xxxxxxxxxxxxxx',
               'xxxxxxxxxxxxxx.original':'xxxxxxxxxxxxxx',
               'xxxxxxxxxxxxxx':'xxxxxxxxxxxxxx',
               'xxxxxxxxxxxxxx':'xxxxxxxxxxxxxx'
            }
         },
         {  
            'name':'xxxxxxxxxxxxxx',
            'lifespanCount':1,
            'parameters':{  
               'xxxxxxxxxxxxxx':'xxxxxxxxxxxxxx',
               'xxxxxxxxxxxxxx.original':'xxxxxxxxxxxxxx',
               'xxxxxxxxxxxxxx.original':'xxxxxxxxxxxxxx',
               'xxxxxxxxxxxxxx.original':'xxxxxxxxxxxxxx',
               'xxxxxxxxxxxxxx':'xxxxxxxxxxxxxx',
               'xxxxxxxxxxxxxx':'xxxxxxxxxxxxxx'
            }
         }
      ],
      'intent':{  
         'name':'xxxxxxxxxxxxxx',
         'displayName':'xxxxxxxxxxxxxx'
      },
      'intentDetectionConfidence':1.0,
      'languageCode':'de'
   },
   'originalDetectIntentRequest':{  
      'payload':{  

      }
   },
   'session':'xxxxxxxxxxxxxx'
}

Is there any solution for this issue? Thanks!!

jbrandstetter commented 6 years ago

Switching back to v1 of the DialogFlow API fixed this issue for me.

sainimohit23 commented 4 years ago

Hi @jbrandstetter @treethought @JohannesMaier , Can any of you guide me how to switch back to v1 of the API? I can't find the option to do that. This is the error:

127.0.0.1 - - [28/Apr/2020 15:14:49] "POST / HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/home/v-mohit.saini/anaconda3/envs/assist/lib/python3.6/site-packages/flask/app.py", line 1997, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/v-mohit.saini/anaconda3/envs/assist/lib/python3.6/site-packages/flask/app.py", line 1985, in wsgi_app
    response = self.handle_exception(e)
  File "/home/v-mohit.saini/anaconda3/envs/assist/lib/python3.6/site-packages/flask/app.py", line 1540, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/v-mohit.saini/anaconda3/envs/assist/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/home/v-mohit.saini/anaconda3/envs/assist/lib/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/v-mohit.saini/anaconda3/envs/assist/lib/python3.6/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/v-mohit.saini/anaconda3/envs/assist/lib/python3.6/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/v-mohit.saini/anaconda3/envs/assist/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/home/v-mohit.saini/anaconda3/envs/assist/lib/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/v-mohit.saini/anaconda3/envs/assist/lib/python3.6/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/v-mohit.saini/anaconda3/envs/assist/lib/python3.6/site-packages/flask_assistant/core.py", line 253, in _flask_assitant_view_func
    _dbgdump(self.request['result'])
KeyError: 'result'