watson-developer-cloud / botkit-middleware

A middleware to connect Watson Conversation Service to different chat channels using Botkit
https://www.npmjs.com/package/botkit-middleware-watson
Apache License 2.0
206 stars 254 forks source link

How do i use socketbot with watson conversation #130

Closed Developer-sa closed 6 years ago

Developer-sa commented 6 years ago

Hi I want to know how i can use socketbot without botkit studio token. I am using botkit with watson and facebook as thirdparty now, would like to know how i can receive and send messages that i was doing using facebookbot through socketbot. So, instead of facebook, i want to get the watson responses on my web application now. Any help would be appreciated. Thanks

Naktibalda commented 6 years ago

Use https://github.com/howdyai/botkit-starter-web and replace Botkit Studio integration code with Watson integration code that you can find in the README file.

Developer-sa commented 6 years ago

Did you mean this, var bot_options = { username: process.env.CONVERSATION_USERNAME, password: process.env.CONVERSATION_PASSWORD, workspace_id: process.env.WORKSPACE_ID, url: process.env.CONVERSATION_URL, version_date: process.env.CONVERSATION_VERSION_DATE replyWithTyping: true, };

Thanks

Naktibalda commented 6 years ago

Yes, options are necessary, but you have to create middleware object and register it with Botkit (as in example). And don't forget to install botkit-middleware-watson using npm.

Developer-sa commented 6 years ago

Thanks much, it works. Can I also know more about message filtering? I don't clearly understand what can i use it for? Can i use it to do something like this, when a particular intent is triggered, i don't want it to go back to watson and get outputs, rather I would like to do it inside my code.

Thanks in advance

Naktibalda commented 6 years ago

Can I also know more about message filtering? I don't clearly understand what can i use it for?

Some chat services send technical messages that don't include input from the user, message filtering allows to avoid sending such messages to Watson Conversation.

Can i use it to do something like this, when a particular intent is triggered, i don't want it to go back to watson and get outputs, rather I would like to do it inside my code.

No. Message filtering filters messages comming from the user. Sending response from your code is actually simpler than going back to watson.

https://github.com/watson-developer-cloud/botkit-middleware#intent-matching

slackController.hears(['intent-name'], ['direct_message', 'direct_mention', 'mention'], watsonMiddleware.hear, function(bot, message) {
  bot.reply(message, 'Hardcoded message here');
});
pgoldweic commented 6 years ago

Wouldn't the above simply filter based on the actual text entered by the user? If you want to recognize actual Watson intents, then you should look at the results obtained from Watson middleware (that is, the message gets augmented with all the information that Watson extracted, including intents). Then you could decide, in your logic, if you want to actually use the Watson-produced response, (which is also part of the augmented message) or provide your own or not.

Developer-sa commented 6 years ago

How can I directly take user inputs from a channel, say facebook, for a particular topic instead of passing it to watson middleware when I have watson middleware for other intents in my code? I want to have a conversation without sending it to watson.

Thanks

pgoldweic commented 6 years ago

As far as I understand it, you need to use a middleware wrapper, as explained in the readme file (see section on message filtering). That is, you write your own function that decides when/how to pass the message to the Watson middleware (or not).

Developer-sa commented 6 years ago

Thank you so much. That helps a lot. Can i build an entire conversation using this message filtering?

Thanks

pgoldweic commented 6 years ago

Sure, the wrapper would work for all messages received so you could decide what to do on a message by message basis.

Developer-sa commented 6 years ago

Thanks a lot