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

is this middleware compatible with botkit-anywhere? #133

Closed pgoldweic closed 6 years ago

pgoldweic commented 6 years ago

I'd like to understand if this middleware is compatible with the new web starter kit for botkit (botkit-anywhere). In particular, I have been using this middleware to connect with botkit via Cisco Spark, but our new requirements are such that we need to have the bot operate outside of a messaging platform. Given the following items:

- This middleware uses botkit storage in order to save user context information
- Botkit-anywhere supports an optional 'message history' via Mongo DB storage

I need to understand whether I can replace the botkit/Spark integration within my bot with botkit-anywhere, while continue using watson middleware as before AND opting out of the 'message history' feature (I'd like to avoid the need to use Mongo DB, plus I've implemented a restricted 'message history' feature myself based on botkit channel storage). And if the answer is YES, how would I go about specifying to botkit (and watson) what my user's userid/account is? I see some relevant docs in https://github.com/howdyai/botkit-starter-web/blob/master/docs/botkit_web_client.md#share-user-accounts--profile-data-with-botkit, but would this work with a userid that is a randomly generated id when the user first connects? (given the absence of a formal user id from the messaging framework).

Naktibalda commented 6 years ago

I am using watson middleware with botkit-starter-web since last June, so it works. However my codebase diverged signifficantly (mostly HTML, CSS and some images) and I stopped merging changes when HTML of starter kit was reworked (between September and November last year). MongoDB history is implemented in the starter kit, so you can remove that code.

I think that it is mostly in this skill file https://github.com/howdyai/botkit-starter-web/blob/master/skills/message_history.js ,you should get rid of it and other skill files (because they override watson responses).

I am actually using in-memory storage in order to avoid storing context data permanently, but I implemented my own message history functionality using plain text files.

Providing user id is optional (documentation says If provided, user information will be used in a variety of ways:).

peterswimm commented 6 years ago

I would not recommend you remove all the skills unless you are sure of what you are removing. If anyone finds a built-in that breaks watson, we'd appreciate a pull request rather than stripping out the functionality.

We added mongo because you really need storage to do stuff on the web client (in other platforms we can lean a little heavier on the API to provide user data) You can replace the inbuilt mongo with your own storage schema, but you would need to do the work to integrate that:

https://github.com/howdyai/botkit/blob/master/docs/storage.md

pgoldweic commented 6 years ago

Thanks @Naktibalda & @peterswimm for your replies. I am curious though @Naktibalda , how could watson work if a userid is not set? (since it's using user storage to keep track of watson's processing state, as far as I understand it). In other words, doesn't your code require this to actually function appropriately?

Naktibalda commented 6 years ago

If userId is not provided, client.js generates random id. https://github.com/howdyai/botkit-starter-web/blob/e0cead4da1e0cf84ab9b12f432508e2d4365e865/public/client.js#L167

pgoldweic commented 6 years ago

Oh, I see. That makes sense. So I assume this random id persists while the websocket connection is open, correct? Thanks again for replying.

germanattanasio commented 6 years ago

This issue is fairly old and there hasn't been much activity on it. Closing, but please re-open if it still occurs.