Botmaster middleware for Watson Conversation
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Botmaster Watson Conversation Ware

Build Status Coverage Status npm-version license

This incoming middleware will make the following available in the middleware being called after it:

  1. update.watsonUpdate: the response Watson Conversation came with based on the text the bot received
  2. update.session.watsonContext: this is simply the watson context, which is also available at update.watsonUpdate.context. However, here, it is leveraging sessionWare and will be persisted that way. For normal use, you shouldn't worry with this.
  3. update.watsonConversation: Simply exposing the watson conversation object that has been used to get the response from watson. It can be used . This is the conversation object as seen here: You'll only want to use this if you wish to make calls to, say, another workspace, or want to retrieve something else than simply the response from Watson (e.g. list of intents etc...). Powerful bots will probably make use of this in order to continually train watson for example.


yarn add botmaster-watson-conversation-ware

or with npm

npm install --save botmaster-watson-conversation-ware


This middleware can only be used in conjunction with botmaster-session-ware: As the context from botmaster needs to be persisted across different user messages. See how sessionWare is added at the end of the example using useWrapped.



Using this will create a botmaster 3 valid incoming middleware object that can be added by simply doing: botmaster.use (See example below)


  • settings object $0.settings just a valid watsonConversationSettings object that can be passed to watson-developer-cloud
  • workspaceId string $0.workspaceId The workspace Id you want to connect to
  • options


const Botmaster = require('botmaster');
// Using this bot class for the sake of the example
const SocketioBot = require('');
// might want to use this in conjunction with your own store in production
// as SessionWare uses the non-production ready MemoryStore by default
const SessionWare = require('botmaster-session-ware');
const WatsonConversationWare = require('botmaster-watson-conversation-ware');

const botmaster = new Botmaster();
botmaster.addBot(new SocketioBot({
  id: 'botId',
  server: botmaster.server,

const watsonConversationWareOptions = {
  settings: {
    username: <username_as_provided_by_bluemix>,
    password: <password_as_provided_by_bluemix>,
    version: 'v1', // as of this writing (01 Apr 2017), only v1 is available
    version_date: '2017-02-03', // latest version-date as of this writing
  workspaceId: <the_workspace_id_to_communicate_with> // As provided by Watson Conversation

// declaring middleware
const watsonConversationWare = WatsonConversationWare(watsonConversationWareOptions);

  type: 'incoming',
  name: 'my-awesome-middleware',
  controller: (bot, update) => {

    // watsonUpdate.output.text is an array as watson can reply with a few
    // messages one after another
    return bot.sendTextCascadeTo(update.watsonUpdate.output.text,;

// This will make our context persist throughout different messages from the
// same user
const sessionWare = new SessionWare();
botmaster.useWrapped(sessionWare.incoming, sessionWare.outgoing);

Returns object valid botmaster 3.0 incoming middleware object