viber-bot-node icon indicating copy to clipboard operation
viber-bot-node copied to clipboard

Added "path" to config, to run bot on non-root URLS and run multiple bots on same site

Open denis-cto opened this issue 8 years ago • 3 comments

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'
});

denis-cto avatar Oct 11 '17 10:10 denis-cto

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}), ));

totoantonio avatar Nov 04 '17 11:11 totoantonio

475d95a18527d031-2056bad74bf56c67-144894bb39a75714

Alik333 avatar Feb 09 '18 12:02 Alik333

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?

dtorov avatar Oct 11 '18 08:10 dtorov