Commit 39a25f06 by Sai Komuravelli

new flow changes with response changes

parent 66f65d53
...@@ -10,43 +10,23 @@ from twilio.rest import Client ...@@ -10,43 +10,23 @@ from twilio.rest import Client
account_sid = "ACc460d692e5a467c60b352714b1416140" account_sid = "ACc460d692e5a467c60b352714b1416140"
auth_token = "bf2a890f36e3329b52d0516a14097623" auth_token = "bf2a890f36e3329b52d0516a14097623"
client = Client(account_sid, auth_token) 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})" 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: import re
return "action_send_sms"
async def run(
self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> List[Dict[Text, Any]]:
for each_event in tracker.events[::-1]: def ExtractEmail(slot_to_fill):
if each_event['event'] == 'user': email_addresse_list = re.findall('\S+@\S+', slot_to_fill)
#print(tracker.events[-1]['parse_data']['intent']['name']) return email_addresse_list
if each_event['parse_data']['intent']['name'] == "send_sms":
querytext = each_event['text'] def ExtractMobilenumber(slot_to_fill):
intentname = "send_sms" #phone number extraction
confidence = each_event['parse_data']['intent']['confidence'] #regex = re.compile("\+?\d[\( -]?\d{3}[\) -]?\d{3}[ -]?\d{2}[ -]?\d{2}")
print(querytext) regex = re.compile("\d{3}[-\.\s]??\d{3}[-\.\s]??\d{4}|\(\d{3}\)\s*\d{3}[-\.\s]??\d{4}|\d{3}[-\.\s]??\d{4}")
pattern = re.compile(regex_phone) mobile_numbers_list = re.findall(regex, slot_to_fill)
data = pattern.search(querytext) return mobile_numbers_list
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 []
class greet_primary_information(FormAction): class greet_primary_information(FormAction):
print('in greet_primary_information_form') print('in greet_primary_information_form')
def name(self) -> Text: def name(self) -> Text:
...@@ -63,7 +43,7 @@ class greet_primary_information(FormAction): ...@@ -63,7 +43,7 @@ class greet_primary_information(FormAction):
tracker.slots["querytext"] = "stop" tracker.slots["querytext"] = "stop"
return["querytext"] return["querytext"]
else: 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]: 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): ...@@ -78,6 +58,7 @@ class greet_primary_information(FormAction):
confidence = each_event['parse_data']['intent']['confidence'] confidence = each_event['parse_data']['intent']['confidence']
break break
return {"querytext":querytext,"intentname":intentname,"confidence":confidence} return {"querytext":querytext,"intentname":intentname,"confidence":confidence}
def validate_askques(self,value:Text,dispatcher: CollectingDispatcher,tracker: Tracker,domain: Dict[Text, Any],) -> Dict[Text, Any]: def validate_askques(self,value:Text,dispatcher: CollectingDispatcher,tracker: Tracker,domain: Dict[Text, Any],) -> Dict[Text, Any]:
print('in validate askques') print('in validate askques')
intentname=tracker.events[-1]['parse_data']['intent']['name'] intentname=tracker.events[-1]['parse_data']['intent']['name']
...@@ -88,13 +69,40 @@ class greet_primary_information(FormAction): ...@@ -88,13 +69,40 @@ class greet_primary_information(FormAction):
print(value) print(value)
if slot_to_fill == "yes": if slot_to_fill == "yes":
print('in yes askq') 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": elif slot_to_fill == "no":
print('askques-no') print('askques-no')
return {"askques":"no","refferals":None,"intentname":intentname,"confidence":confidence} return {"askques":"no","refferals":None,"intentname":intentname,"confidence":confidence}
else: else:
print("------------None------------") print("------------None------------")
return {"askques":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]: def validate_refferals(self,value:Text,dispatcher: CollectingDispatcher,tracker: Tracker,domain: Dict[Text, Any],) -> Dict[Text, Any]:
print('in validate refferals') print('in validate refferals')
...@@ -104,7 +112,7 @@ class greet_primary_information(FormAction): ...@@ -104,7 +112,7 @@ class greet_primary_information(FormAction):
print(value) print(value)
if value.lower() in ['yes','yeah','ha','y']: if value.lower() in ['yes','yeah','ha','y']:
print('validate_refferals') 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']: elif value.lower() in ['no','No','N']:
print('askques-no') print('askques-no')
...@@ -117,6 +125,8 @@ class greet_primary_information(FormAction): ...@@ -117,6 +125,8 @@ class greet_primary_information(FormAction):
return { return {
"askques": [self.from_intent(intent=["affirm"],value="yes"),self.from_intent(intent=["deny"],value="no"),self.from_text()], "askques": [self.from_intent(intent=["affirm"],value="yes"),self.from_intent(intent=["deny"],value="no"),self.from_text()],
"email_mobile": self.from_text(), "email_mobile": self.from_text(),
"email": self.from_text(),
"mobilenumber": self.from_text(),
"skills": self.from_text(), "skills": self.from_text(),
"availabletime": 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()], "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): ...@@ -140,6 +150,6 @@ class ResetSlot(Action):
return "action_reset" return "action_reset"
def run(self, dispatcher, tracker, domain): 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"), #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 @@ ...@@ -58,18 +58,6 @@
- abort - abort
- stop - 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 ## intent:stop
- please stop it - please stop it
......
...@@ -6,12 +6,14 @@ actions: ...@@ -6,12 +6,14 @@ actions:
- utter_stop - utter_stop
- action_reset - action_reset
- utter_goodbye - utter_goodbye
- utter_greet
- utter_welcome - utter_welcome
- utter_deny - utter_deny
- utter_ask_askques - utter_ask_askques
- utter_ask_availabletime - utter_ask_availabletime
- utter_slots_datetime - utter_slots_datetime
- utter_ask_mobilenumber
- utter_ask_email
entities: entities:
- askques - askques
...@@ -22,6 +24,9 @@ entities: ...@@ -22,6 +24,9 @@ entities:
- email_mobile - email_mobile
- skills - skills
- refferals - refferals
- email
- mobilenumber
forms: forms:
- greet_primary_information_form - greet_primary_information_form
...@@ -54,6 +59,14 @@ slots: ...@@ -54,6 +59,14 @@ slots:
refferals: refferals:
type: unfeaturized type: unfeaturized
email:
type: unfeaturized
mobilenumber:
type: unfeaturized
availabletime: availabletime:
type: unfeaturized type: unfeaturized
...@@ -82,19 +95,19 @@ templates: ...@@ -82,19 +95,19 @@ templates:
availabletime: '{availabletime}' availabletime: '{availabletime}'
response: "Thank you" response: "Thank you"
utter_ask_email_mobile: # utter_ask_email_mobile:
- custom: # - custom:
text: "Please enter your email and mobile number?" # text: "Please enter your email and mobile number?"
utter_ask_askques: utter_ask_askques:
- custom: - 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: utter_ask_availabletime:
- custom: - custom:
text: "Great! please let us know the most preferred date and time to schedule a call with a recruiter.  " text: "Great! please let us know the most preferred date and time to schedule a call with a recruiter.  "
utter_ask_refferals: utter_ask_refferals:
- custom: - 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: utter_deny:
- custom: - custom:
text: "0" text: "0"
...@@ -106,28 +119,39 @@ templates: ...@@ -106,28 +119,39 @@ templates:
utter_ask_company: utter_ask_company:
- custom: - 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: - custom:
text: "Can you please update your email address and mobile number ?" text: "Can you please update your email address and mobile number ?"
utter_ask_skills: utter_ask_skills:
- custom: - 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: utter_slots_greet_primary_information:
- custom: - custom:
email_mobile: '{email_mobile}' email_mobile: '{email_mobile}'
skills: '{skills}' skills: '{skills}'
email: '{email}'
mobilenumber : '{mobilenumber}'
refferal_yes_info: '{refferal_yes_info}' 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" text: "1"
availabletime: '{availabletime}' availabletime: '{availabletime}'
utter_stop: utter_stop:
- custom: - custom:
text: "stopped..." text: "Ok, I have cancelled your request."
utter_default: utter_default:
- custom: - custom:
...@@ -142,8 +166,7 @@ templates: ...@@ -142,8 +166,7 @@ templates:
utter_ask_refferal_yes_info: utter_ask_refferal_yes_info:
- custom: - 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: # utter_greet:
...@@ -153,5 +176,5 @@ templates: ...@@ -153,5 +176,5 @@ templates:
utter_welcome: utter_welcome:
- custom: - 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 @@ ...@@ -11,9 +11,9 @@
# https://rasa.com/docs/rasa/core/actions/#custom-actions/ # https://rasa.com/docs/rasa/core/actions/#custom-actions/
action_endpoint: 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. # Tracker store which is used to store the conversations.
# By default the conversations are stored in memory. # 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