Commit 39a25f06 by Sai Komuravelli

new flow changes with response changes

parent 66f65d53
......@@ -10,43 +10,23 @@ from twilio.rest import Client
account_sid = "ACc460d692e5a467c60b352714b1416140"
auth_token = "bf2a890f36e3329b52d0516a14097623"
client = Client(account_sid, auth_token)
regex_phone = r"(\d{3}[-\.\s]??\d{3}[-\.\s]??\d{4}\d?|\(\d{3}\)\s*[-]?\d{3}[-\.\s]??\d{4}|\d{3}[-\.\s]??\d{4}|[+]?\d[-][(]?\d{3}[)]?[-]\d{3}[-]\d{4})"
class ActionSendSms(Action):
def name(self) -> Text:
return "action_send_sms"
import re
async def run(
self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> List[Dict[Text, Any]]:
for each_event in tracker.events[::-1]:
if each_event['event'] == 'user':
#print(tracker.events[-1]['parse_data']['intent']['name'])
if each_event['parse_data']['intent']['name'] == "send_sms":
querytext = each_event['text']
intentname = "send_sms"
confidence = each_event['parse_data']['intent']['confidence']
print(querytext)
pattern = re.compile(regex_phone)
data = pattern.search(querytext)
if data is not None:
phone_no = data.group()
client.messages.create(
to = phone_no,
from_= "+19169995105",
body= "Hi. This is VERA from V-Soft consulting. We may have great job opportunities based on your profile. Are you interested ? "
)
dispatcher.utter_template('utter_sms', tracker)
return []
def ExtractEmail(slot_to_fill):
email_addresse_list = re.findall('\S+@\S+', slot_to_fill)
return email_addresse_list
def ExtractMobilenumber(slot_to_fill):
#phone number extraction
#regex = re.compile("\+?\d[\( -]?\d{3}[\) -]?\d{3}[ -]?\d{2}[ -]?\d{2}")
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
class greet_primary_information(FormAction):
print('in greet_primary_information_form')
def name(self) -> Text:
......@@ -63,7 +43,7 @@ class greet_primary_information(FormAction):
tracker.slots["querytext"] = "stop"
return["querytext"]
else:
return["intentname","confidence","querytext" ,"askques","refferals","refferal_yes_info", "email_mobile", "skills","availabletime"]
return["intentname","confidence","querytext" ,"askques","refferals","refferal_yes_info", "email_mobile","email", "mobilenumber", "skills","availabletime"]
def validate_querytext(self,value:Text,dispatcher: CollectingDispatcher,tracker: Tracker,domain: Dict[Text, Any],) -> Dict[Text, Any]:
......@@ -78,6 +58,7 @@ class greet_primary_information(FormAction):
confidence = each_event['parse_data']['intent']['confidence']
break
return {"querytext":querytext,"intentname":intentname,"confidence":confidence}
def validate_askques(self,value:Text,dispatcher: CollectingDispatcher,tracker: Tracker,domain: Dict[Text, Any],) -> Dict[Text, Any]:
print('in validate askques')
intentname=tracker.events[-1]['parse_data']['intent']['name']
......@@ -88,13 +69,40 @@ class greet_primary_information(FormAction):
print(value)
if slot_to_fill == "yes":
print('in yes askq')
return {"askques":"yes",'email_mobile':None,"intentname":intentname,"confidence":confidence,"refferals":"empty","refferal_yes_info":"None"}
return {"askques":"yes",'email_mobile':None,"intentname":intentname,"confidence":confidence,"refferals":"empty","refferal_yes_info":"None","mobilenumber":"None","email":"None"}
elif slot_to_fill == "no":
print('askques-no')
return {"askques":"no","refferals":None,"intentname":intentname,"confidence":confidence}
else:
print("------------None------------")
return {"askques":None}
def validate_email_mobile(self,value:Text,dispatcher: CollectingDispatcher,tracker: Tracker,domain: Dict[Text, Any],) -> Dict[Text, Any]:
print('in validate email_mobile')
slot_to_fill = value.lower()
print("email_mobile")
print(slot_to_fill)
mobile_numbers_list=ExtractMobilenumber(slot_to_fill)
email_addresse_list=ExtractEmail(slot_to_fill)
print('email_addresse_list',email_addresse_list)
print('mobile_numbers_list',mobile_numbers_list)
if mobile_numbers_list == [] or email_addresse_list == []:
print('in empty lists')
if mobile_numbers_list ==[] and email_addresse_list != []:
print('ask mobile')
return {"mobilenumber": None, "refferals" : "None","refferal_yes_info" : "None", "email": email_addresse_list, "email_mobile":"None" }
elif email_addresse_list ==[] and mobile_numbers_list !=[] :
print('ask email')
return {"email": None, "refferals" : "None","refferal_yes_info" : "None" , "mobilenumber" :mobile_numbers_list ,"email_mobile":"None" }
else:
return {"email_mobile": None }
else:
return {"email_mobile": email_addresse_list + mobile_numbers_list ,"skills":None , "refferals":"None", "email":"None", "mobilenumber":"None"}
def validate_refferals(self,value:Text,dispatcher: CollectingDispatcher,tracker: Tracker,domain: Dict[Text, Any],) -> Dict[Text, Any]:
print('in validate refferals')
......@@ -104,7 +112,7 @@ class greet_primary_information(FormAction):
print(value)
if value.lower() in ['yes','yeah','ha','y']:
print('validate_refferals')
return {"email_mobile":"None", "skills":"None","availabletime":"None"}
return {"email_mobile":"None", "skills":"None","availabletime":"None","mobilenumber":"none","email":"none"}
elif value.lower() in ['no','No','N']:
print('askques-no')
......@@ -117,6 +125,8 @@ class greet_primary_information(FormAction):
return {
"askques": [self.from_intent(intent=["affirm"],value="yes"),self.from_intent(intent=["deny"],value="no"),self.from_text()],
"email_mobile": self.from_text(),
"email": self.from_text(),
"mobilenumber": self.from_text(),
"skills": self.from_text(),
"availabletime": self.from_text(),
"refferals":[self.from_intent(intent=["affirm"],value="yes"),self.from_intent(intent=["deny"],value="no"),self.from_text()],
......@@ -140,6 +150,6 @@ class ResetSlot(Action):
return "action_reset"
def run(self, dispatcher, tracker, domain):
return [SlotSet("email_mobile", None), SlotSet("refferals", None), SlotSet("refferal_yes_info", None),SlotSet("intentname","empty"),SlotSet("confidence",None), SlotSet("skills",None), SlotSet("askques",None),SlotSet("availabletime",None),SlotSet("querytext","empty")]
return [SlotSet("email_mobile", None),SlotSet("email", None),SlotSet("mobilenumber", None),SlotSet("refferals", None), SlotSet("refferal_yes_info", None),SlotSet("intentname","empty"),SlotSet("confidence",None), SlotSet("skills",None), SlotSet("askques",None),SlotSet("availabletime",None),SlotSet("querytext","empty")]
#SlotSet("copeup","empty"),SlotSet("sources","empty"), SlotSet("concern","empty"),SlotSet("pressingconcerns","empty"),SlotSet("items","empty"),SlotSet("purchase","empty"),SlotSet("fmembers","empty"),SlotSet("socialmedia","empty"),SlotSet("assistance","empty"),SlotSet("mobilenumber","empty"),
......@@ -58,18 +58,6 @@
- abort
- stop
## intent:send_sms
- send 19169995105
- send sms 19169995105
- send sms to 19169995105
- 19169995105 send sms
- sms for 19169995105
- 19169995105
- sms sms 19169995105
- sms 19169995105
- send 19169995105 sms
- 19169995105 sms
- sms to 19169995105
## intent:stop
- please stop it
......
......@@ -6,12 +6,14 @@ actions:
- utter_stop
- action_reset
- utter_goodbye
- utter_greet
- utter_welcome
- utter_deny
- utter_ask_askques
- utter_ask_availabletime
- utter_slots_datetime
- utter_ask_mobilenumber
- utter_ask_email
entities:
- askques
......@@ -22,6 +24,9 @@ entities:
- email_mobile
- skills
- refferals
- email
- mobilenumber
forms:
- greet_primary_information_form
......@@ -54,6 +59,14 @@ slots:
refferals:
type: unfeaturized
email:
type: unfeaturized
mobilenumber:
type: unfeaturized
availabletime:
type: unfeaturized
......@@ -82,19 +95,19 @@ templates:
availabletime: '{availabletime}'
response: "Thank you"
utter_ask_email_mobile:
- custom:
text: "Please enter your email and mobile number?"
# utter_ask_email_mobile:
# - custom:
# text: "Please enter your email and mobile number?"
utter_ask_askques:
- custom:
text: "Hi, This is VERA from V-Soft Consulting Inc(https://www.vsoftconsulting.com/). I may help you in finding your new dream job or new project? Would you like to hear more? yes or no ?"
text: "Hi. This is VERA from V-Soft Consulting Inc (link https://www.vsoftconsulting.com/). I may help you in finding your Ideal job or new project. Would you like to hear more? Please say yes/no​"
utter_ask_availabletime:
- custom:
text: "Great! please let us know the most preferred date and time to schedule a call with a recruiter.  "
utter_ask_refferals:
- custom:
text: "Thank you . It looks like you are not interested in this job opportunity now. You can also search for your dream jobs at V-Soft jobs( https://www.vsoftconsulting.com/career-portal/ ). Would you like to refer someone who is in the job market? Yes/no​"
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​"
utter_deny:
- custom:
text: "0"
......@@ -106,28 +119,39 @@ templates:
utter_ask_company:
- custom:
text: "what is the curent company you are working for ?"
text: "What is the curent company you are working for ?"
utter_ask_mobilenumber:
- custom:
text: "Please enter your updated mobile number ?"
utter_ask_email:
- custom:
text: "Please enter your updated email address ?"
utter_ask_email_phone:
utter_ask_email_mobile:
- custom:
text: "Can you please update your email address and mobile number ?"
utter_ask_skills:
- custom:
text: "Thank you, we are almost finished. Could you please update your top 5 technical skills?​"
text: "Thank you, we are almost finished. Could you please update your resume in our portal http://app.vsoftconsulting.com/aistaffingprod/uploadresume.html and reply “Yes” or Please enter top 5 technical skills?​​"
utter_slots_greet_primary_information:
- custom:
email_mobile: '{email_mobile}'
email_mobile: '{email_mobile}'
skills: '{skills}'
email: '{email}'
mobilenumber : '{mobilenumber}'
refferal_yes_info: '{refferal_yes_info}'
response: "Thankyou . We will contact you as advised. Good Bye"
response: "Thankyou. We will contact you as advised. Good Bye"
text: "1"
availabletime: '{availabletime}'
utter_stop:
- custom:
text: "stopped..."
text: "Ok, I have cancelled your request."
utter_default:
- custom:
......@@ -142,8 +166,7 @@ templates:
utter_ask_refferal_yes_info:
- custom:
text: "Great! Could you please enter the candidate’s name and phone number so one of our recruiters can contact them."
text: "Great! Could you please enter the candidate’s name and phone number in our portal http://app.vsoftconsulting.com/aistaffingprod/referral.html ​so one of our recruiters can contact them. Thank you."
# utter_greet:
......@@ -153,5 +176,5 @@ templates:
utter_welcome:
- custom:
text: "Hi, This is VERA from V-Soft Consulting Inc(https://www.vsoftconsulting.com/). I may help you in finding your new dream job or new project? Would you like to hear more? yes or no ​"
text: "Hi. This is VERA from V-Soft Consulting Inc (link https://www.vsoftconsulting.com/). I may help you in finding your Ideal job or new project. Would you like to hear more? Please say yes/no​"
......@@ -11,9 +11,9 @@
# https://rasa.com/docs/rasa/core/actions/#custom-actions/
action_endpoint:
url: "http://action_server_test:5055/webhook"
#url: "http://action_server_test:5055/webhook"
#url: "http://localhost:5055/webhook"
url: "http://localhost:5055/webhook"
# Tracker store which is used to store the conversations.
# By default the conversations are stored in memory.
......
No preview for this file type
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