howdyai / botkit-middleware-witai

Middleware for using Wit.ai with Botkit-powered bots
MIT License
87 stars 49 forks source link

Is this module broken with the latest version of Wit.ai? #15

Open lbustelo opened 7 years ago

lbustelo commented 7 years ago

Getting "WARNING":"DEPRECATED" in the returned payload. I can see my intent in the intent array, but not on the top object under outcomes.

Shreeraj1746 commented 7 years ago

There has been an update that fixes it. But I think the package is not update in npm. I installed it using npm today and I get the older version where wit.hear method handles for the old API response.

The code on git however is updated and works as it should.

Update: This is how I got it to work. Taking a look at the message returned from the API, I saw it was kind of weird. This is a very hacky fix but this is giving me the expected behavior.

middleware.hears = function(tests, message) { //console.log(message); obj = message.intents[0].entities var count = Object.keys(obj).length; if (count != 0) { for (var i = 0; i < message.intents[0].entities.intent.length; i++) { for (var t = 0; t < tests.length; t++) { if (message.intents[0].entities.intent[0].value == tests[t] && message.intents[0].entities.intent[0].confidence >= config.minimum_confidence) { return true; } } } } return false; };

simpixelated commented 7 years ago

I think this may be related: https://github.com/wit-ai/node-wit#changing-the-api-version

On 2016, May 11th, the /message API was updated to reflect the new Bot Engine model: intent are now entities. We updated the SDK to the latest version: 20160516. You can target a specific version by passing the apiVersion parameter when creating the Wit object.