-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbottender.config.js
90 lines (83 loc) · 2.08 KB
/
bottender.config.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
const { withTyping } = require('bottender');
const { getStarted } = require('./app/utils/flow');
const messageWaiting = eval(process.env.WITH_TYPING); // eslint-disable-line no-eval
const { getPoliticianData } = require('./app/chatbot_api');
const mapPageToAccessToken = async (pageId) => {
const perfilData = await getPoliticianData(pageId);
return perfilData && perfilData.fb_access_token ? perfilData.fb_access_token : process.env.MESSENGER_ACCESS_TOKEN;
};
module.exports = {
channels: {
// whatsapp: {
// enabled: true,
// path: '/webhooks/whatsapp',
// accountSid: process.env.ACCOUNT_SID,
// authToken: process.env.AUTH_TOKEN,
// phoneNumber: process.env.PHONE_NUMBER,
// },
// telegram: {
// enabled: true,
// path: '/webhooks/telegram',
// accessToken: process.env.TELEGRAM_ACCESS_TOKEN,
// },
messenger: {
enabled: true,
path: '/webhooks/messenger',
pageId: process.env.MESSENGER_PAGE_ID,
accessToken: process.env.MESSENGER_ACCESS_TOKEN,
appId: process.env.MESSENGER_APP_ID,
appSecret: process.env.MESSENGER_APP_SECRET,
verifyToken: process.env.MESSENGER_VERIFY_TOKEN,
mapPageToAccessToken,
profile: {
getStarted: {
payload: 'greetings',
},
greeting: [
{
locale: 'default',
text: getStarted,
},
],
persistentMenu: [
{
locale: 'default',
composerInputDisabled: false,
callToActions: [
{
type: 'postback',
title: 'Ir para o início',
payload: 'greetings',
},
{
type: 'nested',
title: 'Notificações 🔔',
call_to_actions: [
{
type: 'postback',
title: 'Ligar Notificações 👌',
payload: 'notificationOn',
},
{
type: 'postback',
title: 'Parar Notificações 🛑',
payload: 'notificationOff',
},
],
},
],
},
],
},
},
},
session: {
driver: 'file',
stores: {
file: {
dirname: '.sessions',
},
},
},
plugins: [withTyping({ delay: messageWaiting || 0 })],
};