Commit 1e7678dd by Rajeev Uppala

date and time formats handling and messages changes

parent eacd7c53
Showing with 22 additions and 28 deletions
......@@ -7,6 +7,7 @@ from rasa_sdk.events import SlotSet
import re
from twilio.rest import Client
from datetime import datetime
from dateutil.parser import parse
account_sid = "ACc460d692e5a467c60b352714b1416140"
auth_token = "bf2a890f36e3329b52d0516a14097623"
......@@ -30,21 +31,21 @@ def ExtractMobilenumber(slot_to_fill):
return mobile_numbers_list
def validate_available_date(date_text):
try:
timestamp = int(datetime.strptime(date_text, '%m/%d/%y %I:%M %p').strftime("%s"))
timestamp = int(datetime.strptime(date_text, '%Y-%m-%d %H:%M:%S').strftime("%s"))
new_date_text = datetime.fromtimestamp(timestamp)
print("new_date_text",new_date_text)
HolidaysList = ["21-01-01","21-05-31","21-07-05","21-09-06","21-11-25","21-11-26","21-12-24","21-12-27"]
HolidaysList = ["2021-01-01","2021-05-31","2021-07-05","2021-09-06","2021-11-25","2021-11-26","2021-12-24","2021-12-27"]
dayNumber = int(new_date_text.strftime('%w')) #To check weekend or weekday
print("daynumber",dayNumber)
dateCheck = new_date_text.strftime('%y-%m-%d') #To check for public holidays
dateCheck = new_date_text.strftime('%Y-%m-%d') #To check for public holidays
print("dateCheck",dateCheck)
timeCheck = new_date_text.strftime('%-H') #To check for office hours
print("timeCheck",timeCheck)
date_format = "%m/%d/%y %I:%M %p"
date_format = "%Y-%m-%d %H:%M:%S"
# create datetime objects from the strings
givenDate = datetime.strptime(date_text, date_format)
presentDate = str(datetime.now().strftime("%m/%d/%y %I:%M %p"))
presentDate = str(datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
presentDate = datetime.strptime(presentDate, date_format)
if givenDate >= presentDate:
print("passed past date check condition")
......@@ -52,7 +53,7 @@ def validate_available_date(date_text):
print("passed weekday condition")
if dateCheck not in HolidaysList:
print("passed non holidays day condition")
if int(timeCheck) >=9 and int(timeCheck) <= 17:
if int(timeCheck) >=9 and int(timeCheck) < 17:
print("passed working hours condition")
return True
return False
......@@ -62,7 +63,7 @@ def validate_available_date(date_text):
def validate_date(date_text):
try:
datetime.strptime(date_text, '%m/%d/%y %I:%M %p')
datetime.strptime(date_text, '%Y-%m-%d %H:%M:%S')
return True
except ValueError:
return False
......@@ -156,30 +157,21 @@ class greet_primary_information(FormAction):
print("------------None------------")
return {"refferals":None}
# def validate_availabletime(self,value:Text,dispatcher: CollectingDispatcher,tracker: Tracker,domain: Dict[Text, Any],) -> Dict[Text, Any]:
# print('in validate_availabletime ')
# slot_to_fill = value.lower()
# print(slot_to_fill)
# print(value)
# return {"response":"Thank you. We’ll have a recruiter reach out to you at that time. Please feel free to update your resume at http://app.vsoftconsulting.com/aistaffingprod/uploadresume.html Or if you have any questions please mail to recruiter@vsoftconsulting.com with your reference number"}
def validate_availabletime(self,value:Text,dispatcher: CollectingDispatcher,tracker: Tracker,domain: Dict[Text, Any],) -> Dict[Text, Any]:
print("VALUE")
print(value)
print("OUT")
try:
matchedDate = str(parse(value, fuzzy=True))
# Since both the fields are populated, the form
# will no longer prompt the user separately for the end_date
print("Validate available time try")
dateToValid = value
if validate_date(dateToValid):
if validate_date(matchedDate):
print("Validate available time if")
if validate_available_date(dateToValid):
if validate_available_date(matchedDate):
finalDate = datetime.strptime(matchedDate, "%Y-%m-%d %H:%M:%S").strftime('%m/%d/%y %I:%M %p')
print("Validate available time if")
# availabletime = dateToValid
# dispatcher.utter_message(template="utter_wrong_office_hours")
# return {'availabletime': availabletime}
return {"response":"Thank you. We’ll have a recruiter reach out to you at that time. Please feel free to update your resume at http://app.vsoftconsulting.com/aistaffingprod/uploadresume.html Or if you have any questions please mail to recruiter@vsoftconsulting.com with your reference number"}
return {"availabletime":finalDate,"response":"Thank you. We’ll have a recruiter reach out to you at that time. Please feel free to update your resume at http://app.vsoftconsulting.com/aistaffingprod/uploadresume.html Or if you have any questions please mail to recruiter@vsoftconsulting.com with your reference number"}
else:
print("Validate office available time else")
dispatcher.utter_message(template="utter_wrong_office_hours")
......@@ -196,6 +188,8 @@ class greet_primary_information(FormAction):
def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
print("type of self from text",type(self.from_text()))
print("self from text",self.from_text())
return {
"askques": [self.from_intent(intent=["affirm"],value="yes"),self.from_intent(intent=["deny"],value="no"),self.from_text()],
"email_mobile": self.from_text(),
......
......@@ -104,10 +104,10 @@ templates:
utter_ask_askques:
- custom:
text: "This is VERA from V-Soft Consulting Inc (https://www.vsoftconsulting.com ). It’s been a while since we’ve been in contact with you. Are you interested in hearing about job opportunities that match your background and skills?​Yes/no​"
text: "Hi, This is VERA from V-Soft Consulting Inc (https://www.vsoftconsulting.com ). It’s been a while since we’ve been in contact with you. Are you interested in hearing about job opportunities that match your background and skills?​ Yes/no​"
utter_ask_availabletime:
- custom:
text: "We are almost done. When would be the best time for one of our recruiter reach out to you to talk further? Please enter the date and time as in mm/dd/yy and hh:mm am/pm."
text: "We are almost done. When would be the best time for one of our recruiter reach out to you to talk further? Please enter the date and time as in mm/dd/yy and hh:mm am/pm. (Ex: 01/31/21 12:30 pm)"
utter_ask_refferals:
- custom:
text: "Thank you. It looks like you are not interested in the job opportunities now, but you can search for your ideal job at https://www.vsoftconsulting.com/career-portal/ . Would you like to refer someone who is in the job market? Yes/no"
......@@ -130,12 +130,12 @@ templates:
utter_ask_jobtype:
- custom:
text: "Thanks for the information. Are you interested in Contract, Perm or either?​"
text: "Thanks for the information. Are you interested in Contract, Permanent or both?​"
utter_ask_email_mobile:
- custom:
text: "is this the best email and phone number to reach you? If not please update."
text: "Is this the best email and phone number to reach you? If not please update."
utter_ask_skills:
- custom:
......@@ -170,8 +170,8 @@ templates:
utter_wrong_office_hours:
- custom:
text: "Please enter the date and time in between 9am to 5pm on working days."
text: "Please enter the date and time in between 9am to 5pm only on working days."
utter_welcome:
- custom:
text: "This is VERA from V-Soft Consulting Inc (https://www.vsoftconsulting.com ). It’s been a while since we’ve been in contact with you. Are you interested in hearing about job opportunities that match your background and skills?​Yes/no​"
\ No newline at end of file
text: "Hi, This is VERA from V-Soft Consulting Inc (https://www.vsoftconsulting.com ). It’s been a while since we’ve been in contact with you. Are you interested in hearing about job opportunities that match your background and skills?​Yes/no​"
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment