From f2ce51c9f3d543896b37fcaaa464385932877a48 Mon Sep 17 00:00:00 2001
From: Navneet Gupta
Date: Sun, 15 May 2022 01:35:12 +0530
Subject: [PATCH 1/3] Initial commit
---
.idea/Covid19-chatbot.iml | 2 +-
.idea/misc.xml | 2 +-
DataRequests/MakeApiRequests.py | 24 ++--
.../MakeApiRequests.cpython-39.pyc | Bin 0 -> 1796 bytes
Procfile | 2 +-
README.md | 10 +-
app.py | 50 ++++---
manifest.yml | 2 +-
requirement.txt | Bin 0 -> 5144 bytes
requirements.txt | Bin 601 -> 5122 bytes
runtime.txt | 2 +-
saveConversation/Conversations.py | 28 ++--
.../__pycache__/Conversations.cpython-39.pyc | Bin 0 -> 1377 bytes
sendEmail/DLM_Template.html | 127 +-----------------
sendEmail/EMailClient.py | 38 +++---
sendEmail/TestMongo.py | 2 -
.../__pycache__/EMailClient.cpython-39.pyc | Bin 0 -> 1601 bytes
.../template_reader.cpython-39.pyc | Bin 0 -> 973 bytes
sendEmail/simple.html | 2 +-
sendEmail/template_reader.py | 10 +-
sendEmail/world.html | 123 +----------------
21 files changed, 90 insertions(+), 334 deletions(-)
create mode 100644 DataRequests/__pycache__/MakeApiRequests.cpython-39.pyc
create mode 100644 requirement.txt
create mode 100644 saveConversation/__pycache__/Conversations.cpython-39.pyc
create mode 100644 sendEmail/__pycache__/EMailClient.cpython-39.pyc
create mode 100644 sendEmail/__pycache__/template_reader.cpython-39.pyc
diff --git a/.idea/Covid19-chatbot.iml b/.idea/Covid19-chatbot.iml
index 5b48ddd..8388dbc 100644
--- a/.idea/Covid19-chatbot.iml
+++ b/.idea/Covid19-chatbot.iml
@@ -2,7 +2,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 90e2a6a..f6104af 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,6 @@
-
+
diff --git a/DataRequests/MakeApiRequests.py b/DataRequests/MakeApiRequests.py
index b86d491..3b16b28 100644
--- a/DataRequests/MakeApiRequests.py
+++ b/DataRequests/MakeApiRequests.py
@@ -1,5 +1,7 @@
import requests
import json
+
+
class Api:
def __init__(self):
pass
@@ -9,7 +11,7 @@ def makeApiRequestForCounrty(self, country_name):
querystring = {"country": country_name}
headers = {
'x-rapidapi-host': "covid-193.p.rapidapi.com",
- 'x-rapidapi-key': "482a8f8516msh16204eb9d1f4f68p1a9146jsnf33914c7300e"
+ 'x-rapidapi-key': "36626c56f2msh8580d29c47aca59p12a368jsnc74c1cdf1888"
}
response = requests.request("GET", url, headers=headers, params=querystring)
# print(response.text)
@@ -18,34 +20,30 @@ def makeApiRequestForCounrty(self, country_name):
result = js.get('response')[0]
print(result.get('cases'))
print("*" * 20)
- return result.get('cases') , result.get('deaths'),result.get('tests')
-
+ return result.get('cases'), result.get('deaths'), result.get('tests')
def makeApiRequestForIndianStates(self):
- url = "https://covid19-data.p.rapidapi.com/india"
+ url = "https://covid-193.p.rapidapi.com/history?country=india&day=2022-04-17"
headers = {
- 'x-rapidapi-host': "covid19-data.p.rapidapi.com",
- 'x-rapidapi-key': "482a8f8516msh16204eb9d1f4f68p1a9146jsnf33914c7300e"
+ 'x-rapidapi-host': "covid-193.p.rapidapi.com",
+ 'x-rapidapi-key': "36626c56f2msh8580d29c47aca59p12a368jsnc74c1cdf1888"
}
response = requests.request("GET", url, headers=headers)
# print(response.text)
js = json.loads(response.text)
print("******", js)
- #result = js.get('list')
+ # result = js.get('list')
return js
-
def makeApiWorldwide(self):
- url = "https://covid-19-statistics.p.rapidapi.com/reports/total"
+ url = "https://covid-193.p.rapidapi.com/countries"
headers = {
- "x-rapidapi-host": "covid-19-statistics.p.rapidapi.com",
- "x-rapidapi-key": "482a8f8516msh16204eb9d1f4f68p1a9146jsnf33914c7300e"
+ "x-rapidapi-host": "covid-193.p.rapidapi.com",
+ "x-rapidapi-key": "36626c56f2msh8580d29c47aca59p12a368jsnc74c1cdf1888"
}
response = requests.request("GET", url, headers=headers)
# print(response.text)
js = json.loads(response.text)
print("******", js)
result = js.get('data')
-
return result
-
diff --git a/DataRequests/__pycache__/MakeApiRequests.cpython-39.pyc b/DataRequests/__pycache__/MakeApiRequests.cpython-39.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..e8b387779c17c9ecbdccee7884780cb38e7552e8
GIT binary patch
literal 1796
zcmbVN&u<$=6yBNr8OQmd5+H>JR1TF~uoF9p<5Uz%L#cYGRZ$R-
z^=i!}z4kxgP#<&Pz`rwBPW%fwAl_TssZ&x_VyyY*&CGiJKJQlsBklQq6i3SU9o!wi%OGhHoGSB)ARojDC>~Vw%+LB87@UkL
zrx}UJIR9{N|4zr2GP;C28O^NBI3N{q~T1++{EFI+Xo
zuCg;1`pXk?LWlugMQrC|dAl+pdAm9x$0o3})=WR|C^e9`wzmWP>~i&Rw=$>*Hi$UX
zN|5xorD7_QDhi}_gJc*hF*@6Po42m**6X!;uwOr}^<}5A-`L@`!(i`#1#JItP_41u
zdZR1j;9xJP2K>0%Xf#e~y7s(0-?Q9Fq)Jy82A+l^ZQj54Ly2m)6EY6hr=0;4tS`@;
zn|aZm2<0G&;c8I}EjwT`lk2KB0$GKhN78Gkw6}#{$P(NMYp%Qo
z7@#~zI7~KB9L*JHXC$NCd1;Q#TyJKsHw%>HW>&5@3pC?3(|hmKOa}y$h|$+Ger`uG
zkJt^)Mz?D_wOV;+uUtJ4m<<9yQsA>AmH|%5l(SW^OOALC$2Sn(NB98YLj+`{WapP4
zKEi=>rp3qDJj1#>jOBG?nWon-<##dm0?C-#=Oo{S
z&i^ABlGuYpw=)~)UTUT{-%0nB<|vexaVkE6lL%x~TO8gqaRp2u7ZrRddDn2_4F=a|
z4E~ge9{)As;SF$-xY8S>fjHBR1=`L7nk7gyKhG53*9G72Cw$lo!7lp#vmxtY4*9-7
z62%t6rwG>(ULPj6kYj=GDjE`H",val)
- prepareEmail([cust_name, cust_contact, cust_email,val])
+ print("===>", val)
+ prepareEmail([cust_name, cust_contact, cust_email, val])
elif intent == "totalnumber_cases":
fulfillmentText = makeAPIRequest("world")
@@ -103,7 +103,7 @@ def processRequest(req):
fulfillmentText.get('last_update')) + "\n\n*******END********* \n "
print(webhookresponse)
log.saveConversations(sessionID, "Cases worldwide", webhookresponse, intent, db)
- #log.saveCases("world", fulfillmentText, db)
+ # log.saveCases("world", fulfillmentText, db)
return {
@@ -136,7 +136,7 @@ def processRequest(req):
webhookresponse1 = ''
webhookresponse2 = ''
webhookresponse3 = ''
- for i in range(0,11):
+ for i in range(0, 11):
webhookresponse = fulfillmentText[i]
# print(webhookresponse['state'])
# js = json.loads(webhookresponse.text)
@@ -173,10 +173,8 @@ def processRequest(req):
webhookresponse['active']) + "\n" + " Recovered cases : " + str(
webhookresponse['recovered']) + "\n*********"
print("***World wide Report*** \n\n" + webhookresponse1 + "\n\n*******END********* \n")
- print("***World wide Report*** \n\n" + webhookresponse2 + "\n\n*******END********* \n")
- print("***World wide Report*** \n\n" + webhookresponse3 + "\n\n*******END********* \n")
-
-
+ print("***Country wide Report*** \n\n" + webhookresponse2 + "\n\n*******END********* \n")
+ print("***State wide Report*** \n\n" + webhookresponse3 + "\n\n*******END********* \n")
log.saveConversations(sessionID, "Indian State Cases", webhookresponse1, intent, db)
return {
@@ -218,7 +216,6 @@ def processRequest(req):
]
}
-
else:
return {
"fulfillmentText": "something went wrong,Lets start from the begning, Say Hi",
@@ -226,7 +223,8 @@ def processRequest(req):
def configureDataBase():
- client = MongoClient("mongodb+srv://username:passwrod@cluster0-replace with you URL.mongodb.net/test?retryWrites=true&w=majority")
+ client = MongoClient(
+ "mongodb+srv://username:passwrod@cluster0-replace with you URL.mongodb.net/test?retryWrites=true&w=majority")
return client.get_database('covid19DB')
@@ -247,9 +245,9 @@ def prepareEmail(contact_list):
mailclient.sendEmail(contact_list)
-if __name__ == '__main__':
- port = int(os.getenv('PORT'))
- print("Starting app on port %d" % port)
- app.run(debug=False, port=port, host='0.0.0.0')
-'''if __name__ == "__main__":
- app.run(port=5000, debug=True)''' # running the app on the local machine on port 8000
+# if __name__ == '__main__':
+# port = int(os.getenv('PORT', 5000))
+# print("Starting app on port %d" % port)
+# app.run(debug=True, port=5000, host='0.0.0.0')
+if __name__ == "__main__":
+ app.run(port=5000, debug=True) # running the app on the local machine on port 8000
diff --git a/manifest.yml b/manifest.yml
index 7b748c7..dead716 100644
--- a/manifest.yml
+++ b/manifest.yml
@@ -1,7 +1,7 @@
---
applications:
-- name: covid_19_bot
+- name: MionrCovid_19Bot
memory: 2.0GB
disk_quota: 2.0GB
random-route: true
diff --git a/requirement.txt b/requirement.txt
new file mode 100644
index 0000000000000000000000000000000000000000..016488c756c12c9e204d6bad45bfa310aa929150
GIT binary patch
literal 5144
zcmZ{oNpE9E421g}AV1|9mTb>*$RP=kLl$Hb2gq?CYxiigByaQMlhnt0R6ofI439Bt
zHd!nd+1>j0pFz1RyRs-v*_7Avoql@dqFl!Bx8<8MC@XzFFY8#l(&smwwQZSdWmWpx
zKP(gd%)_o9Ua-C__Hxd$QS7;PkK*5{a1h^n`<=bJve(bLd?{mDrcRNKdja`*M~SiXy={wE!x!!APjqD
zGtu9L;;i*|Q?A1!k$S;PdR)YgVVT9cc}>QM!^$`^UxznPpIVKTk0U1Ymo0-v{~^$K
zYXc{}P8Ergob6S|l~8ZXGV+|4uR^drFk(LXt<<#(_M|S`A;7_lo5D;Ax~7ck(lp
zO;tI{us&G_GhXoLjN#gt(g$@#Tch%#ysQ+W5Y1IZ%V-g9?t&TC=>+GEg3%y(uVusk
zy4ewFEbrj4mR3TY{K2xdOsAnASk4*{rRMaL)&}zJ`k+&CF?W+#+Xp9fEj7-rNKU4)
zdw+-x8;(uS!#VLAS%K3UCJG4NMUBtfHQJkdj#)C_FmSw+o`%!G0ZZ*VDnHiGD$p2h
z>d3ibu@Of(!&trU@H7?vl~!H#W@vU1Ue2vIVud`d3Z_e{qOvg$HI0M^)exNtR4ZE*aIaOgnm&4M2gCl)
z`g~RH<)t6%AnNX1OEJ9$R}z+efSy5KU#1tPP@#zKL+xZ>gw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2Ok>o6YvTRczo<
z%;W~L==x(2jHK4yYZ0U4Drm(CR{Igi?3I?bf<9r#cS203e<4~1r)-|94P
zicBDL6%8|y$n)(H3-n-Z)I#k%xXix0ZhuOH4LA?Gyc5y~#EpJ2?!5gW-hZ#W^Bz{&
zfzh~|TE1~J-;$Td?%(D%v2J4PfaGO(C6hwyxL#Ri4;|jfU=L`yPri1Z*~)tzeL4t!
z*E>Mv+&_J#6Wn9mBVUU#wYZkMaK~t@2cd%y~>-w9afp(ub)M~a`&=el;GD{@G%jfbJ$btg?tlcAG%xU1OGA*iEe
do1SFcwD9d7#R?f1DSLk8Ez>5UXr*jLD|pZMykYu6
zg@!jhX!@$sXbQ~*&K{lBvy}IQ1b?wpGHN7Q0rw`gY^2?J%*Gw!6UPyS2XFwY{{eYlS!chrGCNwSpTkC!W*K`_RHqr
zKFQG5@K>d|#z9@ouSCpqBdsx`E+l{K2O$Q-tc^Mk{6KaeLKvgug4xu6wR0FI8DoU`YS;C7G1-%Ofsrotc+g7la5JL^r^;WKQp
agM=cTK9`UnB=8gNP?}9TBVQO3YdSx~ptL0b
diff --git a/runtime.txt b/runtime.txt
index 257b314..396db58 100644
--- a/runtime.txt
+++ b/runtime.txt
@@ -1 +1 @@
-python-3.7.6
\ No newline at end of file
+python-3.9.6
\ No newline at end of file
diff --git a/saveConversation/Conversations.py b/saveConversation/Conversations.py
index b7a5fdb..fcb1425 100644
--- a/saveConversation/Conversations.py
+++ b/saveConversation/Conversations.py
@@ -1,35 +1,37 @@
from datetime import datetime
+
+
class Log:
def __init__(self):
- pass
-
- def saveConversations(self, sessionID, usermessage,botmessage,intent,dbConn):
+ self.current_time = None
+ self.date = None
+ self.now = None
+ def saveConversations(self, sessionID, usermessage, botmessage, intent, dbConn):
self.now = datetime.now()
self.date = self.now.date()
self.current_time = self.now.strftime("%H:%M:%S")
- #db = dbConn['Covid-19DB'] # connecting to the database called crawlerD
- mydict = {"sessionID":sessionID,"User Intent" : intent ,"User": usermessage, "Bot": botmessage, "Date": str(self.date) + "/" + str(self.current_time)}
+ # db = dbConn['Covid-19DB'] # connecting to the database called crawlerD
+ mydict = {"sessionID": sessionID, "User Intent": intent, "User": usermessage, "Bot": botmessage,
+ "Date": str(self.date) + "/" + str(self.current_time)}
- #table = db[sessionID]
+ # table = db[sessionID]
records = dbConn.chat_records
records.insert_one(mydict)
- #table.insert_one(mydict)
+ # table.insert_one(mydict)
-
- def saveCases(self, search,botmessage,dbConn):
+ def saveCases(self, search, botmessage, dbConn):
myquery = {"search": search}
- cases_dict = {"search":search,"cases": botmessage}
+ cases_dict = {"search": search, "cases": botmessage}
newvalues = {"$set": cases_dict}
records = dbConn.cases_records
records.update_one(myquery, newvalues)
- #records.insert_one(cases_dict)
+ # records.insert_one(cases_dict)
- def getcasesForEmail(self, search,botmessage,dbConn):
+ def getcasesForEmail(self, search, botmessage, dbConn):
records = dbConn.cases_records
return records.find_one({'search': search})
-
diff --git a/saveConversation/__pycache__/Conversations.cpython-39.pyc b/saveConversation/__pycache__/Conversations.cpython-39.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..233aaf15fd6dc558a6f53554f840b435835ae512
GIT binary patch
literal 1377
zcmZuxUuzRV5Z^y{m&=)`#rhW!LHiJps^E)7M2vqyL!tO`1di+NwqD8I>Fy>a;erqK
zWB8Cf`XT%x`|6WlK@gqU*qYXE*x8xgnceyQW-e*F9T6Dc9(>yVK-%mo)7te)^i0IM$=B7`*%O}IR={7to+QHVPnsN;oQnEDb3L28mLBwP$S69htO
zufuIC8!9DBlVD!f!wfAit9?k<({ix$m8cM|__^8L=)coa>3%ATyzFm|v-hbgHdVDJ
zGt+;YSEcG!qg*8SA3m*2U#BD4t;!KZqy`TA%Z6V6Ft%Zm#K$}X5QGNso3sGX
z`r%>b4)72LX3~J^ko7?^WJc$Rh}L9}&Y07g)48B?*iF2e)?UqOZhY8h2SDm&;&ktT
zUWPh-@uxxU?*-FF-Iz7%U`{D;1^jruNx1fEW9{w6+SX5cx8vKUmRbXt*Uu(rkc^wJ
zO9R}+9vU$R+}3*r40b|=1yGo~LU=aRM(rTQ3c86{4rbf}22G-5Rw;U$zL{WO*wh!i_F*Te`5tlX
zVkLq(JL1;{TBa&{-(d>-)cRQp3{Sk
- Covid-19_prevention_measures.pdf
+ Covid-19_prevention_measures.pdf
@@ -351,125 +351,8 @@
-
-
-
+
-
+
@@ -894,13 +777,13 @@
contact
us
at
-
- raturid33@gmail.com if
+ navneetguptaend@gmail.com if
you
need
any
diff --git a/sendEmail/EMailClient.py b/sendEmail/EMailClient.py
index 4b8a679..4520f94 100644
--- a/sendEmail/EMailClient.py
+++ b/sendEmail/EMailClient.py
@@ -1,20 +1,17 @@
-import os
import smtplib
-import imghdr
from email.message import EmailMessage
+
from sendEmail import template_reader
-from bs4 import BeautifulSoup
-import json
-import re
+
class GMailClient:
- def sendEmail(self,contacts):
- #EMAIL_ADDRESS = os.environ.get('EMAIL_USER')
- #EMAIL_PASSWORD = os.environ.get('EMAIL_PASS')
- EMAIL_ADDRESS = 'sender email'
- EMAIL_PASSWORD = 'sender password'
+ def sendEmail(self, contacts):
+ # EMAIL_ADDRESS = os.environ.get('EMAIL_USER')
+ # EMAIL_PASSWORD = os.environ.get('EMAIL_PASS')
+ EMAIL_ADDRESS = 'chatbotproject210@gmail.com'
+ EMAIL_PASSWORD = 'Chatbot_1'
- #contacts = ['dineshraturi22@gmail.com']
+ # contacts = ['navneetguptaend@gmail.com']
msg = EmailMessage()
msg['Subject'] = 'Detailed Covid-19 Report!'
@@ -25,10 +22,10 @@ def sendEmail(self,contacts):
values = value.get("cases")
print(values)
msg.set_content("Hello Mr. {} Here is your Covid 19 Report PFA".format(contacts[0]))
- #print(contacts[2])
+ # print(contacts[2])
template = template_reader.TemplateReader()
email_message = template.read_course_template("simple")
- #print(email_message)
+ # print(email_message)
country_name1 = "India"
total1 = str(values.get("total"))
new1 = str(values.get("new"))
@@ -36,20 +33,19 @@ def sendEmail(self,contacts):
critical1 = str(values.get("critical"))
recovered1 = str(values.get("recovered"))
print(new1 + total1)
- #.format(code1=code1, code2=code2, code3=code3, code4=code4, code5=code5
+ # .format(code1=code1, code2=code2, code3=code3, code4=code4, code5=code5
'''msg.add_alternative(email_message.format(country_name=country_name1, total=total1, new=new1, active=active1, critical=critical1,
recovered=recovered1,subtype='html'))'''
-
-
- msg.add_alternative(email_message.format(country_name=country_name1, total=total1, new=new1, active=active1, critical=critical1,
- recovered=recovered1), subtype='html')
-
+ msg.add_alternative(
+ email_message.format(country_name=country_name1, total=total1, new=new1, active=active1, critical=critical1,
+ recovered=recovered1), subtype='html')
with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp:
smtp.login(EMAIL_ADDRESS, EMAIL_PASSWORD)
smtp.send_message(msg)
- #print("email sent")
+ print("email sent")
+
def __init__(self):
- pass
\ No newline at end of file
+ pass
diff --git a/sendEmail/TestMongo.py b/sendEmail/TestMongo.py
index d88a892..969d0dd 100644
--- a/sendEmail/TestMongo.py
+++ b/sendEmail/TestMongo.py
@@ -11,5 +11,3 @@
records.remove()
-
-
diff --git a/sendEmail/__pycache__/EMailClient.cpython-39.pyc b/sendEmail/__pycache__/EMailClient.cpython-39.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..d8672217973016c804f53e351ca67fa397caf854
GIT binary patch
literal 1601
zcmYjROK%%D5GMDfm9&!G)T!&BKsPxQRe=aqngUG`6n1UL2@tu4
bh5=s_u7E;C|y>PP_0QRAYk3cX)Fh#_mm>O>pF{w!{=;1hhh^n7-
z!T4bkvrI;MXF*PN+K~syGg+;BWs4$?np~uwOL!ehm-Q7b|
zyRc`NR_A!?NTYCWFoyY=Noz9;R@e8?9M54)+B0X4rj?>Ht56SCyRTP3P5(RPWvC3>$!jU~EMq9&YMFKWAJarRZUaIdVQTGU|FD;hglJM`{5
z$cL=W>huG;J2!s)WV%&s%{=hUoWl(0jl$A*eFa&wpx&4mWp_I0H!SXbj&NCj07(%9
z^~2N2UKWls#^hi$lp)LL{y?X&9p&kyb{dZ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6zXYPCgzf3sLpi6Csr9HA9gNV6rWRnwUrSjrNGKy8ubI-d=s0-d-e1-ft#https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png"
class="CToWUd">
- Covid-19_prevention_measures.pdf![]()
+ Covid-19_prevention_measures.pdf
Hi,
diff --git a/sendEmail/template_reader.py b/sendEmail/template_reader.py
index a67a9f1..08b520a 100644
--- a/sendEmail/template_reader.py
+++ b/sendEmail/template_reader.py
@@ -2,16 +2,18 @@ class TemplateReader:
def __init__(self):
pass
- def read_course_template(self,course_name):
+ @staticmethod
+ def read_course_template(course_name):
+ global email_message
try:
- if (course_name=='report'):
+ if course_name== 'report':
email_file = open("sendEmail/graphs.html", "r")
email_message = email_file.read()
- elif (course_name == 'country'):
+ elif course_name == 'country':
email_file = open("sendEmail/DLM_Template.html", "r")
email_message = email_file.read()
- elif (course_name == 'simple'):
+ elif course_name == 'simple':
email_file = open("sendEmail/simple.html", "r")
email_message = email_file.read()
return email_message
diff --git a/sendEmail/world.html b/sendEmail/world.html
index 64dc672..f1afa65 100644
--- a/sendEmail/world.html
+++ b/sendEmail/world.html
@@ -43,7 +43,7 @@
src="https://ci4.googleusercontent.com/proxy/qYa6_H461C21RR-qYIwSBcI7qqS9WSiFAN0DaF9sKsbdOZ5S3C-vrr7s_W7pzqFo7qGPHn6zXYPCgzf3sLpi6Csr9HA9gNV6rWRnwUrSjrNGKy8ubI-d=s0-d-e1-ft#https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png"
class="CToWUd">
- Covid-19_prevention_measures.pdf
+ Covid-19_prevention_measures.pdf
@@ -351,125 +351,8 @@
-
-
-
+
-
+
From c466aebdfca2318933ce5a7de6081950c27e1ccc Mon Sep 17 00:00:00 2001
From: Navneet Gupta
Date: Tue, 17 May 2022 23:30:56 +0530
Subject: [PATCH 2/3] Initial Commit
---
Procfile | 2 +-
app.py | 27 ++++++++++--------
requirement.txt | Bin 5144 -> 5144 bytes
requirements.txt | Bin 5122 -> 0 bytes
runtime.txt | 2 +-
sendEmail/DLM_Template.html | 13 +++++++++
.../__pycache__/EMailClient.cpython-39.pyc | Bin 1601 -> 1624 bytes
7 files changed, 30 insertions(+), 14 deletions(-)
delete mode 100644 requirements.txt
diff --git a/Procfile b/Procfile
index 8001d1a..e6cb5ad 100644
--- a/Procfile
+++ b/Procfile
@@ -1 +1 @@
-web: gunicorn app:app
\ No newline at end of file
+web: python app.py
\ No newline at end of file
diff --git a/app.py b/app.py
index 1fe100b..57e010d 100644
--- a/app.py
+++ b/app.py
@@ -1,8 +1,9 @@
# doing necessary imports
import json
-# import os
+import pymongo
+import requests
-from flask import Flask, request, make_response
+from flask import Flask, render_template, request, jsonify, make_response
from flask_cors import cross_origin
from pymongo import MongoClient
@@ -10,6 +11,8 @@
from saveConversation import Conversations
from sendEmail import EMailClient
+import os
+
app = Flask(__name__) # initialising the flask app with the name 'app'
@@ -28,7 +31,7 @@ def webhook():
# processing the request from dialogflow
def processRequest(req):
- # dbConn = pymongo.MongoClient("mongodb://localhost:27017/") # opening a connection to Mongo
+ dbConn = pymongo.MongoClient("mongodb://localhost:27017/") # opening a connection to Mongo
log = Conversations.Log()
sessionID = req.get('responseId')
result = req.get("queryResult")
@@ -103,7 +106,7 @@ def processRequest(req):
fulfillmentText.get('last_update')) + "\n\n*******END********* \n "
print(webhookresponse)
log.saveConversations(sessionID, "Cases worldwide", webhookresponse, intent, db)
- # log.saveCases("world", fulfillmentText, db)
+ log.saveCases("world", fulfillmentText, db)
return {
@@ -176,7 +179,7 @@ def processRequest(req):
print("***Country wide Report*** \n\n" + webhookresponse2 + "\n\n*******END********* \n")
print("***State wide Report*** \n\n" + webhookresponse3 + "\n\n*******END********* \n")
- log.saveConversations(sessionID, "Indian State Cases", webhookresponse1, intent, db)
+ # log.saveConversations(sessionID, "Indian State Cases", webhookresponse1, intent, db)
return {
"fulfillmentMessages": [
@@ -224,7 +227,7 @@ def processRequest(req):
def configureDataBase():
client = MongoClient(
- "mongodb+srv://username:passwrod@cluster0-replace with you URL.mongodb.net/test?retryWrites=true&w=majority")
+ "mongodb+srv://Covid_19-Bot:Project_1@Minor@cluster0.jvzhh.mongodb.net/myFirstDatabase?retryWrites=true&w=majority")
return client.get_database('covid19DB')
@@ -245,9 +248,9 @@ def prepareEmail(contact_list):
mailclient.sendEmail(contact_list)
-# if __name__ == '__main__':
-# port = int(os.getenv('PORT', 5000))
-# print("Starting app on port %d" % port)
-# app.run(debug=True, port=5000, host='0.0.0.0')
-if __name__ == "__main__":
- app.run(port=5000, debug=True) # running the app on the local machine on port 8000
+if __name__ == '__main__':
+ port = int(os.getenv('PORT'))
+ print("Starting app on port %d" % port)
+ app.run(debug=True, port=5000, host='0.0.0.0')
+# if __name__ == "__main__":
+# app.run(port=5000, debug=True) # running the app on the local machine on port 8000
diff --git a/requirement.txt b/requirement.txt
index 016488c756c12c9e204d6bad45bfa310aa929150..6fed554b6843edcd60fc37efd4dfd86e66004be5 100644
GIT binary patch
delta 94
zcmbQCF+*d539A`{9)saV%UVW8!^ztjXEPda4rZ!nWHjG=nOPesw)sDcJrkqRWPA2j
vM$64d*^60$lqK(DMpi?hMuW|Y{EUq3CP1b!gV|vo=s{^M4k5CZLo(dn=>G
t=A-PztU$_=_c0@@0fQcc(Pl+{Mn-mHAk&b+c(bO!Uq(jb&FVrQ83F8g81Dc8
diff --git a/requirements.txt b/requirements.txt
deleted file mode 100644
index 589b871de508ccb42740c83ddce400cb58021761..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 5122
zcmZ{oTW?}l42Ab|rT!E~0Wz7Hhd#8G`p}CyZ7TJ#B7_h!2@qg%nIGSFeO|}-kT60C
z(y_NM%ggpY{P*vqU9@exZG*OM&+R*XhV4x|iN9~#H*M0EdcJ6@kd5{HZBMpob4iwM
zr1R5urOzVtMqvf*lV&T&Gzap%(CN$gKUW<1_t{bJ?6&RnS+!4XChgR6ly5ux=zNxR
zt%x_$nT0KKIn&>`)4~qY@^iZP^Mg)a=-h25ebY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z^2KiS?U$<84qnSUaj*wLkuE8YGO0XEU_8vv+B13k`xbA;)IH1OfU~oh-mhn%I|NM3
zy*y>?U_Q66Px4|GqG`^X1J*~6JJD5C-qx6x<`=gvvY{3aioWhT)HkDj4uqGABRdzA
z(@RMQ;?YX=;8vWsJxA2no<`k3hS`io`*M~a)ekSHDstbcD*{@ltg@QV?e~tA
z=bBW%c3#Zcz7`xIlHymQ=uTrtQUAx#7%Ni8JL={Za-XN4Yk#?Ra42iXuJavW5R64T
zw|ruNer3oz%vN{A@gAcOz5I5%v-@1W33#>;(P6Y>oq8#QL-iI&FL(xW`irV~zt58i
zorrPIr{7l6FcO?}uJj{J;zsh+iww-M;JnbdSKgj~wc$p+yY)+*<2Ok>o6YvTRczo<
z%;W~L==x(2jHK4yYZ0U4Drm(CR{Igi?3I?bf<9r#cS203e<4~1r)-|94P
zicBDL6%8|y$n)(H3-n-Z)I#k%xXix0ZhuOH4LA?Gyc5y~#EpJ2?!5gW-hZ#W^Bz{&
zfzh~|TE1~J-;$Td?%(D%v2J4PfaGO(C6hwyxL#Ri4;|jfU=L`yPri1Z*~)tzeL4t!
z*E>Mv+&_J#6Wn9mBVUU#wYZkMaK~t@2cd%y~>-w9afp(ub)M~a`&=el;GD{@G%jfbJ$btg?tlcAG%xU1OGA*iEe
do1SFcwD9d7#R?f1-->
+
+
+
+
+
+ Document
+
+
+
+
+
diff --git a/sendEmail/__pycache__/EMailClient.cpython-39.pyc b/sendEmail/__pycache__/EMailClient.cpython-39.pyc
index d8672217973016c804f53e351ca67fa397caf854..6a0e56eb35d9bf2b8988247b437b1e88bf413bb5 100644
GIT binary patch
delta 154
zcmX@ebAyLBk(ZZ?0SGwW)F+*o$or7dVB-6CjCzyrF-nA$Fr`Q|Gcq!SGo&!E0AVvT
zBSW5$A;Sd5VkH9xMlg&7k|_+q44RUDRno~Bi6u$-B?U$KS*gh-Mur9s>A8uSIeN+Y
txlx?X5Xtz-&P=~~s<=`?G7811c_o|em?tqZT1~#lV$I04nVZ#&5dcwiDr*1$
delta 130
zcmcb?bC8EOk(ZZ?0SJOk>XS}Rk$rOfQ22BaSD#^UWvb@yPlJwGolEl=!6o>TO#LOJM
Date: Wed, 18 May 2022 14:58:40 +0530
Subject: [PATCH 3/3] First Commit
---
app.py | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/app.py b/app.py
index 57e010d..dabd5bd 100644
--- a/app.py
+++ b/app.py
@@ -31,8 +31,8 @@ def webhook():
# processing the request from dialogflow
def processRequest(req):
- dbConn = pymongo.MongoClient("mongodb://localhost:27017/") # opening a connection to Mongo
- log = Conversations.Log()
+ # dbConn = pymongo.MongoClient("mongodb://localhost:27017/") # opening a connection to Mongo
+ # log = Conversations.Log()
sessionID = req.get('responseId')
result = req.get("queryResult")
intent = result.get("intent").get('displayName')
@@ -41,7 +41,7 @@ def processRequest(req):
cust_name = parameters.get("cust_name")
cust_contact = parameters.get("cust_contact")
cust_email = parameters.get("cust_email")
- db = configureDataBase()
+ # db = configureDataBase()
if intent == 'covid_searchcountry':
cust_country = parameters.get("geo-country")
@@ -58,8 +58,8 @@ def processRequest(req):
deaths_data.get('new')) + \
"\n" + " Total Test Done : " + str(deaths_data.get('total')) + "\n\n*******END********* \n "
print(webhookresponse)
- log.saveConversations(sessionID, cust_country, webhookresponse, intent, db)
- log.saveCases("country", fulfillmentText, db)
+ # log.saveConversations(sessionID, cust_country, webhookresponse, intent, db)
+ # log.saveCases("country", fulfillmentText, db)
return {
@@ -85,13 +85,13 @@ def processRequest(req):
}
elif intent == "Welcome" or intent == "continue_conversation" or intent == "not_send_email" or intent == "endConversation" or intent == "Fallback" or intent == "covid_faq" or intent == "select_country_option":
fulfillmentText = result.get("fulfillmentText")
- log.saveConversations(sessionID, query_text, fulfillmentText, intent, db)
+ # log.saveConversations(sessionID, query_text, fulfillmentText, intent, db)
elif intent == "send_report_to_email":
fulfillmentText = result.get("fulfillmentText")
- log.saveConversations(sessionID, "Sure send email", fulfillmentText, intent, db)
- val = log.getcasesForEmail("country", "", db)
- print("===>", val)
- prepareEmail([cust_name, cust_contact, cust_email, val])
+ # log.saveConversations(sessionID, "Sure send email", fulfillmentText, intent, db)
+ # val = log.getcasesForEmail("country", "", db)
+ # print("===>", val)
+ # prepareEmail([cust_name, cust_contact, cust_email, val])
elif intent == "totalnumber_cases":
fulfillmentText = makeAPIRequest("world")
@@ -105,8 +105,8 @@ def processRequest(req):
"\n" + " Last updated : " + str(
fulfillmentText.get('last_update')) + "\n\n*******END********* \n "
print(webhookresponse)
- log.saveConversations(sessionID, "Cases worldwide", webhookresponse, intent, db)
- log.saveCases("world", fulfillmentText, db)
+ # log.saveConversations(sessionID, "Cases worldwide", webhookresponse, intent, db)
+ # log.saveCases("world", fulfillmentText, db)
return {
@@ -243,9 +243,9 @@ def makeAPIRequest(query):
return api.makeApiRequestForCounrty(query)
-def prepareEmail(contact_list):
- mailclient = EMailClient.GMailClient()
- mailclient.sendEmail(contact_list)
+# def prepareEmail(contact_list):
+# mailclient = EMailClient.GMailClient()
+# mailclient.sendEmail(contact_list)
if __name__ == '__main__':