diff --git a/lib/Slackbot_worker.js b/lib/Slackbot_worker.js index 65d80244d..3990280c2 100755 --- a/lib/Slackbot_worker.js +++ b/lib/Slackbot_worker.js @@ -313,6 +313,16 @@ module.exports = function(botkit, config) { botkit.createConversation(this, message, cb); }; + bot.createPrivateConversation = function(message, cb) { + bot.api.im.open({ user: message.user }, function(err, channel) { + if (err) return cb(err); + + message.channel = channel.channel.id; + + botkit.createConversation(bot, message, cb); + }); + } + bot.createConversationInThread = function(message, cb) { // make replies happen in a thread if (!message.thread_ts) { @@ -321,7 +331,6 @@ module.exports = function(botkit, config) { botkit.createConversation(this, message, cb); }; - /** * Convenience method for creating a DM convo. */ diff --git a/readme.md b/readme.md index 42097f643..cc18dd7f0 100755 --- a/readme.md +++ b/readme.md @@ -491,6 +491,17 @@ and the conversation will not collect responses until it is activated using [con Use `createConversation()` instead of `startConversation()` when you plan on creating more complex conversation structures using [threads](#conversation-threads) or [variables and templates](#using-variable-tokens-and-templates-in-conversation-threads) in your messages. +#### bot.createPrivateConversation() +| Argument | Description +|--- |--- +| message | message object containing {user: userId} of the user you would like to start a conversation with +| callback | a callback function in the form of function(err,conversation) { ... } + +`createPrivateConversation()` is a function that initiates a conversation with a specific user. Note function is currently *Slack-only!* + +Use `createPrivateConversation()` instead of `startPrivateConversation()` when you plan on creating more complex conversation structures using [threads](#conversation-threads) or [variables and templates](#using-variable-tokens-and-templates-in-conversation-threads) in your messages. + + ### Control Conversation Flow #### conversation.activate()