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
207 stars 255 forks source link

Add Support for Botkit 4 #174

Closed Naktibalda closed 5 years ago

Naktibalda commented 5 years ago

I updated javascript code to work with Botkit 4. It uses a different storage system now. Because Botkit uses promises everywhere now, I used Promises in utils.js too, but the interface of middleware remains unchanged.

BREAKING CHANGES:

germanattanasio commented 5 years ago

@Naktibalda can you fix some of the open issues along with this PR?

Naktibalda commented 5 years ago

I converted code to Typescript.

Usage in Typescript:

import {WatsonMiddleware} from 'botkit-middleware-watson';
const watsonMiddleware = new WatsonMiddleware(config);

Usage in Javascript:

const WatsonMiddleware = require('../lib/middleware/index').WatsonMiddleware;
const middleware = new WatsonMiddleware(config);
Naktibalda commented 5 years ago

Because this middleware is a class now, it must be registered this way: controller.middleware.receive.use(watsonMiddleware.receive.bind(watsonMiddleware)); (I wasted hours trying to figure out why controller.middleware.receive.use(watsonMiddleware.receive); wasn't working.)

Naktibalda commented 5 years ago

Botkit 4.0.1 was released yesterday, so Botkit 4 is complete.

@germanattanasio Please review, merge and release 2.0.0. Another option is to make it 4.0.0 to catchup with ibm-watson 4 and Botkit 4.

I updated README, but samples are still outdated.

germanattanasio commented 5 years ago

@Naktibalda In order to merge this and trigger a major release we need to update or remove the multi-bot sample. I vote for removing that sample and point users to botkit.

Naktibalda commented 5 years ago

I agree on removal of multi-bot. I think that even the README of simple-bot should crearly state that "This is just a sample, please follow documentation of Botkit to create a new bot and then plug Watson middleware into it".

codecov-io commented 5 years ago

Codecov Report

:exclamation: No coverage uploaded for pull request base (master@3fc1bdc). Click here to learn what that means. The diff coverage is 78.5%.

Impacted file tree graph

@@           Coverage Diff            @@
##             master    #174   +/-   ##
========================================
  Coverage          ?   78.5%           
========================================
  Files             ?       2           
  Lines             ?     107           
  Branches          ?      22           
========================================
  Hits              ?      84           
  Misses            ?      19           
  Partials          ?       4
Impacted Files Coverage Δ
lib/utils.js 100% <100%> (ø)
lib/index.js 65.15% <65.15%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 3fc1bdc...74ab971. Read the comment docs.

Naktibalda commented 5 years ago

Thanks