Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

message sent to wit.ai contains @mention #2

Open
simpixelated opened this issue Apr 10, 2016 · 6 comments
Open

message sent to wit.ai contains @mention #2

simpixelated opened this issue Apr 10, 2016 · 6 comments
Labels

Comments

@simpixelated
Copy link

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"?

@simpixelated
Copy link
Author

I tried to wrap receive with a function that replaces the bot ID:

controller.middleware.receive.use(function (bot, message, next) {
  if (message.text) {
    var reg = new RegExp('^<@' + bot.identity.id + '>:?\s?');
    message.text = message.text.replace(reg, '').trim();
    wit.receive(bot, message, next);
  }
});

EDIT: this solves the problem with sending the message to wit.ai with the user ID stripped, but it breaks the hears middleware. Seems like botkit may be matching against that string to determine "direct_mention", so if the bot userid is not there it won't even get passed to middleware.hears.

anonrig pushed a commit that referenced this issue Aug 24, 2016
@cesarvarela
Copy link

Any news about this?

@simpixelated
Copy link
Author

No news. I'm still seeing the issue with this and https://github.com/abeai/botkit-middleware-apiai. I think it needs to be fixed within the receive function of each middleware.

@peterswimm peterswimm added the bug label Jan 3, 2017
@makstaks
Copy link

@simpixelated I thought sending the @user_id to wit.ai was the expected behaviour, so in wit.ai I marked the @user_id as a contact and wit.ai began to correctly determine the intent of the phrase.
Having the @user_id might be a useful piece of information to create more interesting functionality.

@simpixelated
Copy link
Author

@makstaks you have a good point; is there a way to filter it out of intents within wit.ai though? Last time I checked there was not, which meant I had to include both "this my intent" and "<@botId> this is my intent" in order to trigger the correct responses.

@makstaks
Copy link

@simpixelated Sorry I missed your message. I was including both, but after using wit.ai with actual users, I'm finding it is still not working very well, even with single word commands. I don't have a solution yet, for now I just disabled wit.

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

No branches or pull requests

4 participants