Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

denis-cto
Copy link

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

…like site.com/bot/viber) or multiple bots (like site.com/bot/1 and site.com/bot/2)
…like site.com/bot/viber) or multiple bots (like site.com/bot/1 and site.com/bot/2)
@totoantonio
Copy link

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

@Alik333
Copy link

Alik333 commented Feb 9, 2018

475d95a18527d031-2056bad74bf56c67-144894bb39a75714

@dtorov
Copy link

dtorov commented Oct 11, 2018

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants