Giter VIP home page Giter VIP logo

botkit-middleware-witai's People

Contributors

anonrig avatar benbrown avatar dfischer avatar michaelmior avatar ouadie-lahdioui avatar robinjayaswal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

botkit-middleware-witai's Issues

Bot does not reply

Bot failed to reply on message_receive event. It looks like control never returns to bot controller and it hangs in wit.hears method, getting below log

debug: Successfully subscribed to Facebook events: {"success":true} {"msg_id":"262e9aa7-a945-452a-a275-3be9ff7c8970","_text":"hello","outcomes":[{"_text":"hello","confidence":null,"intent":"default_intent","entities":{"contact":[{"confidence":0.5748402256063738,"type":"value","value":"hello","suggested":true}]}}],"WARNING":"DEPRECATED"} debug: RECEIVED MESSAGE debug: CUSTOM FIND CONVO 1297127133704505 1297127133704505

Code snippet

`module.exports = function(bot, controller){
var wit = require('botkit-middleware-witai')({
token: process.env.wit_server_access_token,
logLevel: 'debug',
minConfidence: 0,
});

//Inject wit in receive
controller.middleware.receive.use(wit.receive);


// user said hello
controller.hears(['hello'], 'direct_message',wit.hears, function(bot, message) {
    bot.botkit.log("Wit.ai detected entities", message.entities);
    bot.reply(message, 'Hey there');

});

};
`

Help with getting started

I've used both this repo and the fork that includes an API update, I'm new to Wit, my bot doesn't respond at all once I include the middleware for hears. Any clue?

EDIT: looked at the code, and if I don't get intents returned it doesn't seem to run at all, so this might be my. Any info would be highly appreciated.

not calling next() if empty message recieved

Doubt it will happen but you should probably call next() if you don't have message,text

middleware.receive = function(bot, message, next) {
    if (message.text) {
        wit.captureTextIntent(config.token, message.text, function(err, res) {
            if (err) {
                next(err);
            } else {
                console.log(JSON.stringify(res));
                message.intents = res.outcomes;
                next();
            }
        });
    }

};

"node-wit": "^2.0.0" uses deprecated API

Hey there,

I noticed an issue where confidence score is not being returned when using botkit-middleware-witai. This is because it is using an old version on node-wit as a dependency.

Would it be possible to get this updated or is there a work around/something else I should be doing?

var VERSION = "20150306" is now deprecated. The latest is '20160516'

Thanks in advance for everything!

Npm package is outdated.

Hey guys, just a headsup about the npm package.
It looks like it's not up to date to the latest release from this repo and thus doesn't work with the current Wit API version.

To make it work, I've downloaded the code from this repo directly and included in my project.

wit.ai is not called when directly messaging bot

In botkit-middleware-witai.js, the receive function has this condition:

message.text && message.text.indexOf(bot.identity.id) > -1)

When I directly message the bot, the message.text doesn't contain the bot's identity so this always condition always fails. I want to be able to DM the bot, and have wit.ai process the message.

TypeError: Cannot read property 'id' of undefined

I'm running into an error while using this middleware along with the example code from the README. My experience with Botkit and Wit.ai is limited so I'm not sure if it's something I'm doing incorrectly or an actual bug.

I've included the code I'm testing with and the output of the console.

const Botkit = require('botkit');

const controller = Botkit.facebookbot({
    'access_token': process.env.FACEBOOK_PAGE_TOKEN,
    'verify_token': process.env.VERIFY_TOKEN
});

const wit = require('botkit-middleware-witai')({
    'token': process.env.WITAI_TOKEN
});

controller.middleware.receive.use(wit.receive);

controller.setupWebserver(process.env.PORT, (err, webserver) => {

    controller.createWebhookEndpoints(webserver, controller.spawn());

});

controller.hears(['hello'], 'message_received', wit.hears, (bot, message) => {

    bot.reply(message, 'hi!');

});
{
  "engines": {
    "node": ">=6.0"
  },
  "dependencies": {
    "botkit": "0.4.0",
    "botkit-middleware-witai": "howdyai/botkit-middleware-witai"
  }
}
Click to expand
14:55:41 web.1  | info: ERROR IN RECEIVE MIDDLEWARE:  TypeError: Cannot read property 'id' of undefined
14:55:41 web.1  |     at Ware.middleware.receive (/Users/scottdoxey/git/github/scottdoxeybot/node_modules/botkit-middleware-witai/src/botkit-middleware-witai.js:34:62)
14:55:41 web.1  |     at Ware.<anonymous> (/Users/scottdoxey/git/github/scottdoxeybot/node_modules/wrap-fn/index.js:45:19)
14:55:41 web.1  |     at next (/Users/scottdoxey/git/github/scottdoxeybot/node_modules/ware/lib/index.js:85:20)
14:55:41 web.1  |     at Ware.run (/Users/scottdoxey/git/github/scottdoxeybot/node_modules/ware/lib/index.js:88:3)
14:55:41 web.1  |     at Object.Botkit.botkit.receiveMessage (/Users/scottdoxey/git/github/scottdoxeybot/node_modules/botkit/lib/CoreBot.js:973:35)
14:55:41 web.1  |     at /Users/scottdoxey/git/github/scottdoxeybot/node_modules/botkit/lib/Facebook.js:202:45
14:55:41 web.1  |     at Layer.handle [as handle_request] (/Users/scottdoxey/git/github/scottdoxeybot/node_modules/express/lib/router/layer.js:95:5)
14:55:41 web.1  |     at next (/Users/scottdoxey/git/github/scottdoxeybot/node_modules/express/lib/router/route.js:131:13)
14:55:41 web.1  |     at Route.dispatch (/Users/scottdoxey/git/github/scottdoxeybot/node_modules/express/lib/router/route.js:112:3)
14:55:41 web.1  |     at Layer.handle [as handle_request] (/Users/scottdoxey/git/github/scottdoxeybot/node_modules/express/lib/router/layer.js:95:5)

accessing witai info in convo.ask()

How would I access the intents within this method or would I need to make a separate call to wit.ai? Thanks!

`convo.ask('What can I help with?',function(response, convo) {

  convo.say('Great, finding an article for you now...');
  console.log("response:" + response.text);
  console.log("convo:" + convo.text);
  convo.next();

});`

message sent to wit.ai contains @mention

The message.text value passed to the middleware.receive function contains the username mentioned, which means it gets set to wit.ai. For example, a "direct_mention" shows up in wit.ai as:
<@U0ZA78R19> testing pt 2. This may be an issue with how https://github.com/howdyai/botkit works, but is there any way to strip out the user prior to passing it to wit.captureTextIntent in the case of "direct_mention" and "direct_message"?

intents are now entities

In the README, you have:

The results of the call to Wit.ai are added into the incoming message as message.intents, and ...

But that should be message.entities.

using old version of wit.ai api

With wit.ai new api it's no longer appropriate to classify things off of the intent attribute.

It seems there has to be another strategy to figure it out.


Investigating this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.