Added "path" to config, to run bot on non-root URLS and run multiple bots on same site
If you need the bot to be run on non-root URL, for example www.site.com/mybot/runhere or if you want run multiple bots on the same site, for example www.site.com/bots/01, www.site.com/bots/02, www.site.com/bots/03, and so on. There is additional configuration option for this: use
const bot = new ViberBot({
authToken: YOUR_AUTH_TOKEN_HERE,
name: "EchoBot",
avatar: "http://viber.com/avatar.jpg",
path: '/mybot/runhere'
});
Can't make keyboard work... I'm no coder so i just followed the instructions and not tweak anything but can't make keyboard to work.. //Sample Location works as well as others except for Keyboard.. What could be the cause?
//Sample Keyboard bot.onTextMessage(/^test|keyboard$/i, (message, response) => response.send ( new KeyboardMessage('SAMPLE_KEYBOARD'), ));
//Sample Location
bot.onTextMessage(/^loc|location$/i, (message, response) =>
response.send (
new LocationMessage('10.315699', '123.885437'),
console.log(${message.latitude}, ${message.longitude}),
));
475d95a18527d031-2056bad74bf56c67-144894bb39a75714
sorry.. can you describe how to use it? const bot1 = new ViberBot({ logger: logger, authToken: '123', name: "123", avatar: "123", path: '/bots/bot1' }); const bot2 = new ViberBot({ logger: logger, authToken: '123', name: "123", avatar: "123", path: '/bots/bot2' });
const webhookUrl1 = 'https://mybotapi.ru:7002/bots/bot1'; const webhookUrl2 = 'https://mybotapi.ru:7002/bots/bot2';
let httpOptions = {};
http.createServer(bot1.middleware()).listen(port, () =>
{
bot1.setWebhook(webhookUrl1).then(() => {
console.log('bot started');
}).catch(err => console.log(err));
}
);
how to start second bot? in my task i need to start and stop bots at any time...
or,maybe, i need some additional middleware? or?