Search code examples
botsslack-apibotkit

How can i make my bot ask a statement, wait for the response of that statement


Is there any way i can ask my bot a question and make it wait for a response to that particular question so i could do some more things on that particular message?


Solution

  • Yes, there are examples in the botkit readme. copy pasting :

    controller.hears(['question me'], 'message_received',function(bot,message) {
    
      // start a conversation to handle this response.
      bot.startConversation(message,function(err,convo) {
    
        convo.ask('How are you?',function(response,convo) {
    
          convo.say('Cool, you said: ' + response.text);
          convo.next();
        });
      })
    })