Hello, i am wonedring is that bug in rasa or i am doing something wrong.
in my flow i want the user whenever he says stop the conversation or any word related to the intent stop the flow, the bot ask him if he really want to stop or not as a confirmation message, if the user said yes the flow should stop and send goodbye message to the user. But if the user send no the bot keep the conversation, however if he in the form it should continue from the last slot he was filling.
i already implemented my idea through custom actions. but in first glance you think its working when the user says stop the flow and then says no, but if he said it again in the conversation the second time the bot doesn’t respond to the user. (in the interactive mode is working fine however in shell it doesnt send message)( i get empty response )
if its not bug what is the best solution to do same idea of confirmation the stopping the flow and return the user the same form in the same slot. Action_no_flow is the last step where issue occurs in the actions file
Actions file
import re
import rasa_sdk
import requests
from rasa_sdk.types import DomainDict
from rasa_sdk.executor import CollectingDispatcher
from typing import Any, Text, Dict, List
from rasa_sdk import FormValidationAction , Action, Tracker
from rasa_sdk.events import EventType, AllSlotsReset, SlotSet, FollowupAction, ActiveLoop ,Restarted ,ActionExecuted
from datetime import datetime
forms_name= ['network_complains_form']
issue_type_list ={ 'voice':"Please choose the digit related to your voice problem:\n"
"1. Can not initiate Call (Call Block)\n"
"2. Can not hear other party at all since call start (Silent Call)\n"
"3. Can not hear other party well (Call Quality)\n"
"4. Calls drop in the middle of the call (Call Drop)\n"
"5. Others" ,
"data":"Please choose the digit related to your data problem:\n"
"1. Can not initiate any data session at all\n"
"2. Can not download any video or image\n"
"3. Slow Speed in browsing or streaming\n"
"4.Can not connect to certain applications/servers/links\n"
"5. Others\n" ,
"both":"Please choose the digit related to your voice problem:\n"
"1. Can not initiate Call (Call Block)\n"
"2. Can not hear other party at all since call start (Silent Call)\n"
"3. Can not hear other party well (Call Quality)\n"
"4. Calls drop in the middle of the call (Call Drop)\n"
"5. Others"
}
translate_issue_type_list ={ 'voice':"الرجاء اختيار الرقم المتعلق بمشكلة الصوت الخاصة بك: \n "
"1. لا يمكن بدء الاتصال (حظر المكالمة) \n"
"2. لا يمكن سماع الطرف الآخر على الإطلاق منذ بدء المكالمة (اتصال صامت) \n"
"3. لا يمكن سماع الطرف الآخر جيدًا (جودة المكالمة) \n"
"4. سقوط المكالمات في منتصف المكالمة (سقوط المكالمه) \n"
"5. أخرى" ,
"data":"الرجاء اختيار الرقم المتعلق بمشكلة البانات لديك: \n"
"1. لا يمكن بدء أي جلسة بيانات على الإطلاق \n"
"2. لا يمكن تنزيل أي فيديو أو صورة \n"
"3. سرعة بطيئة في التصفح أو البثة \n"
"4. لا يمكن الاتصال بتطبيقات / خوادم / روابط معينة \n"
"5. اخرى\n" ,
"both":"الرجاء اختيار الرقم المتعلق بمشكلة الصوت الخاصة بك:\n "
"1. لا يمكن بدء الاتصال (حظر المكالمة)\n"
"2. لا يمكن سماع الطرف الآخر على الإطلاق منذ بدء المكالمة (الاتصال الصامت)\n"
"3. لا يمكن سماع الطرف الآخر جيدًا (جودة المكالمة)\n"
"4. انخفاض المكالمات في منتصف المكالمة (سقوط مكالمه)\n"
"5. اخرى"
}
En = 0
Ar = 0
last_correct_value = None
language_change_based_on_user_input = True
def check_language(word):
global En
global Ar
if language_change_based_on_user_input == True:
if word.isnumeric() == False:
if word.isascii() == True:
En = En + 1
else:
Ar = Ar + 1
else:
if word.isnumeric() == False:
if word.isascii() == True:
En = 1
Ar = 0
else:
Ar = 1
En = 0
form_running =""
class Validate_stop_the_flow_answer_form(FormValidationAction):
def name(self) -> Text:
return "validate_stop_the_flow_answer_form"
def validate_stop_the_flow_answer(self,slot_value:str, dispatcher: CollectingDispatcher,tracker: Tracker, domain: DomainDict) -> List[Dict[Text, Any]]:
global form_running
# last_form_was_running = form_running
# form_running = 'stop_the_flow_answer_form'
last_intent = tracker.get_intent_of_latest_message()
if last_intent == "affirm":
return {"stop_the_flow_answer": 'yes'}
elif last_intent == "deny":
return {"stop_the_flow_answer": 'no'}
#
# elif slot_value in forms_name:
# return {"stop_the_flow_answer":slot_value}
else:
return {"stop_the_flow_answer": None}
class Validate_change_language_form(FormValidationAction):
def name(self) -> Text:
return "validate_change_language_form"
def validate_language(self,slot_value:any, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
global En
global Ar
last_entity_list = tracker.latest_message['entities']
if len(last_entity_list) > 0:
entity_name = last_entity_list[0]['entity']
if entity_name == 'language':
slot_value = last_entity_list[0]['value']
print("i am in val")
last_intent = tracker.get_intent_of_latest_message()
if last_intent == "stop_the_flow" or last_intent =='negative_words':
return {"requested_slot": None, "restart": "stop"}
if slot_value == "En" or slot_value == "انجليزى":
En = En + 1000
Ar = 0
return {"language": slot_value }
elif slot_value == "Ar" or slot_value=="عربى":
print("i am here")
Ar = Ar + 1000
En = 0
return {"language": slot_value }
else:
if En > Ar:
dispatcher.utter_message('select langague XX_OPTION_XX(En) XX_OPTION_XX(Ar)')
return {"language": None}
elif En <= Ar:
dispatcher.utter_message('اختار اللغهXX_OPTION_XX(عربى) XX_OPTION_XX(انجليزى)')
return {"language": None}
class Action_ask_language(Action):
def name(self) -> Text:
return "action_ask_language"
def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> List[EventType]:
sentence = tracker.latest_message['text']
check_language(sentence)
if En > Ar:
dispatcher.utter_message('Kindly choose the language you want XX_OPTION_XX(En) XX_OPTION_XX(Ar)')
elif En <= Ar:
dispatcher.utter_message('من فضلك قم باختيار اللغةXX_OPTION_XX(عربى) XX_OPTION_XX(انجليزى)')
class Action_ask_stop_the_flow_answer(Action):
def name(self) -> Text:
return "action_ask_stop_the_flow_answer"
def run(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> List[EventType]:
sentence = tracker.latest_message['text']
check_language(sentence)
if En > Ar:
dispatcher.utter_message('Want to stop the converstion XX_OPTION_XX(yes) XX_OPTION_XX(no)')
elif En <= Ar:
dispatcher.utter_message('عاوز توقف الحوارXX_OPTION_XX(لا) XX_OPTION_XX(نعم)')
class Validate_network_complains_form(FormValidationAction):
def name(self) -> Text:
return "validate_network_complains_form"
def validate_issue_number(self,slot_value:str, dispatcher: CollectingDispatcher,tracker: Tracker, domain: DomainDict) -> List[Dict[Text, Any]]:
global form_running
global last_correct_value
form_running = 'network_complains_form'
last_intent = tracker.get_intent_of_latest_message()
if last_intent == "stop_the_flow" :
return {"requested_slot": None, "restart": "stop"}
if slot_value != '1' and slot_value != '2' and slot_value != '3' and slot_value != '١' and slot_value != '٢' and slot_value != '٣':
if En > Ar:
dispatcher.utter_message('please choose number from list')
return {"issue_number": None}
elif En <= Ar:
dispatcher.utter_message("اختار رقم من القائمه")
return {"issue_number": None}
else:
return {"issue_number": slot_value}
def validate_issue_date(self,slot_value:any, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
last_intent = tracker.get_intent_of_latest_message()
if last_intent == "stop_the_flow" :
return {"requested_slot": None, "restart": "stop" }
if slot_value == "":
if En > Ar:
dispatcher.utter_message("you need to put issue date")
return {"issue_date": None}
elif En <= Ar:
dispatcher.utter_message("محتاج تقول تاريخ ")
return {"issue_date": None}
else:
return {'issue_date': slot_value}
def validate_issue_type(self,slot_value:any, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
last_intent = tracker.get_intent_of_latest_message()
if last_intent == "stop_the_flow" :
return {"requested_slot": None, "restart": "stop"}
last_entity_list = tracker.latest_message['entities']
if len(last_entity_list) > 0:
entity_name = last_entity_list[0]['entity']
if entity_name == 'issue_type':
slot_value = last_entity_list[0]['value']
slot_value = slot_value.lower()
if slot_value == 'data' or slot_value == 'voice' :
return {'issue_type': slot_value , 'number_2': "" , 'comment_2': ""}
elif slot_value == '1' or slot_value == '١' :
return {'issue_type': "voice" , 'number_2': "" , 'comment_2': ""}
elif slot_value == '2' or slot_value == '٢' :
return {'issue_type': "data" , 'number_2': "" , 'comment_2': ""}
elif slot_value == 'both':
return {'issue_type': slot_value}
elif slot_value == '3' or slot_value == '٣' :
return {'issue_type': 'both'}
else:
if En > Ar:
dispatcher.utter_message(text="you need to put issue type ")
return {"issue_type": None}
elif En <= Ar:
dispatcher.utter_message(text="محتاج تقول نوع المشكله")
return {"issue_type": None}
def validate_number_1(self,slot_value:any, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
last_intent = tracker.get_intent_of_latest_message()
if last_intent == "stop_the_flow" :
return {"requested_slot": None, "restart": "stop"}
issue_type = tracker.get_slot("issue_type")
if (slot_value =='5' or slot_value =="٥") and issue_type == 'voice':
return {'number_1':slot_value}
elif (slot_value =='4' or slot_value =='5' or slot_value == '٤' or slot_value =="٥") and issue_type == 'data':
return {'number_1': slot_value}
elif (slot_value =='5' or slot_value =="٥") and issue_type == 'both':
return {'number_1': slot_value}
elif (slot_value == "1" or slot_value == '2' or slot_value == '3' or slot_value == '4' or slot_value == "١" or slot_value == '٢' or slot_value == '٣' or slot_value == '٤') and issue_type == 'both':
return {'number_1': slot_value, 'comment_1': ""}
elif slot_value == "1" or slot_value == '2' or slot_value == '3' or slot_value == '4' or slot_value == "١" or slot_value == '٢' or slot_value == '٣' or slot_value == '٤':
return {'number_1':slot_value, 'comment_1':""}
else:
if En > Ar:
dispatcher.utter_message(text="you need to put number")
return {"number_1": None}
elif En <= Ar:
dispatcher.utter_message(text="محتاج تقول رقم")
return {"number_1": None}
def validate_comment_1(self,slot_value:any, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
last_intent = tracker.get_intent_of_latest_message()
if last_intent == "stop_the_flow":
return {"requested_slot": None, "restart": "stop"}
else:
return {"comment_1": slot_value}
def validate_number_2(self,slot_value:any, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
last_intent = tracker.get_intent_of_latest_message()
if last_intent == "stop_the_flow" :
return {"requested_slot": None, "restart": "stop"}
if slot_value == '1' or slot_value == '2' or slot_value == '3' or slot_value == "١" or slot_value == '٢' or slot_value == '٣':
return {'number_2': slot_value , 'comment_2':""}
elif slot_value == '4' or slot_value == '5' or slot_value == "٤" or slot_value == '٥':
return {'number_2': slot_value}
else:
if En > Ar:
dispatcher.utter_message(text="you need to put number ")
return {"number_2": None}
elif En <= Ar:
dispatcher.utter_message(text="محتاج تقول رقم")
return {"number_2": None}
def validate_comment_2(self,slot_value:any, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
last_intent = tracker.get_intent_of_latest_message()
if last_intent == "stop_the_flow" :
return {"requested_slot": None, "restart": "stop"}
else:
return {"comment_2": slot_value}
def validate_location(self,slot_value:any, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
last_intent = tracker.get_intent_of_latest_message()
if last_intent == "stop_the_flow" :
return {"requested_slot": None, "restart": "stop"}
slot_value = slot_value.split(",")
if 'latitude' in slot_value[0] and 'longitude' in slot_value[1]:
slot_value = (f"({slot_value[0][9:]},{slot_value[1][10:]})")
return {'location': slot_value}
else:
if En > Ar:
dispatcher.utter_message(text="you need to put current location")
return {"location": None}
elif En <= Ar:
dispatcher.utter_message(text="محتاج تبعت المكان الحالى")
return {"location": None}
class Action_ask_issue_number(Action):
def name(self) -> Text:
return "action_ask_issue_number"
def run(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> List[EventType]:
sentence = tracker.latest_message['text']
check_language(sentence)
if En > Ar:
dispatcher.utter_message(text='Please choose the digit related to your'
' problem (1,2,3)\n'
'1.Indoor Only\n'
'2.Outdoor Only\n'
'3.Both\n'
' XX_OPTION_XX(1) XX_OPTION_XX(2) XX_OPTION_XX(3)')
elif En <= Ar:
dispatcher.utter_message(text='من فضلك اختار رقم له علاقه بمشكلتك (1,2,3) \n'
'1-مشكله داخليه فقط\n'
'2-مشكله خارجيه فقط\n'
'3-الاتنين\n'
'XX_OPTION_XX(1) XX_OPTION_XX(2) XX_OPTION_XX(3)')
return []
class Action_ask_issue_date(Action):
def name(self) -> Text:
return "action_ask_issue_date"
def run(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> List[EventType]:
sentence = tracker.latest_message['text']
check_language(sentence)
if En > Ar:
dispatcher.utter_message(text='what is the issue date ?')
elif En <= Ar:
dispatcher.utter_message(text='ايه هو تاريخ المشكله ؟')
return []
class Action_ask_issue_type(Action):
def name(self) -> Text:
return "action_ask_issue_type"
def run(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> List[EventType]:
sentence = tracker.latest_message['text']
check_language(sentence)
if En > Ar:
dispatcher.utter_message(text='write the issue type (voice,data,both)'
' XX_OPTION_XX(voice) XX_OPTION_XX(data) XX_OPTION_XX(both)')
elif En <= Ar:
dispatcher.utter_message(text='اكتب نوع المشكله(صوتى ولا معلومات ولا الاتنين)XX_OPTION_XX'
'(صوتى) XX_OPTION_XX(داتا) XX_OPTION_XX(الاتنين)')
return []
class Action_ask_number_1(Action):
def name(self) -> Text:
return "action_ask_number_1"
def run(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> List[EventType]:
sentence = tracker.latest_message['text']
check_language(sentence)
issue_type= tracker.get_slot('issue_type')
if En > Ar:
dispatcher.utter_message(issue_type_list[issue_type])
elif En <= Ar:
dispatcher.utter_message(translate_issue_type_list[issue_type])
return []
class Action_ask_comment_1(Action):
def name(self) -> Text:
return "action_ask_comment_1"
def run(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> List[EventType]:
sentence = tracker.latest_message['text']
check_language(sentence)
number = tracker.get_slot('number_1')
issue_type = tracker.get_slot('issue_type')
if number == '5' and issue_type =="voice":
if En > Ar:
dispatcher.utter_message(text='Please provide voice problem type')
elif En <= Ar:
dispatcher.utter_message(text='اكتب المشكله الصوت لو سمحت ')
elif number == '5' and issue_type =="data":
if En > Ar:
dispatcher.utter_message(text='Please provide data problem type')
elif En <= Ar:
dispatcher.utter_message(text='اكتب المشكله الصوت لو سمحت ')
elif number == '5' :
if En > Ar:
dispatcher.utter_message(text='Please provide voice problem type')
elif En <= Ar:
dispatcher.utter_message(text='اكتب المشكله الصوت لو سمحت ')
elif number == "4":
if En > Ar:
dispatcher.utter_message(text='Please specify application/server/link name')
elif En <= Ar:
dispatcher.utter_message(text='اكتب المواقع او اللينكات اللى مش شغاله ')
class Action_ask_number_2(Action):
def name(self) -> Text:
return "action_ask_number_2"
def run(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> List[EventType]:
sentence = tracker.latest_message['text']
check_language(sentence)
# issue_type= tracker.get_slot('issue_type')
if En > Ar:
dispatcher.utter_message(issue_type_list['data'])
elif En <= Ar:
dispatcher.utter_message(translate_issue_type_list['data'])
return []
class Action_ask_comment_2(Action):
def name(self) -> Text:
return "action_ask_comment_2"
def run(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> List[EventType]:
sentence = tracker.latest_message['text']
check_language(sentence)
number = tracker.get_slot('number_2')
if number == '5':
if En > Ar:
dispatcher.utter_message(text='Please provide data problem type')
elif En <= Ar:
dispatcher.utter_message(text='اكتب مشكله البيانات لو سمحت ')
elif number == "4":
if En > Ar:
dispatcher.utter_message(text='Please specify application/server/link name')
elif En <= Ar:
dispatcher.utter_message(text='اكتب المواقع او اللينكات اللى مش شغاله ')
class Action_ask_location(Action):
def name(self) -> Text:
return "action_ask_location"
def run(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> List[EventType]:
sentence = tracker.latest_message['text']
check_language(sentence)
if En > Ar:
dispatcher.utter_message('Please share the problem location as a final step')
elif En <= Ar:
dispatcher.utter_message('لو سمحت شارك معانا مكانك كخطوه اخيره')
class Action_response_final_answer(Action):
def name(self) -> Text:
return "response_final_answer"
def run(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> List[EventType]:
sentence = tracker.latest_message['text']
check_language(sentence)
restart = tracker.get_slot("restart")
last_intent = tracker.get_intent_of_latest_message()
if restart == "stop" and last_intent=="stop_the_flow":
return [FollowupAction("stop_the_flow_answer_form")]
elif restart == "stop" and last_intent=="negative_words":
return [FollowupAction("response_negative_words")]
if En > Ar:
dispatcher.utter_message('Sorry for any inconvenience and thanks for submitting your network complaint.'
' We will come back to you the soonest with our feedback to your problem.XX_OPTION_XX(network issue)')
return [AllSlotsReset()]
elif En <= Ar:
dispatcher.utter_message('آسف على أي إزعاج وشكرا على تقديم شكوى الشبكة الخاصة بك. سنعود إليك في أقرب وقت مع ملاحظاتنا لمشكلتك XX_OPTION_XX(مشكله شبكه)')
return [AllSlotsReset()]
class Action_confirm_network_complains_slots(Action):
def name(self) -> Text:
return "response_confirm_network_complains_slots"
def run(self, dispatcher, tracker, domain):
sentence = tracker.latest_message['text']
check_language(sentence)
issue_number = tracker.get_slot('issue_number')
issue_date = tracker.get_slot('issue_date')
issue_type = tracker.get_slot('issue_type')
if En > Ar:
return dispatcher.utter_message(f'The issue_number is {issue_number},and the date'
f'{issue_date},and the type {issue_type} .')
elif En <= Ar:
return dispatcher.utter_message(f'رقم المشكله هو {issue_number}'
f'{issue_date} و تاريخ المشكله هو '
f'و نوع المشكله هو {issue_type}')
class ActionGreet(Action):
def name(self) -> Text:
return "response_greet"
def run(self, dispatcher, tracker, domain):
sentence = tracker.latest_message['text']
check_language(sentence)
if En > Ar:
print(tracker.sender_id)
return dispatcher.utter_message('Hi, this is Lissa from Etisalat Technical team '
'May I assist you in your network complaint? '
'XX_OPTION_XX(yes) XX_OPTION_XX(no)')
elif En <= Ar:
return dispatcher.utter_message('اهلا انا ليزا من اتصالات تيكنكال تيم '
'اقدر اساعد حضرتك فى مشكله الشبكه ؟'
' XX_OPTION_XX(نعم) XX_OPTION_XX(لا)')
class ActionGoodbye(Action):
def name(self) -> Text:
return "response_goodbye"
def run(self, dispatcher, tracker, domain):
sentence = tracker.latest_message['text']
check_language(sentence)
if En > Ar:
return dispatcher.utter_message('Thank you for using Etisalat')
elif En <= Ar:
return dispatcher.utter_message('شكرا لاستخدامك اتصالات')
class Action_response_rephrase(Action):
def name(self) -> Text:
return "response_rephrase"
def run(self, dispatcher, tracker, domain):
sentence = tracker.latest_message['text']
check_language(sentence)
if En > Ar:
return dispatcher.utter_message('please re-phrase')
elif En <= Ar:
return dispatcher.utter_message('عيد الجمله من فضلك')
class ActionReset_all_slots(Action):
def name(self) -> Text:
return "reset_all_slots"
def run(self, dispatcher, tracker, domain):
return [AllSlotsReset()]
class ActionRefill(Action):
def name(self) -> Text:
return "response_refill"
def run(self, dispatcher, tracker, domain):
sentence = tracker.latest_message['text']
check_language(sentence)
if En > Ar:
return dispatcher.utter_message('please re-filli the form.')
elif En <= Ar:
return dispatcher.utter_message('ابد العمليه من جديد.')
class ActionConfrim(Action):
def name(self) -> Text:
return "response_confrim"
def run(self, dispatcher, tracker, domain):
sentence = tracker.latest_message['text']
check_language(sentence)
intent = tracker.get_intent_of_latest_message()
if intent == 'affirm':
if En > Ar:
dispatcher.utter_message('ok sending the form')
return [AllSlotsReset()]
elif En <= Ar:
dispatcher.utter_message('تمام ببعت الفورم دلوقتى')
return [AllSlotsReset()]
if intent == 'deny':
if En > Ar:
dispatcher.utter_message('please re-fill the form.')
return [AllSlotsReset(),rasa_sdk.events.FollowupAction(form_running)]
elif En <= Ar:
dispatcher.utter_message('ابد العمليه من جديد.')
return [AllSlotsReset(),rasa_sdk.events.FollowupAction(form_running)]
class ActionIssue_type_list(Action):
def name(self) -> Text:
return "response_Issue_type_list"
def run(self, dispatcher, tracker, domain):
sentence = tracker.latest_message['text']
check_language(sentence)
issue_type = tracker.get_slot('issue_type')
if En > Ar:
return dispatcher.utter_message(issue_type_list[issue_type])
elif En <= Ar:
return dispatcher.utter_message(translate_issue_type_list[issue_type])
class Action_time(Action):
def name(self) -> Text:
return "response_time"
def run(self, dispatcher, tracker, domain):
sentence = tracker.latest_message['text']
check_language(sentence)
now = datetime.now()
if En > Ar:
return dispatcher.utter_message("the time and date is : " + now.strftime('%Y/%m/%d %I:%M:%S'))
elif En <= Ar:
return dispatcher.utter_message("الوقت و التاريح هو : "+ now.strftime('%Y/%m/%d %I:%M:%S'))
return []
class Action_who_are_you(Action):
def name(self) -> Text:
return "response_who_are_you"
def run(self, dispatcher, tracker, domain):
sentence = tracker.latest_message['text']
check_language(sentence)
if En > Ar:
return dispatcher.utter_message("My name is Chatbot, I am built on Artificial Intelligence technologies"
"to serve etisalat employees. I am not a human, So I don't really have any certain physical"
"features")
elif En <= Ar:
return dispatcher.utter_message("اسمي شات بوت ،اتبنيت على تقنيات الذكاء الاصطناعي لخدمة موظفي اتصالات. "
"أنا مش إنسانًا ، علشان كدا مليش أي سمات جسدية معينة")
class Action_no_flow(Action):
def name(self) -> Text:
return "response_no_flow"
def run(self, dispatcher, tracker, domain):
stop_the_flow_answer = tracker.get_slot('stop_the_flow_answer')
if stop_the_flow_answer == 'no' or stop_the_flow_answer == 'لا' :
return [FollowupAction(form_running)]
elif stop_the_flow_answer == 'yes' or stop_the_flow_answer == 'نعم':
return [FollowupAction("response_goodbye"),AllSlotsReset()]
class Action_language_changed(Action):
def name(self) -> Text:
return "response_language_changed"
def run(self, dispatcher, tracker, domain):
sentence = tracker.latest_message['text']
check_language(sentence)
if En > Ar:
return dispatcher.utter_message("The chat langauge has been changed to English")
elif En <= Ar:
return dispatcher.utter_message("تم تغير اللغة الى العربيه")
class Action_out_of_scope(Action):
def name(self) -> Text:
return "response_out_of_scope"
def run(self, dispatcher, tracker, domain):
sentence = tracker.latest_message['text']
check_language(sentence)
print(tracker.latest_message)
if En > Ar:
return dispatcher.utter_message("sorry i didn't understand you")
elif En <= Ar:
return dispatcher.utter_message("اسف لم افهم ما قلت")
class Action_negative_words(Action):
def name(self) -> Text:
return "response_negative_words"
def run(self, dispatcher, tracker, domain):
sentence = tracker.latest_message['text']
print(sentence)
check_language(sentence)
if En > Ar:
dispatcher.utter_message("I am sorry you feel that way, how I can help you ?XX_OPTION_XX(network issue)")
return [Restarted()]
elif En <= Ar:
dispatcher.utter_message("انا اسف لو مفهمتش حضرتك اقدر اساعدك ازاى ؟XX_OPTION_XX(مشكله شبكه)")
return [Restarted()]
class Action_change(Action):
def name(self) -> Text:
return "action_changing_language"
def run(self, dispatcher, tracker, domain):
return[AllSlotsReset(),FollowupAction("response_language_changed")]
class Action_how_i_can_help(Action):
def name(self) -> Text:
return "response_how_i_can_help"
def run(self, dispatcher, tracker, domain):
sentence = tracker.latest_message['text']
check_language(sentence)
if En > Ar:
return dispatcher.utter_message("how I can help ? XX_OPTION_XX(network issue)")
elif En <= Ar:
return dispatcher.utter_message("اقدر اساعدك حضرتك ازاى ؟XX_OPTION_XX(مشكله شبكه)")
class Action_which_company(Action):
def name(self) -> Text:
return "response_which_company"
def run(self, dispatcher, tracker, domain):
sentence = tracker.latest_message['text']
check_language(sentence)
if En > Ar:
dispatcher.utter_message("i am working for Etisalat")
elif En <= Ar:
dispatcher.utter_message("انا اعمل لشركه اتصالات")
Domain file
version: '3.0'
session_config:
session_expiration_time: 60
carry_over_slots_to_new_session: false
intents:
- affirm
- stop_the_flow
- greet
- goodbye
- deny
- network_complains
- digits
- out_of_scope
- what_is_the_time
- who_are_you
- negative_words
- network_complains_issue
- change_language
- which_company
entities:
- comment_1
- comment_2
- issue_date
- issue_number
- issue_type
- location
- number
- number_1
- number_2
- restart
- stop_the_flow_answer
- language
slots:
issue_number:
type: text
influence_conversation: true
mappings:
- type: from_text
entity: issue_number
conditions:
- active_loop: network_complains_form
requested_slot: issue_number
issue_date:
type: text
influence_conversation: true
mappings:
- type: from_text
entity: issue_date
conditions:
- active_loop: network_complains_form
requested_slot: issue_date
issue_type:
type: text
influence_conversation: true
mappings:
- type: from_text
entity: issue_type
conditions:
- active_loop: network_complains_form
requested_slot: issue_type
number_1:
type: text
influence_conversation: true
mappings:
- type: from_text
entity: number
conditions:
- active_loop: network_complains_form
requested_slot: number_1
number_2:
type: text
influence_conversation: true
mappings:
- type: from_text
entity: number
conditions:
- active_loop: network_complains_form
requested_slot: number_2
comment_1:
type: text
influence_conversation: true
mappings:
- type: from_text
conditions:
- active_loop: network_complains_form
requested_slot: comment_1
comment_2:
type: text
influence_conversation: true
mappings:
- type: from_text
conditions:
- active_loop: network_complains_form
requested_slot: comment_2
location:
type: text
influence_conversation: true
mappings:
- type: from_text
conditions:
- active_loop: network_complains_form
requested_slot: location
restart:
type: text
influence_conversation: false
mappings:
- type: from_entity
entity: restart
stop_the_flow_answer:
type: text
influence_conversation: true
mappings:
- type: from_text
conditions:
- active_loop: stop_the_flow_answer_form
requested_slot: stop_the_flow_answer
language:
type: text
influence_conversation: true
mappings:
- type: from_text
entity: language
conditions:
- active_loop: change_language_form
requested_slot: language
requested_slot:
type: any
influence_conversation: false
mappings: []
actions:
- action_ask_stop_the_flow_answer
- action_ask_comment_1
- action_ask_comment_2
- action_ask_issue_date
- action_ask_issue_number
- action_ask_issue_type
- action_ask_location
- action_ask_number_1
- action_ask_number_2
- action_ask_language
- action_changing_language
- response_Issue_type_list
- response_confirm_network_complains_slots
- response_confrim
- response_final_answer
- response_goodbye
- response_greet
- response_no_flow
- response_refill
- response_rephrase
- response_time
- response_which_company
- response_who_are_you
- response_language_changed
- response_out_of_scope
- response_negative_words
- response_how_i_can_help
- stop_the_flow
- validate_network_complains_form
- validate_stop_the_flow_answer_form
- validate_change_language_form
forms:
network_complains_form:
required_slots:
- issue_number
- issue_date
- issue_type
- number_1
- comment_1
- number_2
- comment_2
- location
stop_the_flow_answer_form:
required_slots:
- stop_the_flow_answer
change_language_form:
required_slots:
- language
stories file
version: "3.0"
stories:
- story: network_complain_issue_1
steps:
- intent: greet
- action: response_greet
- intent: affirm
- action: network_complains_form
- active_loop: network_complains_form
- slot_was_set:
- requested_slot: null
- active_loop: null
- action: response_final_answer
- story: network_complain
steps:
- intent: network_complains_issue
- action: network_complains_form
- active_loop: network_complains_form
- slot_was_set:
- requested_slot: null
- active_loop: null
- action: response_final_answer
- story: goodbye_2
steps:
- intent: greet
- action: response_greet
- intent: deny
- action: response_goodbye
- story: goodbye
steps:
- intent: greet
- action: response_greet
- intent: goodbye
- action: response_goodbye
- story: digits with no reason
steps:
- intent: digits
- action: response_rephrase
- story: affirm with no reason
steps:
- intent: affirm
- action: response_rephrase
- story: affirm with no reason
steps:
- intent: network_complains
- action: response_rephrase
- story: ask for time
steps:
- intent: what_is_the_time
- action: response_time
- story: who are you
steps:
- intent: who_are_you
- action: response_who_are_you
- story: digits with no reason 2
steps:
- intent: greet
- action: response_greet
- intent: digits
- action: response_rephrase
- story: network_complain_2
steps:
- intent: network_complains_issue
- action: network_complains_form
- active_loop: network_complains_form
- slot_was_set:
- requested_slot: null
- active_loop: null
- action: response_final_answer
- story: which_company
steps:
- intent: which_company
- action: response_which_company
rule file
version: "3.0"
rules:
#- rule: network complains Activate form
# steps:
# - action: network_complains_form
# - active_loop: network_complains_form
#
#- rule: network complains submit
# condition:
# - active_loop: network_complains_form
# steps:
# - action: network_complains_form
# - slot_was_set:
# - requested_slot: null
# - active_loop: null
# - action: response_final_answer
#- rule: Ask the user to rephrase whenever they send a message with low NLU confidence
# steps:
# - action: action_default_fallback
# - action: response_rephrase
#
#- rule: trigger human handoff with action_unlikely_intent
# steps:
# - intent: nlu_fallback
# - action: response_rephrase
#
#- rule: trigger human handoff with action_unlikely_intent
# steps:
# - action: action_unlikely_intent
# - action: response_rephrase
- rule: out-of-scope2
steps:
- intent: out_of_scope
- action: response_out_of_scope
- rule: negative_words
steps:
- intent: negative_words
- action: response_negative_words
- rule: Restart
steps:
- intent: stop_the_flow
- action: response_goodbye
- rule: Restart1
condition:
- slot_was_set:
- restart: "stop"
steps:
- action: response_no_flow
- rule: stop_the_flow_answer
condition:
- active_loop: stop_the_flow_answer_form
steps:
- action: stop_the_flow_answer_form
- slot_was_set:
- requested_slot: null
- active_loop: null
- action: response_no_flow
- rule: change_language
steps:
- intent: change_language
- action: change_language_form
- active_loop: change_language_form
- rule: change_language_submit
condition:
- active_loop: change_language_form
steps:
- action: change_language_form
- slot_was_set:
- requested_slot: null
- active_loop: null
- action: action_changing_language
- rule: out-of-scope
steps:
- intent: nlu_fallback
- action: response_out_of_scope
nlu file
version: "3.0"
nlu:
- intent: greet
examples: |
- hey
- hello
- hi
- hello there
- good morning
- good evening
- moin
- hey there
- let's go
- hey dude
- goodmorning
- goodevening
- good afternoon
- ازيك
- صباح الخير
- صباح النور
- مساء النور
- مساء الخير
- صباحك بيضحك
- صباحك عسل
- هلو
- اهلا
- مرحبا
- عامل ايه
- هاى
- سلام عليكم
- سلام عليكم و رحمه الله و بركاته
- intent: goodbye
examples: |
- cu
- good by
- cee you later
- good night
- bye
- goodbye
- have a nice day
- see you around
- bye bye
- see you later
- thanks
- thank you
- سلام
- باى
- مع السلامه
- intent: affirm
examples: |
- yes
- y
- indeed
- of course
- that sounds good
- correct
- ok
- okay
- k
- affirm
- fine
- proceed
- ماشى
- تمام
- فل
- اوكيه
- اوك
- مظبوط
- اه
- نعم
- intent: deny
examples: |
- no
- n
- never
- I don't think so
- don't like that
- no way
- not really
- deny
- لا
- نو
- مستحيل
- تؤ
- لا شكرا
- لا لا
- intent: network_complains
examples: |
- [data](issue_type)
- [voice](issue_type)
- [both](issue_type)
- [oth](issue_type)
- [الاتنين](issue_type)
- [صوتى](issue_type)
- [داتا](issue_type)
- [اتا](issue_type)
- [صوت](issue_type)
- [اتنين](issue_type)
- intent: what_is_the_time
examples: |
- what is the time?
- what is the date?
- time now ?
- how much oclock
- tell me the time
- what is the date of today
- what is the time now
- الوقت كام
- الساعه كام دلوقتى
- النهاردا يوم ايه
- قولى الساعه كام
- كام الساعه
- النهاردا يوم كام
- وقت
-الوقت
- intent: network_complains_issue
examples: |
- i have network issue
- network issue
- i have data issue
- i have issue in my data
- have trouble in my voice network
- voice and data issues
- there is problem in my data
- my network data is not working
- voice issue
- voice problems
- i have issuse in both my data and network
- عندى مشكله داتا
- عندى مشكله صوت
- عندى مشكله صوتيه
- مشكله شبكه
- فيه مشكله فى الشبكه و الداتا
- نتورك
- نتورك اشيوى
- عندى مشكله نتورك
- intent: digits
examples: |
- [1](number)
- [3](number)
- [4](number)
- [5](number)
- [6](number)
- [7](number)
- [8](number)
- [9](number)
- [10](number)
- intent: change_language
examples: |
- i want to change language
- in what language can i talk to you ?
- change language
- are you bilingual?
- which languages do you speak?
- what languages do you speak?
- can you talk in arabic?
- how many languages can you speak?
- can you talk in other languages?
- do you speak english?
- want to make [English](language) my default
- want to make [Arabic](language) my default
- [English](language)
- [Arabic](language)
- [EN](language)
- [en](language)
- [Ar](language)
- [ar](language)
- تحويل اللغه الى [الانجليزيه](language)
- تغير اللغه
- غاوز اخلى اللغه [عربى](language)
- عاوز اخلى اللغه عربى
- عاوز اخلى اللغه انجليزى
- كلمنى عربى
- عربى
- عربيه
- عربي
- عربية
- كلمنى انجليزى
- بتتكلم كام لغه ؟
- تعرف تكلمنى عربى؟
- كلمنى لغه افهمها
- لغتك ايه
- اللغه
- لغه
- intent: who_are_you
examples: |
- who are you
- who with me
- Are you human ?
- Are you ai bot ?
- مين معايا
- مين انت
- انت بنى ادم
- انت الى
- هل انت انسان؟
- intent: which_company
examples: |
- which institute you talking in the name of?
- which company do you belong to?
- what company do you present?
- who are you working for ?
- do you work for Etisalat?
- intent: stop_the_flow
examples: |
- [let me exit the flow](restart)
- [stop the flow](restart)
- انهى الحديث
- [stop](restart)
- [stop the flow](restart)
- I have to leave
- Stop talking to me
- exit this chat
- Go away
- close bot
- I have got to go
- Stop doing this
- log out
- Go off
- Going
- Im done
- end the conversation
- stop
- End trial
- Shut up
- I want to quit
- I d like to stop doing this
- That is all
- Get lost
- I am out of here
- exit
- kill you
- i will kill you
- I am leaving
- close
- I'm done
- Enough
- Hey bot go away
- Ending this session
- I'm leaving
- علي المغادرة الآن
- انهي
- ما عندي طلبات أخرى
- اسكت
- انا رايح دلوقتي
- يكفي هذا
- حان الوقت لأذهب
- انهاء هذا الحديث
- ما عندي طلبات اخرى
- خروج
- حان الوقت لاذهب
- أنا ذاهب من هنا
- إنهاء هذا الحديث
- انصرف
- انهاء
- إنهي
- انا ذاهب من هنا
- ما تحكيش معي اكثر
- يا روبوت، روح من هون.
- إنهاء التجربة
- انه اء المحادثة
- انهاء التجربة
- انهي المحادثة
- توقف
- كفى مع هذا
- انهاؤ
- روح ع الجهنم
- فيش عندي شيء ثاني
- علي المغادرة الان
- روح مني
- انهأ
- اريد وقف العملية
- أنا رايح دلوقتي
- أريد وقف العملية
- ما تحكيش معي أكثر
- لقد انتهيت
- لا انهي الشات
- مش عاوز اكمل الحوار
- intent: out_of_scope
examples: |
- i want to order food
- what is 2+2?
- who is the us president ?
- sorry
- a
- s
- q
- d
- f
- h
- g
- ,
- .
- b
- v
- x
- c
- z
- j
- k
- l
- u
- t
- ا
- ض
- ص
- ث
- ق
- ف
- غ
- ع
- ه
- خ
- ح
- ج
- د
- ش
- س
- ي
- ب
- ل
- ت
- ت
- ن
- م
- ط
- ئ
- ء
- ؤ
- ر
- ى
- ة
- و
- ز
- ظ
- ياعم بقى
- شسبررشير
- intent: negative_words
examples: |
- fuck off
- fuck you
- fuck your ass
- you sucker
- suck my dick
- monkey
- donkey
- btich
- donkey
- stupid
- bitch
- kangro
- nigga
- dog
- cat
- mother fucker
- sucker
- idiot
- noob
- fucker
- fuck off
- a7a
- A7A
- kosom
- kosmok
- laboa
- ass
- manyok
- لبوه
- كسمك
- كسم
- احا
- متناك
- عربجى
- حيوان
- بضان
- عرص
- خول
- انت خرا
- انت غبى
- غبى
- انت عبيط
- عبيط
- حمار
- متخلف
- شمام
- مجنون
- خريان
- انت خريان
- synonym: data
examples: |
- data
- date
- atta
- dat
- datta
- ata
- dsta
- داتا
- دتا
- دااتا
- synonym: voice
examples: |
- voice
- voce
- ioce
- foice
- vose
- voise
- صوتى
- صوت
- صوط
- سوتى
- synonym: both
examples: |
- both
- bth
- bath
- bosth
- boh
- oth
- الاتنين
- اتنين
- انتنين
- synonym: stop
examples: |
- let me exit the flow
- stop the flow
- انهى الحديث
- stop
- synonym: Ar
examples: |
- Ar
- Arabic
- العربيه
- ar
- عربى
- ARABIC
- arabia
- synonym: En
examples: |
- English
- En
- en
- ENGLISH
- انجليزى
- الانجليزيه
domain.yml (3.8 KB) nlu.yml (8.9 KB) rules.yml (1.9 KB) stories.yml (1.9 KB) actions.py (32.5 KB)