Reputation: 47
I want to have someone say to a bot in slack:
@Bot setup @usertosetup
This should then start a conversation with that user to be setup. If I'm right and I've read correctly, the one that starts the conversation with the bot will be the one it listens to?
So the flow would be to bring the new user, an admin and the bot into their own room on slack, then start the conversation. Ideally, would be if you could say in the main chat window that phrase and it starts a private message with the user to set up, but I don't think that's possible due to the channel not existing yet?
I'm using Botkit to get this done.
Upvotes: -2
Views: 38
Reputation: 47
Solved it.
controller.hears('setup','direct_mention', function(bot,message) {
var x = message.text.indexOf("@");
var usr = message.text.substr(x - 2, message.text.length);
usr = usr.substring(3, usr.length - 1);
bot.api.im.open({user: usr}, function(err, response) {
bot.startConversation({
user:usr,
channel: response.channel.id
}, "Hello");
});
So, it finds the index of the message sent to the bot with the @ symbol, pulls it out and does some substring fun to reduce it. Then, launches the conversation by the channel.
Upvotes: 1