Hey, I have the following rule:
- rule: submit form
condition:
- active_loop: user_offer_form
steps:
- action: user_offer_form
- active_loop: null
- slot_was_set:
- requested_slot: null
- action: action_get_offer
- action: utter_ask_deal
And here is the custom action:
class ActionGetOffer(Action):
def name(self) -> Text:
return "action_get_offer"
def run(self,dispatcher,tracker: Tracker,domain: "DomainDict",) -> List[Dict[Text, Any]]:
dispatcher.utter_message(text = "Ok! Let me see what I can do!")
product_price = 500
platform_bargain_percentage = 5
vendor_bargain_percentage = 5
max_bargain = platform_bargain_percentage + vendor_bargain_percentage
offer_price = int(tracker.get_slot("price"))
print(offer_price)
user_asked_percentage = (offer_price / product_price) * 100
current_bargain = tracker.get_slot('current_bargain') + 2
print(current_bargain)
if user_asked_percentage > current_bargain:
dispatcher.utter_message(text = "Okay so I just checked and sorry but we can't give away for that price!")
if tracker.get_slot('current_bargain_price') == 0:
current_bargain_price = (product_price - (((current_bargain)/100) * product_price))
else:
current_bargain_price = tracker.get_slot('current_bargain_price')
if current_bargain <= max_bargain:
dispatcher.utter_message(text = f"How about {str( product_price - (((current_bargain)/100) * product_price))}?")
else:
dispatcher.utter_message(text = "Hmm...wanna make a fresh offer then?")
# dispatcher.utter_message(response = 'utter_ask_deal')
return[SlotSet("current_bargain", value = float(current_bargain))]
And here is the utter_ask_deal:
utter_ask_deal:
- text: "Ok with this deal?"
buttons:
- title: "Yup"
payload: '/inform_intent{{"deal":"true"}}'
- title: "Nope"
payload: '/inform_intent{{"deal":"false"}}'
The rule is executing till action_get_offer but the utter_ask_deal is not getting executed, and the slot ‘current_bargain’ is also not getting updated.
Interestingly, when I’m not using SlotSet in the return statement but using it in the code directly, the next action is being executed but the slot is not updated in both cases.
Can someone help please?