VictorRancesCode / flutter_dialogflow

Flutter package for makes it easy to integrate dialogflow and support dialogflow v2
Apache License 2.0
214 stars 73 forks source link

[BUG] Invalid context appearing in request #11

Open HARSHITAGUPTA123 opened 5 years ago

HARSHITAGUPTA123 commented 5 years ago

My code is giving error at AIResponse response = await dialogflow.sendQuery(query);. I am using webhook through my own server for response. But the error comes before hitting webhook and says that

Context should contain only Latin letters, digits and underscore [a-z0–9_].

When I am checking my request json, it shows contexts key in json as

{contexts: fashion exhibition, lifespan: 2, parameters : {} }

We can never set contexts on Dialogflow console to anything with spaces or special characters. It doesn't allow us to do that. And to clear, fashion exhibition is one of the smart reply and I am not at all setting context to this. This is automatically happening in each request. It only works when smart reply doesn't contain any spaces. Please help, my app is broken and this happened only 3 weeks ago. It was working fine before that

HARSHITAGUPTA123 commented 5 years ago

Found the error. You may need to update your API here

String _getUrl(query) {
    return "https://api.dialogflow.com/v1/query?v=$version&contexts=$query"
        "&lang=es&query=$query&lang=$language&sessionId=$sessionId&timezone=$timezone";
  }

So this is using v1, the support of which is soon going to end. Secondly, you are passing contexts same as query(entered by user) which will break when the entered query has spaces or question marks or any special characters, as contexts do not allow all of that.