I am developing a facebook messenger bot using hubot & hubot-fb adapter. All the basic setup is done & is working perfectly. But, in order to chat with the bot I need to add hubot with all the commands. In case of facebook chats, it doesn't make much sense. A current chat looks something like this:
user: hubot ping
bot: PONG
user: hubot the rules
bot: 0. A robot may not harm humanity, or, by inaction, allow humanity to come to harm.
1. A robot may not injure a human being or, through inaction, allow a human being to come to harm.
2. A robot must obey any orders given to it by human beings, except where such orders would conflict with the First Law.
3. A robot must p
however, I want my bot to be accessible without using the "hubot" with all the messenges. How do I achieve that?
TIA
You could use the 'hear' method, instead of the 'respond' method.
Hubot has two methods for how it interacts with with messages:
hear - This is called whenever text in a message room matches a given regex. The robot's name is not used in this case. Example:
module.exports = (robot) ->
robot.hear /ping/i, (res) ->
res.send "PONG"
The following messages would cause the robot.hear callback to be called:
Note: the regex in this case is very simplistic and could be modified so the callback is not called for the "how do I ping the server" case.
respond - this is only called when text matches a given regex AND is immediately preceded by the robot's name or alias. Example:
module.exports = (robot) ->
robot.respond /ping/i, (res) ->
res.reply "PONG"
The following messages would cause the robot.respond callback to be called:
It would NOT be called for the following, since the robot's name is not used.
See the Hubot scripting documentation for more details.