def ideal(uniqueSessionId): global lastReplyTime global customerId global user global bot global StartTime customerId = random.random() c = datetime.datetime.now() StartTime = c print("uniqueSessionId : ", uniqueSessionId) while True: c = datetime.datetime.now() current_time = (c.hour * 60 * 60) + (c.minute * 60) + c.second print("While lastReplyTime: ", int(lastReplyTime), " ", current_time) sleep(1) if (lastReplyTime + 20) == current_time: print("ideal") endmsg = '''Since there is no response from your end, I will have to end this conversation now. I appreciate your time and patients. Please text or speak to me if you need my help. Goodbye''' layout1.ChatLog.config(state=NORMAL) layout1.ChatLog.insert(END, "AssistBot: " + str(endmsg) + '\n\n') layout1.ChatLog.config(state=DISABLED) voice1.speak(endmsg) if (lastReplyTime + 40) == current_time: push_to_mongodb(uniqueSessionId) print("Closed") layout1.main.destroy() global stop stop = False break
def enterresponse(): global response userID = '123' ints = chatbot1.predict_class(query, chatbot1.model) response = chatbot1.getResponse(ints, userID, intents) layout1.ChatLog.config(state=NORMAL) layout1.ChatLog.insert(END, "AssistBot: " + str(response) + '\n\n') layout1.ChatLog.config(state=DISABLED) layout1.EntryBox.delete(0, END) layout1.ChatLog.yview(END) voice1.speak(response)
def intro(): intromsg = "Hi, I am AssistBot. Your customer service agent. How may I help you?" ChatLog.config(state=NORMAL) ChatLog.insert(END, "AssistBot: " + intromsg + '\n\n') ChatLog.config(state=DISABLED) voice1.speak(intromsg)