0

I'm using wit ai for a bot and I think it's amazing. However, I must provide the customer with screens in my web app to train and manage the app. And here I found a big problem (or maybe I'm just lost). The documentation of the REST API is not enough to design a client that acts like the wit console (not even close). it's like a tutorial of what endpoints you can hit and an overview of the parameters, but no clean explanation of the structure of the response.

For example, there is no endpoint to get the insights edge. Also and most importantly, no clear documentation about the response structure when hitting the message endpoints (i.e. the structure the returned entities: are they prebuilt or not, and if they are, is the value a string or an object or array, and what the object might contain [e.g. datetime]). Also the problem of the deprecated guide and the new guide (the new guide should be done and complete by now). I'm building parts of the code based on my testing. Sometimes when I test something new (like adding a range in the datetime entity instead of just a value), I get an error when I try to set the values to the user since I haven't parsed the response right, and the new info I get makes me modify the DB structure at my end sometimes.

So, the bottom line, is there a complete reference that I can implement a complete client in my web app (my web app is in Java by the way and I couldn't find a client library that handles the latest version of the API)? Again, the tool is AWESOME but the documentation is not enough, or maybe I'm missing something.

M.R.M
  • 540
  • 1
  • 13
  • 30

1 Answers1

1

The document is not enough of course but I think its pretty straightforward. And from what I read there is response structure under "Return the meaning of a sentence".

It's response in JSON format. So you need to decode the response first.

Example Request:

 $ curl -XGET 'https://api.wit.ai/message?v=20170307&q=how%20many%20people%20between%20Tuesday%20and%20Friday' \
  -H 'Authorization: Bearer $TOKEN'

Example Response:

 {
"msg_id": "387b8515-0c1d-42a9-aa80-e68b66b66c27",
"_text": "how many people between Tuesday and Friday",
"entities": {
  "metric": [ {
    "metadata": "{'code': 324}",
    "value": "metric_visitor",
    "confidence": 0.9231
  } ],
  "datetime": [ {
    "value": {
      "from": "2014-07-01T00:00:00.000-07:00",
      "to": "2014-07-02T00:00:00.000-07:00"
    },
    "confidence": 1
  }, {
    "value": {
      "from": "2014-07-04T00:00:00.000-07:00",
      "to": "2014-07-05T00:00:00.000-07:00"
    },
    "confidence": 1
  } ]
}
}

You can read more about response structure under Return the meaning of a sentence

Salehin Rafi
  • 351
  • 2
  • 6
  • 16
  • but this doesn't handle many cases .. for example, datetime depends on the type, if interval, then there is no value and there is a from and to objects with value and grain returned .. I couldn't find that anywhere in the docs – M.R.M Dec 20 '17 at 08:12
  • also, sometimes a suggested parameter is returned, does it mean that this is suggested .. what does it mean exaclty? after testing i think it means that it's not an actual value of the prebuilt entity, but rather a value that you added through the training ..and still no sure – M.R.M Dec 20 '17 at 08:14
  • I shouldn't find bugs on parsing the response cause the structure is not detailed – M.R.M Dec 20 '17 at 08:15
  • also, roles are returned as entities and contain a reference to the actual entity which makes a mess according to the structure since a role is not an actual entity (for example, when you post a sample, you don't send it as an entity but rather as a parameter in the entity) .. which makes confusion I'm interested in the hierarchy of having an entity with its roles (like children) – M.R.M Dec 20 '17 at 09:04
  • so you are right there is a response structure, but doesn't actually state the structure but rather provide an example (which is btw outdated, try the example on an app that has wit datetime entity, I get a different structure with interval type) – M.R.M Dec 20 '17 at 09:07