Commit c0dfdbfb by Rajeev Uppala

calendar validaitons are added

parent 0ec3cba2
......@@ -6,6 +6,7 @@ from rasa_sdk.forms import FormAction, Action
from rasa_sdk.events import SlotSet
import re
from twilio.rest import Client
from datetime import datetime
account_sid = "ACc460d692e5a467c60b352714b1416140"
auth_token = "bf2a890f36e3329b52d0516a14097623"
......@@ -27,6 +28,37 @@ def ExtractMobilenumber(slot_to_fill):
regex = re.compile("\d{3}[-\.\s]??\d{3}[-\.\s]??\d{4}|\(\d{3}\)\s*\d{3}[-\.\s]??\d{4}|\d{3}[-\.\s]??\d{4}")
mobile_numbers_list = re.findall(regex, 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"))
new_date_text = datetime.fromtimestamp(timestamp)
print("new_date_text",new_date_text)
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 = 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
print("dateCheck",dateCheck)
timeCheck = new_date_text.strftime('%-H') #To check for office hours
print("timeCheck",timeCheck)
if dayNumber not in [0,6]:
print("passed 1")
if dateCheck not in HolidaysList:
print("passed 2")
if int(timeCheck) >=9 and int(timeCheck) <= 17:
print("passed 3")
return True
return False
except Exception as e:
print("FALSE in validate_available_date",e)
return False
def validate_date(date_text):
try:
datetime.strptime(date_text, '%m/%d/%Y %I:%M %p')
return True
except ValueError:
return False
class greet_primary_information(FormAction):
print('in greet_primary_information_form')
......@@ -116,13 +148,45 @@ 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('in validate_availabletime ')
slot_to_fill = value.lower()
print(slot_to_fill)
print("VALUE")
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"}
print("OUT")
try:
# 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):
print("Validate available time if")
if validate_available_date(dateToValid):
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"}
else:
print("Validate office available time else")
dispatcher.utter_message(template="utter_wrong_office_hours")
return {'availabletime':None}
else:
print("Validate available time else")
dispatcher.utter_message(template="utter_wrong_availabletime")
return {'availabletime':None}
except Exception as timeException:
print("Validate available time except",timeException)
print(tracker.latest_message)
dispatcher.utter_message(template="utter_wrong_availabletime")
return {'availabletime':None}
def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
return {
"askques": [self.from_intent(intent=["affirm"],value="yes"),self.from_intent(intent=["deny"],value="no"),self.from_text()],
......
......@@ -163,9 +163,15 @@ templates:
utter_goodbye:
- custom:
text: "Bye"
utter_wrong_availabletime:
- custom:
text: "Please enter the date and time in MM/DD/YYYY hh:mm am/pm format."
utter_wrong_office_hours:
- custom:
text: "Please enter the date and time in between 9am to 5pm 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​"
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
No preview for this file type
No preview for this file type
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