-
Notifications
You must be signed in to change notification settings - Fork 332
/
index.js
35 lines (30 loc) · 836 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const { ViberBot, ViberHandler } = require('bottender');
const { createServer } = require('bottender/express');
const config = require('./bottender.config').viber;
const bot = new ViberBot({
accessToken: config.accessToken,
});
const handler = new ViberHandler()
.onDelivered(() => {
console.log('delivered');
})
.onSeen(() => {
console.log('seen');
})
.onFailed(() => {
console.log('failed');
})
.onText(/yo/i, async context => {
await context.sendText('Hi there!');
})
.onEvent(async context => {
await context.sendText("I don't know what you say.");
})
.onError(async context => {
await context.sendText('Something wrong happened.');
});
bot.onEvent(handler);
const server = createServer(bot);
server.listen(5000, () => {
console.log('server is running on 5000 port...');
});