Search code examples
javascriptnlphubot

Saving Hubot Input to a Variable


All I can find in the documentation is .hear("specific phrase"), or similar methods of processing input. Is there a way to simply store all input to the bot as a variable? The reason for this is that I intend on filtering this input through an NLP library to allow for natural language input to the bot. Any help is appreciated.

hubot on github.


Solution

  • I think what you're asking is if you can take what the person says to hubot, and put that into a variable. I do this with the following code:

    module.exports = function(robot) {
    robot.hear(/^(.*)/, function(msg) {
    var content = msg.match.input;
    
    });
    }
    

    Then, you can do whatever you want with the "content" variable. If you have any further questions, I'd be happy to answer them, assuming you haven't solved your problem already.