def processRequest(req): log = logger.Log() sessionID=req.get('responseId') result = req.get("queryResult") user_says=result.get("queryText") log.write_log(sessionID, "User Says: "+user_says) parameters = result.get("parameters") cust_name=parameters.get("cust_name") #print(cust_name) cust_contact = parameters.get("cust_contact") cust_email=parameters.get("cust_email") course_name= parameters.get("course_name") intent = result.get("intent").get('displayName') if (intent=='course_selection'): email_sender=EmailSender() template= template_reader.TemplateReader() email_message=template.read_course_template(course_name) email_sender.send_email_to_student(cust_email,email_message) email_file_support = open("email_templates/support_team_Template.html", "r") email_message_support = email_file_support.read() email_sender.send_email_to_support(cust_name=cust_name,cust_contact=cust_contact,cust_email=cust_email,course_name=course_name,body=email_message_support) fulfillmentText="We have sent the course syllabus and other relevant details to you via email. An email has been sent to the Support Team with your contact information, you'll be contacted soon. Do you have further queries?" log.write_log(sessionID, "Bot Says: "+fulfillmentText) return { "fulfillmentText": fulfillmentText } else: log.write_log(sessionID, "Bot Says: " + result.fulfillmentText)
def processRequest(req): log = logger.Log() sessionID = req.get("responseId") user_says = req.get("queryText") result = reg.get("queryResult") log.writeLog(sessionID, "User Says : " + user_says) parameters = req.get("parameters") name = parameters.get("name") pin = parameters.get("pin") mailid = parameters.get("mailid") phone = parameters.get("phone") option_name = paramerers.get("option_name") intent = result.get("intent").get('displayName') if intent == "covid_intent": email_sender = EmailSender() template = template_reader.TemplateReader() email_message = template.select_info(option_name) email_sender.send_email_to_student(mailid, email_message) email_file_support = open("email_templates/preventive_Template.html", "r") email_message_support = email_file_support.read() email_sender.send_email_to_support(name=name, phone=phone, mailid=mailid, option_name=option_name, body=email_message_support) fulfillmentText = "We have sent the details to you via email. An email has been sent to the Support Team with your contact information, you'll be contacted soon. Do you have further queries?" log.write_log(sessionID, "Bot Says: " + fulfillmentText) return {"fulfillmentText": fulfillmentText} else: log.write_log(sessionID, "Bot Says: " + result.fulfillmentText)
def processRequest(req): log = logger.Log() sessionID=req.get('responseId') result = req.get("queryResult") user_says=result.get("queryText") log.write_log(sessionID, "User Says: "+user_says) parameters = result.get("parameters") cust_name=parameters.get("cust_name") #print(cust_name) cust_contact = parameters.get("cust_contact") cust_email=parameters.get("cust_email") person_name= parameters.get("person_name") intent = result.get("intent").get('displayName') if (intent=='Person_info'): email_sender=EmailSender() #template= template_reader.TemplateReader() #email_message=template.read_person_name(person_name) email_sender.send_email_to_student(cust_email,email_message) # email_file_support = open("email_templates/support_team_Template.html", "r") #email_message_support = email_file_support.read() email_sender.send_email_to_support(cust_name=cust_name,cust_contact=cust_contact,cust_email=cust_email,person_name=person_name,body=email_message_support) fulfillmentText="Happy botting" log.write_log(sessionID, "Bot Says: "+fulfillmentText) return { "fulfillmentText": fulfillmentText } else: log.write_log(sessionID, "Bot Says: " + result.fulfillmentText)
def processRequest(req): log = logger.Log() sessionID = req.get('responseId') result = req.get("queryResult") user_says = result.get("queryText") bot_says = result.get("fulfillmentText") log.write_log(sessionID, "User Says: " + user_says) parameters = result.get("parameters") cust_name = parameters.get("cust_name") #print(cust_name) cust_contact = parameters.get("cust_contact") cust_email = parameters.get("cust_email") course_name = parameters.get("course_name") intent = result.get("intent").get('displayName') if (intent == 'course_selection'): dbConn = pymongo.MongoClient("mongodb://localhost:27017/") db = dbConn['Chatbot'] collection = db['GD_INeuron_Course_Details'] if collection['SessionID'] == sessionID: collection.update_one( {"SessionId": sessionID}, {"$push": { "Event": { "$each": [user_says, bot_says] } }}, True) else: collection.insert_one({ "SessionId": sessionID, "Name": cust_name, "Contact": cust_contact, "EmailId": cust_email, "Course": course_name, "Events": [user_says, bot_says] }) email_sender = EmailSender() template = template_reader.TemplateReader() email_message = template.read_course_template(course_name) email_sender.send_email_to_student(cust_email, email_message) email_file_support = open("email_templates/support_team_Template.html", "r") email_message_support = email_file_support.read() email_sender.send_email_to_support(cust_name=cust_name, cust_contact=cust_contact, cust_email=cust_email, course_name=course_name, body=email_message_support) fulfillmentText = "We have sent the course syllabus and other relevant details to you via email. An email has been sent to the Support Team with your contact information, you'll be contacted soon. Do you have further queries?" log.write_log(sessionID, "Bot Says: " + fulfillmentText) return {"fulfillmentText": fulfillmentText} else: log.write_log(sessionID, "Bot Says: " + result.fulfillmentText)
def processRequest(req): log = logger.Log() sessionID=req.get('responseId') result = req.get("queryResult") user_says=result.get("queryText") log.write_log(sessionID, "User Says: "+user_says) parameters = result.get("parameters") cust_name=parameters.get("Name") cust_contact = parameters.get("PhoneNumber") cust_email=parameters.get("Email") course_name= parameters.get("Disease") intent = result.get("intent").get('displayName') if (intent=='appoint_yes_confirm'): email_sender=EmailSender() template= template_reader.TemplateReader() email_message=template.read_course_template(course_name) email_sender.send_email_to_student(cust_email,email_message) email_file_support = open("email_templates/support_team_Template.html", "r") email_message_support = email_file_support.read() email_sender.send_email_to_support(cust_name=cust_name,cust_contact=cust_contact,cust_email=cust_email,course_name=course_name,body=email_message_support) fulfillmentText="An email has been sent to the Support Team with your contact information, you'll be contacted soon with appointment details. " log.write_log(sessionID, "Bot Says: "+fulfillmentText) return { "fulfillmentText": fulfillmentText } if (intent == 'Welcome_Intent'): return { "fulfillmentMessages": [ { "card": { "title": "Hello. Good day. Please choose any of the below.", "buttons": [ { "text": "Need advise.", "postback": "Advise" }, { "text": "Consultation", "postback": "Consultation" }, { "text": "Book Appointment ?", "postback": "Appointment" } ] } } ] } else: log.write_log(sessionID, "Bot Says: " + result.fulfillmentText)