PlanBCom / hubot-wit

:speech_balloon: A script to use Wit.ai with Hubot.
10 stars 2 forks source link

"Bot executes" of Stories does not work #2

Open iStooge opened 7 years ago

iStooge commented 7 years ago

Hey!

I just created the following storie: image

Without the "Bot executes" command, the script seems to work fine. But as soon as i try to call a function (in this case findTheater) the script does not work correctly anymore!

Here is my conversation: image

And here the output of the console: image

The first message always throws the error No findTheater action found. The second time it works but without calling the function.

I created an event for Hubot: image

But it is never called. I think the error of the not found action comes up before the script can even emit the event.

Does someone can help me to get this work?

iStooge commented 7 years ago
 Ok i just found out that i have to add the Action directly into the hubot-wit.js file. 
 `// Example Action
  findTheater({sessionId, context, text, entities}) {
    console.log(`Session ${sessionId} received ${text}`);
    console.log(`The current context is ${JSON.stringify(context)}`);
    console.log(`Wit extracted ${JSON.stringify(entities)}`);
    return Promise.resolve(context);
  },`

Am I doing something wrong? Or does anyone have an idea howto automatically forward any action of a wit story to a Hubot event?

Godoy commented 7 years ago

Hey!

Unfortunately this package still does not perform actions coming from Wit. It was initially created just for the purpose of conversation, but performs a specific action called "missing", passing to the hubot the value of the entity "command" in this case.

Look at the plugin code in hubot-wit.js line 47:

      missing(request) {
        const { entities, context } = request;
        console.log(entities);
        const botCommand = firstEntityValue(entities, "command");

        return new Promise(function(resolve, reject) {
          robot.emit(botCommand, res);

          return resolve();
        });
      }

In your case, you can do something like: screen shot 2017-01-28 at 8 53 01 am

We also accept a "pull request" so that the package can execute an "emit" to the hubot of any action coming from "wit" :smile:

I will mark this issue as a feature request label.

thanks

iStooge commented 7 years ago

Ok :) I'll see what I can do!