Hey everyone!
I hope I’m in the right category here to ask this question. If not, feel free to tell me to move my thread.
I’m currently testing out bbot. Installed it and a rocket.chat server locally. I followed this ( Introducing bBot | Get started with chatbots and conversational apps - YouTube ) to set it up.
I’m having an issue when trying to chat with the bot. I’m trying to have multiple bot.global.direct(something something) in my index.js, but whenever I try to access any of them, only the first one mentioned in the code works. I tried force: true as an option, but it didn’t seem to work. My guess would be that the bot jumps into the first one, because it is called with his name, checks the condition, realizes he shouldn’t answer and then skips the rest of the direct conditions… bot.global.text works as expected unless i start the message with the name of the bot, then it doesn’t respond either.
Is this expected behaviour or am I doing something wrong?
My code looks roughly like this:
const bot = require('bbot')
const spawn = require("child_process").spawn;
bot.global.direct(/\b((hi|hola|hello|hey))\b/i, (b) => b.respond(`Hey ${b.message.user.name}`), {
id: 'hello-user'
})
bot.global.direct(/\b(?<=ip )([^?]*)\b/i, (b) => {
userName = b.message.user.name
capturedHost = b.conditions.captured
pythonProcess = spawn('python',["/home/onnsn/demo/simpleReturn.py", capturedHost])
pythonProcess.stdout.on('data', (data) => {
b.respond(`Hey ${userName}!\n` + capturedHost + ': ' + data)
})
}, {
id: 'Simple-Return', force: true
})
bot.global.direct(/\b(spalarm)\b/i, (b) => {
userName = b.message.user.name
pythonProcess = spawn('python',["/home/onnsn/demo/Orchestrator.py"])
pythonProcess.stdout.on('data', (data) => {
b.respond(`Hey ${userName}!\n` + data)
})
}, {
id: 'Sp-Alarm'
})
bot.start()
Any help or tips on how to tackle this issue would be greatly appreciated.