1

I am giving hubot a go to be integrated with slack to act as a helpdesk.

The script (coffeescript) so far looks out for keywords, if the keywords don't exist then I need the hubot to return something like 'Sorry I can't find what you are looking for'.

Below is an example of the keyword query;

module.exports = (robot) ->
  robot.hear /ansible/i, (res) ->
     res.send "Hi, for all ansible related querys, please go to 
     www.github.com/ansible/ansiblehelp"

So for example is ansible is not in the question, the hubot needs to reply with 'Sorry I can't find what you are looking for'.

Is this possible?

Thanks

CPdev
  • 375
  • 2
  • 5
  • 20

1 Answers1

0

Try a catchAll clause to provide a default response:

module.exports = (robot) ->
  robot.catchAll (msg) ->
    if msg.message.match /// ^#{robot.name}\s ///
        msg.reply "Sorry I can't find what you are looking for"

Answer source

Similar answer

Adil B
  • 14,635
  • 11
  • 60
  • 78
  • Thanks. Tried that but it is throwing the below error; error: unexpected if if msg.message.match /// ^#{myhubot}\s /// – CPdev Aug 02 '18 at 09:38
  • Take a look at this example as well: https://github.com/hassaku/hubot-suggest/blob/636f59b8d81407e3dae0048ade326bb6e02980c3/scripts/suggest.coffee#L64-L70 – Adil B Aug 02 '18 at 16:46