Hi, how do I put a rule that says i want action address_confirm to succeed ask_order, if in the initial stages of the story, a slot was set to “B”. else, save_order will succeed ask_order.
Please, I feel like its an easy solution, but I cant figure out
ask name
ask address
ask delivery_at_home_or_collect_from_shop
...10-15 lines of other actions
deny
confirm_address
confirm order
...
what I want is that the confirm address action at the end should only be predicted after the last deny if the slot delivery_at_home_or_collect_from_shop = “home”
otherwise it should just move on to “confirm order” action.
In your domain.yml file you will also have to change your delivery_at_home_or_collect_from_shop slot to have influence_conversation=true.
Second, have you looked into forms? Looking at your story though it looks like you’re collecting a lot of information from the user (ask_name, ask_address, ask_delivery_at_home_or_collect_from_shop etc.) It looks like all of these steps could be put into a form so you don’t have to write each of them in each story. When you process the form at the end you can add logic for determining if based on the user input you have to confirm their address or not.
Looking at this more you’d probably be better off putting this into a Form. With the form you can collect all the details about your user’s order and store that information in slots. If a user wants home delivery you can leverage the dynamic form behavior on your action server to confirm their address. Your code on the action server would look something like this:
class ValidateDeliveryForm(FormValidationAction):
def name(self) -> Text:
return "validate_delivery_form"
async def required_slots(
self,
slots_mapped_in_domain: List[Text],
dispatcher: "CollectingDispatcher",
tracker: "Tracker",
domain: "DomainDict",
) -> Optional[List[Text]]:
additional_slots = []
if tracker.slots.get("delivery_at_home_or_collect_from_shop") == "home":
# If the user wants home delivery then ask to confirm their address.
additional_slots.append("confirm_address")
return additional_slots + slots_mapped_in_domain
async def extract_confirm_address(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> Dict[Text, Any]:
if tracker.slots.get("requested_slot") == "confirm_address":
text_of_last_user_message = tracker.get_intent_of_latest_message()
return {"confirm_address": text_of_last_user_message}
When a user answers that they want home delivery the form will dynamically prompt for the user to confirm their address. Using the form helps avoid having to write a bunch of stories to collect data from the user. With the form you can also validate user responses are they are provided to make sure what they are providing valid responses.
Man, I think you can help me with another short problem if you dont mind.
The action_listen after action_record_order is extracting other stuff and trying to fill slots, so how do I stop the extraction for that specific action_listen