botkit-middleware-watson
Advanced tools
Comparing version 1.7.0 to 1.7.1
@@ -111,2 +111,5 @@ /** | ||
} | ||
if (payload.context && payload.context.workspace_id && payload.context.workspace_id.length === 36) { | ||
payload.workspace_id = payload.context.workspace_id; | ||
} | ||
return payload; | ||
@@ -113,0 +116,0 @@ }).then(function(payload) { |
{ | ||
"name": "botkit-middleware-watson", | ||
"version": "1.7.0", | ||
"version": "1.7.1", | ||
"description": "A middleware for using Watson Conversation in a Botkit-powered bot.", | ||
@@ -5,0 +5,0 @@ "main": "lib/middleware/index.js", |
@@ -365,4 +365,28 @@ # Use IBM Watson's Conversation service to chat with your Botkit-powered Bot! [![Build Status](https://travis-ci.org/watson-developer-cloud/botkit-middleware.svg?branch=master)](https://travis-ci.org/watson-developer-cloud/botkit-middleware) | ||
#### Dynamic workspace | ||
If you need to make use of multiple workspaces in a single bot, workspace_id can be changed dynamically by setting workspace_id property in context. | ||
Example of setting workspace_id to id provided as a property of hello message: | ||
```js | ||
function handleHelloEvent(bot, message) { | ||
message.type = 'welcome'; | ||
var contextDelta = {}; | ||
if (message.workspaceId) { | ||
contextDelta.workspace_id = message.workspaceId; | ||
} | ||
watsonMiddleware.sendToWatsonAsync(bot, message, contextDelta).catch(function (error) { | ||
message.watsonError = error; | ||
}).then(function () { | ||
bot.reply(message, message.watsonData.output.text.join('\n')); | ||
}); | ||
} | ||
controller.on('hello', handleHelloEvent); | ||
``` | ||
## License | ||
This library is licensed under Apache 2.0. Full license text is available in [LICENSE](LICENSE). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39281
299
392