forked from gadgetguy82/euans_guide_chatbot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
questions.js
351 lines (337 loc) · 11.9 KB
/
questions.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
const ratings = [
{
content_type: "text",
title: "1",
payload: "one"
},
{
content_type: "text",
title: "2",
payload: "two"
},
{
content_type: "text",
title: "3",
payload: "three"
},
{
content_type: "text",
title: "4",
payload: "four"
},
{
content_type: "text",
title: "5",
payload: "five"
}
];
function overallResponse(rating, place) {
if (rating < 3)
return "Sorry to hear that, please can you tell us more about " + place + "?\n";
else if (rating == 3)
return "Disabled access at the " + place + " sounds ok - we're looking forward to hearing more!\n";
else
return "That's a great rating! People are going to love reading about " + place + "!\n"
}
function transportResponse(rating) {
if (rating < 3)
return "That doesn't sound great.\n";
else if (rating == 3)
return "That sounds like it could've been better...\n";
else
return "That sounds convenient!\n"
}
function accessResponse(rating) {
if (rating < 3)
return "That's not a good rating...\n";
else if (rating == 3)
return "That sounds like it could've been better...\n";
else
return rating + "* is a great rating!\n"
}
function toiletResponse(rating) {
if (rating < 3)
return "They don't sound very good\n";
else if (rating == 3)
return "The loos sound like they could've been better...\n";
else
return "Wow! They sound great! We'd love to hear some more!\n"
}
function staffResponse(rating) {
if (rating < 4)
return "That's useful to know...\n";
else
return "That's great to know!\n"
}
const infoOrSkip = [
{
content_type: "text",
title: "Add more info",
payload: "add_review"
},
{
content_type: "text",
title: "Skip this question",
payload: "skip_question"
}
];
const skip = [infoOrSkip[1]];
const start = [
{
content_type: "text",
title: "Start a new review",
payload: "review"
},
{
content_type: "text",
title: "Chat to us",
payload: "chat"
}
];
const uploadPhotos = [
{
content_type: "text",
title: "Skip to photo upload",
payload: "skip_question"
},
{
content_type: "text",
title: "Submit my review",
payload: "finish_option_question"
}
]
let show = false;
function changeShowUpload() {
show = !show;
}
function showOrHideUpload() {
return (show ? uploadPhotos : [uploadPhotos[1]]);
}
function getQuestionData(questionKey, place, rating) {
const questionsData = {
"hello": {
text: "Hello! Thanks for clicking get started. Would you like to leave a review or chat to us?",
quick_replies: [
{
content_type: "text",
title: "Review!",
payload: "review"
},
{
content_type: "text",
title: "Chat!",
payload: "chat"
}
]
},
"chat": {
text: "No problem! Leave us a message and we will get back to you as soon as possible!",
quick_replies: [start[0]]
},
"account": {
text: "Thanks for choosing to share your experience with us, this shouldn't take too long!\n" +
"You can abandon the review at any time by typing STOP.\n" +
"Please can you start by telling us if you have a Euan's Guide account",
quick_replies: [
{
content_type: "text",
title: "Yes, I do",
payload: "yes"
},
{
content_type: "text",
title: "No, I do not",
payload: "no"
}
]
},
"username": {text: "Please enter your username or the associated email address so we can add this to your existing reviews."},
"new-user": {text: "Please can you give us a username you would like us to associate with this review so that you can make changes to the review or add additional reviews at a later date from the same account. If the username is already taken we will try to assign you something similar to your request."},
"visited": {text: "Thank you, now on to your review. Please can you tell us the name of the place that you visited?"},
"city": {text: "Ok, great! Can you confirm which town or city " + place + " is in?"},
"image": {
text: "Do you have any photos or images you'd like to upload with your review?\n" +
"By uploading images you agree that you are the creator and owner of the content you upload and that you are happy for the images to be used by Euan’s Guide.",
quick_replies: [
{
content_type: "text",
title: "Upload photos now",
payload: "yes"
},
{
content_type: "text",
title: "Upload photos later",
payload: "no"
},
{
content_type: "text",
title: "No photos to upload",
payload: "no"
}
]
},
"image2": {
text: "Do you have any more images you'd like to share?",
quick_replies: [
{
content_type: "text",
title: "Yes!",
payload: "yes"
},
{
content_type: "text",
title: "No!",
payload: "no"
}
]
},
"upload-image": {text: "Great, to select an image to attach, click on the picture icon in the bottom left corner of the messenger and send it."},
"title": {text: "Thanks! Now, what would you like to title your review? This will be the first thing people will see. \n " +
"An example might be \"Accessible Museum in the heart of London\" or \"Great accessible cafe with delicious cakes!\""},
"overall-rating": {
text: "Great title! \n" +
"\n" +
"Now for a rating... Out of 5, where 5 is great and 1 is bad, how would you rate the disabled access overall?",
quick_replies: ratings
},
"overall-summary": {text: overallResponse(rating, place) + "\nNow could you summarise your experience? \n" +
"\n" +
"Some things you might want to talk about include:\n\n" +
"What did you do there?\n" +
"What did you like about the place? \n" +
"What wasn't quite right? \n" +
"What made it special?"},
"continue-or-finish": {
text: "That's your review nearly complete! \n" +
"\n" +
"Some of our users do like to know some additional information before they visit. This focuses on 4 main areas:\n" +
"\n" +
"1) Getting there \n" +
"2) Getting in and getting around\n" +
"3) Toilets\n" +
"4) Staff\n" +
"\n" +
"These are all optional questions so if you don't have anything else to add then no problem! Would you like to finish and submit your review or add more information?\n" +
"\n" +
"(You can submit your review at any time simply by typing SUBMIT.)",
quick_replies: [
{
content_type: "text",
title: "Add more information",
payload: "continue_option_question"
},
{
content_type: "text",
title: "Finish and submit",
payload: "finish_option_question"
}
]
},
"transport": {
text: "We'll start with getting there. Would you like to add any information on parking or transport?",
quick_replies: infoOrSkip
},
"transport-rating": {
text: "How would you rate the parking and transport options? (Where 5 is great and 1 is bad.)",
quick_replies: ratings
},
"transport-summary": {
text: transportResponse(rating) + "\nCould you give us some more information? Did you drive? If so, where did you park? If you travelled using public transport where was the nearest bus stop or train station?\n" +
"What information would help others most?",
quick_replies: skip
},
"access": {
text: "Thank You! Now onto getting in and around " + place + ". Is there anything specific about Disabled Access you would like to add?",
quick_replies: infoOrSkip
},
"access-rating": {
text: "Ok, great! Let's start with a rating, again out of 5.",
quick_replies: ratings
},
"access-summary": {
text: accessResponse(rating) + "\nWould you be able to give any more detail on what you noticed?\n" +
"\n" +
"For example, do you have any comments on doors or ramps? Were there any lifts? What was the signage like? Were there any steps? Could you see everything you wanted to? Was there an induction loop? Was there any seating so you could stop and take a rest? Were there any alternative formats available such as braille, large print, easy read or BSL?",
quick_replies: skip
},
"toilet": {
text: "Thank you for taking the time to provide additional information on the disabled access at " + place + "!\n" + "\nNow, onto toilets. Our users consistently tell us how important both accessible toilets and information about toilets is. Are you able to tell us anything about the toilets at " + place + "?",
quick_replies: infoOrSkip
},
"toilet-rating": {
text: "Brilliant! We'd love to know more…\n Let's start with a rating…",
quick_replies: ratings
},
"toilet-summary": {
text: toiletResponse(rating) + "\nWould you be able to provide some more detail? Things to mention might include: Was there an accessible loo? How easy was it to find? Was there enough space to manoeuvre? Did it have grab rails? Was it clean and tidy? Was there space for a carer? Do you know if it was a certified Changing Places toilet?",
quick_replies: skip
},
"staff": {
text: "Thank you - that's such important information to share with people.\n" +
"\n" +
"Now we come to staff. Would you like to add any further information about the people you came across at " + place + "?",
quick_replies: infoOrSkip
},
"staff-rating": {
text: " Thank you! This will be the last time we ask you for a rating…",
quick_replies: ratings
},
"staff-summary": {
text: staffResponse(rating) + "\nWould you be able to tell us a bit more about the welcome you received?\n" +
"Was there anyone who particularly who stood out? If so, what did they do to make it a memorable experience?",
quick_replies: skip
},
"anything-else": {
text: "Thank you! That's really useful information!\n" +
"Just one more question now, which is to ask if there's anything else you wish to tell us?",
quick_replies: showOrHideUpload()
},
"image-last": {
text: "Now is your final chance to upload any photos or images you took at " + place + ". Images are an important way of letting people see what a venue is like before they vist.\n" +
"By uploading images you agree that you are the creator and owner of the content you upload and that you are happy for the images to be used by Euan’s Guide.",
quick_replies: [
{
content_type: "text",
title: "Upload photos",
payload: "yes"
},
{
content_type: "text",
title: "Submit my review",
payload: "finish_option_question"
}
]
},
"end": {
text: "Thank you for taking the time to leave your review! We'll send you a message when it has gone live!",
quick_replies: start
},
"stop": {
text: "It looks like you want to stop writing a review. Is that correct? Please confirm what action you’d like to take.",
quick_replies: [
{
content_type: "text",
title: "Continue my review",
payload: "continue"
},
{
content_type: "text",
title: "Submit my review",
payload: "submit"
},
{
content_type: "text",
title: "Abandon my review",
payload: "abandon"
}
]
},
"stop-end": {
text: "Thank you for your time. Is there anything else you’d like to do while you are here?",
quick_replies: start
},
"delete": {text: "Uh oh. Something's went wrong. Try deleting the chat and starting again. Sorry!"}
};
return questionsData[questionKey];
}
module.exports = {getQuestionData, changeShowUpload};