Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

adapt to new version of wit api, give configuration option for wit co… #27

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

ALBotStageSoftNaert
Copy link

I adapted the middleware to work with version 5.0.0 of node-wit. I added an optional config option so that you could specify a command to use instead of the bot identity. If no command was specified every request will be parsed by wit.

@msftclas
Copy link

msftclas commented Mar 26, 2019

CLA assistant check
All CLA requirements met.

client.message(message.text, {})
.then((data) => {
message.entities = data.entities;
console.log(JSON.stringify(data));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this console.log, or use the debug module

@benbrown
Copy link
Contributor

@ALBotStageSoftNaert This looks backward compatible but I want to make sure you agree. Is it?

Thanks for your quick response to my review!

@benbrown
Copy link
Contributor

Also, it looks like the hears middleware may need a mild update? See this other PR -> #26

@ALBotStageSoftNaert
Copy link
Author

@benbrown thanks for your fast review. I think that it won't be backwards compatible, node-wit changed the way they return intents in a different way. However they do provide the posibility to provide an option to include the apiversion. https://github.com/wit-ai/node-wit#changing-the-api-version. I can add an extra config option to make it backwards compatible in this manner.

@benbrown
Copy link
Contributor

In that case the readme will need some updates and we'll have to bump the version number on npm.

Thanks!

@ALBotStageSoftNaert
Copy link
Author

@benbrown I updated the discussed topics

  • configuration option api_version was added
  • the version nr in package.json has been placed on 2.0.0
  • the middleware.hears method has been updated, I checked the PR #26 and noticed that the improvement provided was to not have to loop over the tests array. I included this in the current code by using an include on the tests array.
 if (message.entities && message.entities.intent) {
            for (var i = 0; i < message.entities.intent.length; i++) {
                if(tests.includes(message.entities.intent[i].value) && message.entities.intent[i].confidence >= config.minimum_confidence){
                    return true;
                }
            }

I also noticed that the results from entities were taken instead of entities.intent. This is possible and would mean that all entities in wit can be used to get a match, not only the intents. However, I don't think this is desired behaviour, so it wasn't included in the changes.

  • the readme file has been updated

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants