@@ -72,7 +72,7 @@ app.intent('Card Pin', (conv, {number}) => {
72
72
73
73
74
74
app . intent ( 'Lock Card' , ( conv ) => {
75
- var fraud = 'You can call 8608178983 if you want to report a fraud. '
75
+ var fraud = 'You can call (860)-817-8983 if you want to report a fraud. '
76
76
var response = '' ;
77
77
if ( cardChecked === false ) {
78
78
response = 'Please say the last four digits of your card. ' ;
@@ -112,39 +112,34 @@ app.intent('Unlock Card', (conv) => {
112
112
113
113
114
114
app . intent ( 'Search Transaction' , ( conv , { Product} ) => {
115
+
115
116
if ( cardChecked === false ) {
116
117
conv . ask ( 'Please say the last four digits of your card first. ' ) ;
117
118
return null ;
118
119
} else if ( pinConfirmed === false ) {
119
120
conv . ask ( 'You cannot search transaction before entering the pin! Please say the pin number of your card first. ' ) ;
120
121
} else if ( currentCardLocked ) {
121
- conv . ask ( 'You card ending in ' + currentCardNum . toString ( ) + ' is locked. Please unlock your card first to search your transaction. ' ) ;
122
+ conv . ask ( 'You card ending in ' + currentCardNum . toString ( ) + ' is locked. Please unlock your card first, to search your transaction. ' ) ;
122
123
} else {
124
+ var totalSpending = 0 ;
123
125
const theProduct = Product . toLowerCase ( )
124
126
const currRef = dbRef . doc ( currentCardNum . toString ( ) ) . collection ( 'Transactions' ) ;
125
127
var theResponse = '' ;
126
128
return currRef . where ( 'Item' , '==' , theProduct ) . get ( )
127
129
. then ( ( snapshot ) => {
128
130
if ( snapshot . empty ) {
129
- conv . ask ( 'Hmm. It looks like there are no recent purchases on ' + theProduct + '. ' ) ;
130
- conv . ask ( 'Anything else you need?' ) ;
131
+ conv . ask ( 'Hmm. It looks like there are no recent purchases on ' + theProduct + '. Anything else you need? ' ) ;
131
132
return null ;
132
133
}
133
134
134
- var totalSpending = 0 ;
135
-
136
- snapshot . forEach ( doc => {
137
- const { Date, Item, Price, Timestamp} = doc . data ( ) ;
138
- totalSpending += Price ;
139
- } ) ;
140
- conv . ask ( 'You spent $' + totalSpending + ' on ' + Product + '. ' ) ;
141
135
142
136
snapshot . forEach ( doc => {
143
137
const { Date, Item, Price, Timestamp} = doc . data ( ) ;
138
+ totalSpending = totalSpending + Price ;
144
139
theResponse = theResponse + 'There was a transaction on ' + Date + ' for $' + Price + '. ' ;
145
140
} ) ;
146
-
147
- theResponse = theResponse + 'Anything else you need help with?' ;
141
+ var totalSpent = 'You spent $' + totalSpending + ' on ' + Product + '. ' ;
142
+ theResponse = totalSpent + theResponse + ' Anything else you need help with?' ;
148
143
conv . ask ( theResponse ) ;
149
144
return null ;
150
145
} ) . catch ( ( e ) => {
@@ -162,7 +157,7 @@ app.intent('Current Balance', (conv) => {
162
157
} else if ( pinConfirmed === false ) {
163
158
conv . ask ( 'You cannot check your balance before entering the pin! Please say the pin number of your card first. ' ) ;
164
159
} else if ( currentCardLocked ) {
165
- conv . ask ( 'You card ending in ' + currentCardNum . toString ( ) + ' is locked. Please unlock your card first to check your balance. ' ) ;
160
+ conv . ask ( 'You card ending in ' + currentCardNum . toString ( ) + ' is locked. Please unlock your card first, to check your balance. ' ) ;
166
161
} else {
167
162
if ( currentBalance . toString ( ) !== '' ) {
168
163
conv . ask ( 'You owe $' + currentBalance . toString ( ) + '. What would you like to do' + currentName + '?' ) ;
@@ -179,7 +174,7 @@ app.intent('SearchByDate', (conv, {theNumber, DateString}) => {
179
174
} else if ( pinConfirmed === false ) {
180
175
conv . ask ( 'You cannot check your balance before entering the pin! Please say the pin number of your card first. ' ) ;
181
176
} else if ( currentCardLocked ) {
182
- conv . ask ( 'You card ending in ' + currentCardNum . toString ( ) + ' is locked. Please unlock your card first to check your transactions. ' ) ;
177
+ conv . ask ( 'You card ending in ' + currentCardNum . toString ( ) + ' is locked. Please unlock your card first, to check your transactions. ' ) ;
183
178
} else {
184
179
var today = new Date ( ) ;
185
180
var currTimeStamp = Math . round ( ( new Date ( ) ) . getTime ( ) / 1000 ) ;
@@ -217,7 +212,6 @@ app.intent('SearchByDate', (conv, {theNumber, DateString}) => {
217
212
. then ( ( snapshot ) => {
218
213
if ( snapshot . empty ) {
219
214
conv . ask ( 'The card ending in ' + currentCardNum . toString ( ) + ' has no transactions in that timeframe. ' ) ;
220
- conv . ask ( 'What else would you like to do?' ) ;
221
215
return null ;
222
216
}
223
217
@@ -248,14 +242,14 @@ app.intent('Change Pin', (conv, {theNumber}) => {
248
242
} else if ( pinConfirmed === false ) {
249
243
response = 'You cannot change your pin before entering the current one! Please say the pin number of your card first. ' ;
250
244
} else if ( currentCardLocked ) {
251
- response = 'You card ending in ' + currentCardNum . toString ( ) + ' is locked. Please unlock your card first to change your pin. ' ;
245
+ response = 'You card ending in ' + currentCardNum . toString ( ) + ' is locked. Please unlock your card first, to change your pin. ' ;
252
246
} else {
253
247
const currRef = dbRef . doc ( currentCardNum . toString ( ) ) ;
254
248
if ( theNumber . toString ( ) !== '' ) {
255
249
var updateSingle = currRef . update ( { cardPin : theNumber . toString ( ) } ) ;
256
250
response = 'Your pin has been changed to ' + theNumber . toString ( ) + '. Is there anything else you need' + currentName + '?' ;
257
251
} else {
258
- response = "Oops, sorry I didn't get that! Please try again . " ;
252
+ response = "Oops, sorry I didn't get that! Please say something like 'Change pin to 1234' . " ;
259
253
}
260
254
}
261
255
conv . ask ( response ) ;
@@ -271,11 +265,11 @@ app.intent('Make Payment', (conv, {number})=> {
271
265
} else if ( pinConfirmed === false ) {
272
266
response = 'You cannot make a payment without saying your cards PIN! Please say the PIN number of your card.' ;
273
267
} else if ( currentCardLocked ) {
274
- response = 'You card ending in ' + currentCardNum . toString ( ) + ' is locked. Please unlock your card first to make a payment. ' ;
268
+ response = 'You card ending in ' + currentCardNum . toString ( ) + ' is locked. Please unlock your card first, to make a payment. ' ;
275
269
} else if ( number !== '' ) {
276
270
const currRef = dbRef . doc ( currentCardNum . toString ( ) ) ;
277
- const minPay = String ( min ( 25 , currentBalance ) ) ;
278
- response = 'Your total balance is $' + String ( currentBalance ) + '. Your minimum payment is $' + minPay + '. ' ;
271
+ var minPay = Math . min ( 25 , currentBalance ) ;
272
+ response = 'Your total balance is $' + String ( currentBalance ) + '. Your minimum payment is $' + String ( minPay ) + '. ' ;
279
273
const amountPaid = number . toString ( ) ;
280
274
var newBal = Number ( currentBalance ) - Number ( number ) ;
281
275
newBal = newBal . toFixed ( 2 ) ;
@@ -301,7 +295,7 @@ app.intent('Help', (conv, {Help_input})=> {
301
295
" I'm always here to answer your questions, help you stay on top of your finances and make everyday baking easier.. " ;
302
296
}
303
297
response = response + 'I can help with things like making a payment, checking your balance, locking or unlocking your card, or checking your past transactions. ' ;
304
- response = response + "You can say 'pay my bill' to make a payment or 'How much I spent on gas?' to check your recent gas purchases. " ;
298
+ response = response + "You can say something like 'pay my bill' to make a payment or 'How much I spent on gas?' to check your recent gas purchases. " ;
305
299
response = response + 'What would you like to do' + currentName + '?' ;
306
300
conv . ask ( response ) ;
307
301
} ) ;
0 commit comments