Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

adds createPrivateConversation to Slack bots #586

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/Slackbot_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -321,7 +331,6 @@ module.exports = function(botkit, config) {
botkit.createConversation(this, message, cb);
};


/**
* Convenience method for creating a DM convo.
*/
Expand Down
11 changes: 11 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down