-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dialog_Flow_Code.txt
680 lines (609 loc) · 19.9 KB
/
Dialog_Flow_Code.txt
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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
global.arr.push(word);
agent.add(global.arr);
return axios.get(`https://api.datamuse.com/words?rel_rhy=${word}`)
.then((result)=>{
result.data.map(wordobj=>{
agent.add(wordobj.word);
});
});
function handlePermission(agent){
//agent.add(global.name);
//agent.add(global.email);
axios.post(' ',{
symptoms : ['Belly pain'],
name : 'Default name',
email : 'default email',
phone : '+917014280843'
})
.then(function (response) {
console.log(response);
agent.add(response);
})
.catch(function (error) {
console.log(error);
agent.add(error);
});
}
axios.post('http://134.119.194.12:5000/disease/')
.then(function (response) {
console.log(response);
agent.add(response);
})
.catch(function (error) {
console.log(error);
agent.add(error);
});
axios.post('http://134.119.194.12:5000/disease/',{
headers: {
'Content-Type': 'text/plain'
},
symptoms : ['Belly pain'],
name : 'Default name',
email : 'default email',
phone : '+917014280843'
})
.then(function (response) {
console.log(response);
agent.add(response);
})
.catch(function (error) {
console.log(error);
agent.add(error);
});
sufyan
axios.post('http://134.119.194.12:5000/disease/',{
Symptoms : ['back pain'],
Name : 'Deepak',
Email : '[email protected]',
Phone : '+919128389121'
});
agent.add(global.name_main);
agent.add(global.email_main);
agent.add(global.phone_number_main);
'use strict';
const axios = require('axios');
const functions = require('firebase-functions');
const admin=require('firebase-admin');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
admin.initializeApp(functions.config().firebase);
var db=admin.firestore();
global.name_main='';
global.email_main='';
global.phone_number_main='';
global.Symp_Item=[];
global.arr = [];
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
function rymingwordhandler(agent){
const word =agent.parameters.word;
agent.add(`Here are the rhyming word for ${word}`);
}
function welcome(agent) {
agent.add(`Welcome to my agent!`);
}
function fallback(agent) {
agent.add(`I didn't understand`);
agent.add(`I'm sorry, can you try again?`);
}
function handleReadFromDB(agent){
return admin.database().ref('data').once('value').then((snapshot)=> {
const value_symp = snapshot.child('symptoms').val();
const value_name = snapshot.child('Name').val();
if(value_symp!==null){
agent.add(`You Have Entered your Symptoms as ${value_symp}`);
}
if(value_name!==null){
agent.add(`Your Name is ${value_name}`);
}
});
}
function handlemedical(agent){
global.name_main=agent.parameters.name;
global.email_main=agent.parameters.email;
global.phone_number_main=agent.parameters.number;
}
function handlebackpain(agent){
global.Symp_Item.push('back pain');
}
function handlemildfever(agent){
global.Symp_Item.push('mild fever');
}
function handleCramps(agent){
global.Symp_Item.push('cramps');
}
function handleBruising(agent){
global.Symp_Item.push('Bruising');
}
function handleObesity(agent){
global.Symp_Item.push('obesity');
}
function handlebellypain(agent){
global.Symp_Item.push('belly Pain');
}
function handleitching(agent){
global.Symp_Item.push('ithcing');
}
function handleskin_rash(agent){
global.Symp_Item.push('skin rash');
}
function handlenodal_skin_eruptions(agent){
global.Symp_Item.push('nodal skin eruptions');
}
function handlecontinuous_sneezing(agent){
global.Symp_Item.push('continuous sneezing');
}
function handleshivering(agent){
global.Symp_Item.push('shivering');
}
function handlejoint_pain(agent){
global.Symp_Item.push('joint pain');
}
function handlestomach_pain(agent){
global.Symp_Item.push('stomach pain');
}
function handleacidity(agent){
global.Symp_Item.push('acidity');
}
function handleulcers_on_tongue(agent){
global.Symp_Item.push('ulcers on tongue');
}
function handlemuscle_wasting(agent){
global.Symp_Item.push('muscle wasting');
}
function handlevomiting(agent){
global.Symp_Item.push('vomiting');
}
function handleburning_micturition(agent){
global.Symp_Item.push('burning micturition');
}
function handlespotting_urination(agent){
global.Symp_Item.push('spotting urination');
}
function handlefatigue(agent){
global.Symp_Item.push('fatigue');
}
function handleweight_gain(agent){
global.Symp_Item.push('weight gain');
}
function handleanxiety(agent){
global.Symp_Item.push('anxiety');
}
function handlecold_hands_and_feets(agent){
global.Symp_Item.push('cold hands and feets');
}
function handlemood_swings(agent){
global.Symp_Item.push('mood swings');
}
function handleweight_loss(agent){
global.Symp_Item.push('weight loss');
}
function handlerestlessness(agent){
global.Symp_Item.push('restlessness');
}
function handlelethargy(agent){
global.Symp_Item.push('lethargy');
}
function handlepatches_in_throat(agent){
global.Symp_Item.push('patches in throat');
}
function handleirregular_sugar_level(agent){
global.Symp_Item.push('irregular sugar level');
}
function handlecough(agent){
global.Symp_Item.push('cough');
}
function handlehigh_fever(agent){
global.Symp_Item.push('high fever');
}
function handlesunken_eyes(agent){
global.Symp_Item.push('sunken eyes');
}
function handlebreathlessness(agent){
global.Symp_Item.push('breathlessness');
}
function handlesweating(agent){
global.Symp_Item.push('sweating');
}
function handledehydration(agent){
global.Symp_Item.push('dehydration');
}
function handleindigestion(agent){
global.Symp_Item.push('indigestion');
}
function handleheadache(agent){
global.Symp_Item.push('headache');
}
function handleyellowish_skin(agent){
global.Symp_Item.push('yellowish skin');
}
function handledark_urine(agent){
global.Symp_Item.push('dark urine');
}
function handlenausea(agent){
global.Symp_Item.push('nausea');
}
function handleloss_of_appetite(agent){
global.Symp_Item.push('loss of appetite');
}
function handlepain_behind_the_eyes(agent){
global.Symp_Item.push('pain behind the eyes');
}
function handleconstipation(agent){
global.Symp_Item.push('constipation');
}
function handleabdominal_pain(agent){
global.Symp_Item.push('abdominal pain');
}
function handlediarrhea(agent){
global.Symp_Item.push('diarrhea');
}
function handleyellow_urine(agent){
global.Symp_Item.push('yellow urine');
}
function handleyellowing_of_eyes(agent){
global.Symp_Item.push('yellowing of eyes');
}
function handleacute_liver_failure(agent){
global.Symp_Item.push('acute liver failure');
}
function handlefluid_overload(agent){
global.Symp_Item.push('fluid overload');
}
function handleswelling_of_stomach(agent){
global.Symp_Item.push('swelling of stomach');
}
function handleswelled_lymph_nodes(agent){
global.Symp_Item.push('swelled lymph nodes');
}
function handlemalaise(agent){
global.Symp_Item.push('malaise');
}
function handleblurred_and_distorted_vision(agent){
global.Symp_Item.push('blurred and distorted vision');
}
function handlephlegm(agent){
global.Symp_Item.push('phlegm');
}
function handlethroat_irritation(agent){
global.Symp_Item.push('throat irritation');
}
function handleredness_of_eyes(agent){
global.Symp_Item.push('redness of eyes');
}
function handlesinus_pressure(agent){
global.Symp_Item.push('sinus pressure');
}
function handlerunny_nose(agent){
global.Symp_Item.push('runny nose');
}
function handlecongestion(agent){
global.Symp_Item.push('congestion');
}
function handlechest_pain(agent){
global.Symp_Item.push('chest pain');
}
function handleweakness_in_limbs(agent){
global.Symp_Item.push('weakness in limbs');
}
function handlefast_heart_rate(agent){
global.Symp_Item.push('fast heart rate');
}
function handlepain_during_bowel_movements(agent){
global.Symp_Item.push('pain during bowel movements');
}
function handlepain_in_anal_region(agent){
global.Symp_Item.push('pain in anal region');
}
function handlebloody_stool(agent){
global.Symp_Item.push('bloody stool');
}
function handleirritation_in_anus(agent){
global.Symp_Item.push('irritation in anus');
}
function handleneck_pain(agent){
global.Symp_Item.push('neck pain');
}
function handleswollen_legs(agent){
global.Symp_Item.push('swollen legs');
}
function handleswollen_blood_vessels(agent){
global.Symp_Item.push('swollen blood vessels');
}
function handlepuffy_face_and_eyes(agent){
global.Symp_Item.push('puffy face and eyes');
}
function handleenlarged_thyroid(agent){
global.Symp_Item.push('enlarged thyroid');
}
function handlebrittle_nails(agent){
global.Symp_Item.push('brittle nails');
}
function handleswollen_extremeties(agent){
global.Symp_Item.push('swollen extremeties');
}
function handledrying_and_tingling_lips(agent){
global.Symp_Item.push('drying and tingling lips');
}
function handleslurred_speech(agent){
global.Symp_Item.push('slurred speech');
}
function handleknee_pain(agent){
global.Symp_Item.push('knee pain');
}
function handlehip_joint_pain(agent){
global.Symp_Item.push('hip joint pain');
}
function handlemuscle_weakness(agent){
global.Symp_Item.push('muscle weakness');
}
function handlestiff_neck(agent){
global.Symp_Item.push('stiff neck');
}
function handleswelling_joints(agent){
global.Symp_Item.push('swelling joints');
}
function handlemovement_stiffness(agent){
global.Symp_Item.push('movement stiffness');
}
function handlespinning_movements(agent){
global.Symp_Item.push('spinning movements');
}
function handleloss_of_balance(agent){
global.Symp_Item.push('loss of balance');
}
function handleunsteadiness(agent){
global.Symp_Item.push('unsteadiness');
}
function handleweakness_of_one_body_side(agent){
global.Symp_Item.push('weakness of one body side');
}
function handleloss_of_smell(agent){
global.Symp_Item.push('loss of smell');
}
function handlebladder_discomfort(agent){
global.Symp_Item.push('bladder discomfort');
}
function handlefoul_smell_of_urine(agent){
global.Symp_Item.push('foul smell of urine');
}
function handlecontinuous_feel_of_urine(agent){
global.Symp_Item.push('continuous feel of urine');
}
function handlepassage_of_gases(agent){
global.Symp_Item.push('passage of gases');
}
function handleinternal_itching(agent){
global.Symp_Item.push('internal itching');
}
function handletoxic_look(agent){
global.Symp_Item.push('toxic look (typhus)');
}
function handledepression(agent){
global.Symp_Item.push('depression');
}
function handleirritability(agent){
global.Symp_Item.push('irritability');
}
function handlemuscle_pain(agent){
global.Symp_Item.push('muscle pain');
}
function handlealtered_sensorium(agent){
global.Symp_Item.push('altered sensorium');
}
function handleabnormal_menstruation(agent){
global.Symp_Item.push('abnormal menstruation');
}
function handledyschromic_patches(agent){
global.Symp_Item.push('dyschromic patches');
}
function handlewatering_from_eyes(agent){
global.Symp_Item.push('watering from eyes');
}
function handleincreased_appetite(agent){
global.Symp_Item.push('increased appetite');
}
function handlepolyuria(agent){
global.Symp_Item.push('polyuria');
}
function handlemucoid_sputum(agent){
global.Symp_Item.push('mucoid sputum');
}
function handlerusty_sputum(agent){
global.Symp_Item.push('rusty sputum');
}
function handlelack_of_concentration(agent){
global.Symp_Item.push('lack of concentration');
}
function handlevisual_disturbances(agent){
global.Symp_Item.push('visual disturbances');
}
function handlereceiving_blood_transfusion(agent){
global.Symp_Item.push('receiving blood transfusion');
}
function handlereceiving_unsterile_injections(agent){
global.Symp_Item.push('receiving unsterile injections');
}
function handlecoma(agent){
global.Symp_Item.push('coma');
}
function handlestomach_bleeding(agent){
global.Symp_Item.push('stomach bleeding');
}
function handledistention_of_abdomen(agent){
global.Symp_Item.push('distention of abdomen');
}
function handleblood_in_sputum(agent){
global.Symp_Item.push('blood in sputum');
}
function handleprominent_veins_on_calf(agent){
global.Symp_Item.push('prominent veins on calf');
}
function handlepalpitations(agent){
global.Symp_Item.push('palpitations');
}
function handlepainful_walking(agent){
global.Symp_Item.push('painful walking');
}
function handlepus_filled_pimples(agent){
global.Symp_Item.push('pus filled pimples');
}function handleblackheads(agent){
global.Symp_Item.push('blackheads');
}
function handlescurring(agent){
global.Symp_Item.push('scurring');
}
function handleskin_peeling(agent){
global.Symp_Item.push('skin peeling');
}
function handlesilver_like_dusting(agent){
global.Symp_Item.push('silver like dusting');
}
function handlesmall_dents_in_nails(agent){
global.Symp_Item.push('small dents in nails');
}
function handleinflammatory_nails(agent){
global.Symp_Item.push('inflammatory nails');
}
function handleblister(agent){
global.Symp_Item.push('blister');
}
function handlered_sore_around_nose(agent){
global.Symp_Item.push('red sore around nose');
}
function handleyellow_crust_ooze(agent){
global.Symp_Item.push('yellow crust ooze');
}
function handlechills(agent){
global.Symp_Item.push('chills');
}
function handleulcer_on_tongue(agent){
global.Symp_Item.push('ulcer_on_tongue');
}
function handledizziness(agent){
global.Symp_Item.push('dizziness');
}
function handlePermission(agent){
axios({
method: 'post',
url: 'http://134.119.194.12:5000/disease/',
data:
{
"symptoms" : global.Symp_Item,
"name" : global.name_main,
"email" : global.email_main,
"phone" : global.phone_number_main
},
headers: {
"content-type": "application/json"
}
}).then(function (response) {
//agent.add(`${global.name_main} you have Submitted Symptoms as-> ${global.Symp_Item}`);
var dis = response.data.prediction[0];
var accuracy = response.data.prediction[1];
console.log("Disease Predicted ->",dis);
agent.add("disease is ", dis);
console.log("Confidence ->",accuracy);
agent.add("confidance is",accuracy);
}).catch(function (error) {
console.log("Error ->",error);
});
global.Symp_Item=[];
}
let intentMap = new Map();
intentMap.set('RhymingWord', rymingwordhandler);
intentMap.set('Default Welcome Intent', welcome);
intentMap.set('Default Fallback Intent', fallback);
intentMap.set('ReadFromDB', handleReadFromDB);
intentMap.set('Permission',handlePermission);
intentMap.set('Back_Pain',handlebackpain);
intentMap.set('mild_fever',handlemildfever);
intentMap.set('Cramps',handleCramps);
intentMap.set('Bruising',handleBruising);
intentMap.set('Obesity',handleObesity);
intentMap.set('belly_pain',handlebellypain);
intentMap.set('itching',handleitching);
intentMap.set('skin_rash',handleskin_rash);
intentMap.set('nodal_skin_eruptions',handlenodal_skin_eruptions);
intentMap.set('continuous_sneezing',handlecontinuous_sneezing);
intentMap.set('shivering',handleshivering);
intentMap.set('chills',handlechills);
intentMap.set('joint_pain',handlejoint_pain);
intentMap.set('stomach_pain',handlestomach_pain);
intentMap.set('acidity',handleacidity);
intentMap.set('ulcer_on_tongue',handleulcer_on_tongue);
intentMap.set('muscle_wasting',handlemuscle_wasting);
intentMap.set('vomiting',handlevomiting);
intentMap.set('burning_micturition',handleburning_micturition);
intentMap.set('spotting_urination',handlespotting_urination);
intentMap.set('fatigue',handlefatigue);
intentMap.set('weight_gain',handleweight_gain);
intentMap.set('anxiety',handleanxiety);
intentMap.set('cold_hands_and_feets',handlecold_hands_and_feets);
intentMap.set('mood_swings',handlemood_swings);
intentMap.set('weight_loss',handleweight_loss);
intentMap.set('restlessness',handlerestlessness);
intentMap.set('lethargy',handlelethargy);
intentMap.set('patches_in_throat',handlepatches_in_throat);
intentMap.set('irregular_sugar_level',handleirregular_sugar_level);
intentMap.set('cough',handlecough);
intentMap.set('high_fever',handlehigh_fever);
intentMap.set('sunken_eyes',handlesunken_eyes);
intentMap.set('breathlessness',handlebreathlessness);
intentMap.set('sweating',handlesweating);
intentMap.set('dehydration',handledehydration);
intentMap.set('indigestion',handleindigestion);intentMap.set('headache',handleheadache);
intentMap.set('yellowish_skin',handleyellowish_skin);
intentMap.set('dark_urine',handledark_urine);
intentMap.set('nausea',handlenausea);
intentMap.set('loss_of_appetite',handleloss_of_appetite);
intentMap.set('pain_behind_the_eyes',handlepain_behind_the_eyes);
intentMap.set('constipation',handleconstipation);
intentMap.set('abdominal_pain',handleabdominal_pain);
intentMap.set('diarrhea',handlediarrhea);
intentMap.set('yellow_urine',handleyellow_urine);
intentMap.set('yellowing_of_eyes',handleyellowing_of_eyes);
intentMap.set('acute_liver_failure',handleacute_liver_failure);
intentMap.set('fluid_overload',handlefluid_overload);
intentMap.set('swelling_of_stomach',handleswelling_of_stomach);
intentMap.set('swelled_lymph_nodes',handleswelled_lymph_nodes);
intentMap.set('malaise',handlemalaise);
intentMap.set('chest_pain',handlechest_pain);
intentMap.set('blurred_and_distorted_vision',handleblurred_and_distorted_vision);
intentMap.set('phlegm',handlephlegm);
intentMap.set('throat_irritation',handlethroat_irritation);
intentMap.set('redness_of_eyes',handleredness_of_eyes);
intentMap.set('sinus_pressure',handlesinus_pressure);
intentMap.set('runny_nose',handlerunny_nose);
intentMap.set('congestion',handlecongestion);
intentMap.set('weakness_in_limbs',handleweakness_in_limbs);
intentMap.set('fast_heart_rate',handlefast_heart_rate);
intentMap.set('pain_during_bowel_movements',handlepain_during_bowel_movements);
intentMap.set('pain_in_anal_region',handlepain_in_anal_region);
intentMap.set('bloody_stool',handlebloody_stool);
intentMap.set('irritation_in_anus',handleirritation_in_anus);
intentMap.set('neck_pain',handleneck_pain);
intentMap.set('dizziness',handledizziness);
intentMap.set('swollen_legs',handleswollen_legs);
intentMap.set('swollen_blood_vessels',handleswollen_blood_vessels);
intentMap.set('puffy_face_and_eyes',handlepuffy_face_and_eyes);
intentMap.set('enlarged_thyroid',handleenlarged_thyroid);
intentMap.set('brittle_nails',handlebrittle_nails);
intentMap.set('swollen_extremeties',handleswollen_extremeties);
intentMap.set('drying_and_tingling_lips',handledrying_and_tingling_lips);
intentMap.set('slurred_speech',handleslurred_speech);
intentMap.set('knee_pain',handleknee_pain);
intentMap.set('hip_joint_pain',handlehip_joint_pain);
intentMap.set('muscle_weakness',handlemuscle_weakness);
intentMap.set('stiff_neck',handlestiff_neck);
intentMap.set('swelling_joints',handleswelling_joints);
intentMap.set('movement_stiffness',handlemovement_stiffness);
intentMap.set('spinning_movements',handlespinning_movements);
intentMap.set('loss_of_balance',handleloss_of_balance);
intentMap.set('unsteadiness',handleunsteadiness);
intentMap.set('weakness_of_one_body_side',handleweakness_of_one_body_side);
intentMap.set('loss_of_smell',handleloss_of_smell);
intentMap.set('bladder_discomfort',handlebladder_discomfort);