Beispiel #1
0
 def run(self, dispatcher, tracker, domain):
     dispatcher.utter_message(template="utter_iamabot")
     dispatcher.utter_message(template="utter_explain_whatspossible")
     return [UserUtteranceReverted(), ActionReverted()]
Beispiel #2
0
 def run(self, dispatcher, tracker, domain):
     dispatcher.utter_message(template="utter_respond_insult")
     return [UserUtteranceReverted(), ActionReverted()]
Beispiel #3
0
 def run(self, dispatcher, tracker, domain):
     dispatcher.utter_message(template="utter_noworries")
     dispatcher.utter_message(template="utter_mood_greet")
     return [UserUtteranceReverted(), ActionReverted()]
Beispiel #4
0
 def run(self, dispatcher, tracker, domain):
     dispatcher.utter_message(template="utter_mood_unhappy")
     return [UserUtteranceReverted(), ActionReverted()]
Beispiel #5
0
    def submit(
        self,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> List[Dict]:
        flight_no = tracker.get_slot("flight_no")
        class_type = tracker.get_slot("class_type")
        seat_type = tracker.get_slot("seat_type")
        seat_title = ["W", "A"]
        if seat_type == "window seat":
            seat_title = seat_title[0]
        elif seat_type == "aisle seat":
            seat_title = seat_title[1]
        else:
            seat_title = seat_title[random.randint(0, 1)]
        user_name = tracker.get_slot("user_name")
        passport_no = tracker.get_slot("passport_no")
        email = tracker.get_slot("email")
        with open("ticket.json") as f:
            data = json.loads(f.read())
            # myFormat = "{:<10} {:<10} {:<20} {:<10} {:<10} {:<20} {:<10}"
            # list1 = [myFormat.format("From", "To", "Airlines", "Seats No.", "Flight No.", "Date", "Price")]
            list1 = []
            for item in data:
                if item["Flight No"].upper() == flight_no.upper() and \
                        item['From'].upper() == tracker.get_slot("fromloc_city") and \
                        item['To'].upper() == tracker.get_slot("toloc_city"):
                    Flight_No = item['Flight No']
                    From = item['From']
                    To = item['To']
                    Airline = item['Airlines']
                    Date = item['Date']
                    Seat = seat_title + str(
                        random.randint(0, int(item['Seats'])))
                    Price = item['Price']
                    list1.append("Flight : " + Flight_No + "  \nFrom - To : " +
                                 From + " - " + To + "  \nAirline : " +
                                 Airline + "  \nDate : " + Date +
                                 "  \nSeat : " + Seat + "  \nPrice : " + Price)
                    # list1.append(myFormat.format(item['From'], item['To'], item['Airlines'], seat_title+str(random.randint(0, int(item['Seats']))), item['Flight No'], item['Date'], item['Price']))
        if len(list1) > 0:
            dispatcher.utter_message(
                "Well, I have you booked on a flight that will fit your schedule. The tickets will arrive by mail in a few days."
            )
            dispatcher.utter_message("Here is your flight ticket information.")
            ticket = ""
            for i in range(len(list1)):
                ticket += (list1[i])
            ticket += "  \nName: {}  \nClass: {}  \nPassport No.: {}".format(
                str(user_name).upper(),
                str(class_type).upper(), str(passport_no))
            dispatcher.utter_message(ticket)
        else:
            dispatcher.utter_message(
                "Sorry! There are no flights available...\n\nPlease check the Flight No."
            )
            return [ActionReverted(), SlotSet("flight_no", None)]

        # dispatcher.utter_message("NAME: {}  \nCLASS: {}  \nPassport No.: {}".format(str(user_name).upper(), str(class_type).upper()), str(passport_no))

        dispatcher.utter_message(template="utter_precautions_for_boarding")
        return []