-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathformatter.js
55 lines (52 loc) · 1.16 KB
/
formatter.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
/* module imports */
exports.formatMsg = msg => ({
type: 'text',
content: msg,
})
exports.formatQuickReplies = (quickRp, res) => {
const elements = []
quickRp.forEach((elem) => {
elements.push({
title: elem.name,
value: elem.value,
})
})
return {
type: 'quickReplies',
content: {
title: `More information regarding ${res.value}`,
buttons: elements,
},
}
}
exports.formatCardsReplies = (cards) => {
const elements = []
cards.forEach((c) => {
elements.push({
title: c.name,
subtitle: c.city,
imageUrl: c.picture,
buttons: [
{
type: 'web_url',
title: 'More Information',
value: c.link,
},
{
type: 'postback',
title: c.register.rsvp === 'yes' ? 'RSVP' : 'Unregister',
value: JSON.stringify({
text: c.register.rsvp === 'yes' ? 'I want to RSPV for this meetup' : 'I want to unsubscribe',
groupurl: c.register.groupurl,
id: c.register.id,
rsvp: c.register.rsvp,
}),
},
],
})
})
return {
type: 'carouselle',
content: elements,
}
}