Beispiel #1
0
 def run(self, dispatcher: CollectingDispatcher, tracker: Tracker,
         domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
     if tracker.get_latest_input_channel() == 'facebook':
         message = {
             "text":
             "Is this correct (Yes/No/YesNo)?",
             "quick_replies": [{
                 "content_type": "text",
                 "title": "Yes",
                 "payload": "/affirm",
             }, {
                 "content_type": "text",
                 "title": "No",
                 "payload": "/deny",
             }, {
                 "content_type": "text",
                 "title": "YesNo",
                 "payload": "/deny",
             }, {
                 "content_type": "text",
                 "title": "NoYes",
                 "payload": "/deny",
             }]
         }
         # dispatcher.utter_custom_json(message)
         dispatcher.utter_message(json_message=message)
     else:
         dispatcher.utter_message(template="utter_greet")
     return []
Beispiel #2
0
    def submit(self, dispatcher: CollectingDispatcher, tracker: Tracker,
               domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

        url = tracker.get_slot("link_2_url")
        try:
            co2_in_tons = self.kb.calculate_emissions(tracker,
                                                      unit="short_tons")
        except ValueError as e:
            logger.error(f"calculate_emissions failed with: {e}")
            dispatcher.utter_message("Sorry, I was unable to calculate that.")
            return []
        departure_airport = tracker.get_slot("travel_departure")
        departure_iata = tracker.get_slot("iata_departure")
        destination_airport = tracker.get_slot("travel_destination")
        destination_iata = tracker.get_slot("iata_destination")

        message = f"A one-way flight from {departure_airport} ({departure_iata}) to {destination_airport} ({destination_iata}) "\
                  f"emits {co2_in_tons} of CO2. " \
                  f"It would be amazing if you bought offsets for that carbon! " \
                  f"There are some great, UN-certified projects you can pick from."

        if tracker.get_latest_input_channel() == "facebook":
            payload = hyperlink_payload(tracker, message, "Buy Offsets", url)
            dispatcher.utter_custom_json(payload)
        else:
            dispatcher.utter_message(message + f" [Buy Offsets]({url})")
        return [
            SlotSet("travel_departure"),
            SlotSet("iata_departure"),
            SlotSet("travel_destination"),
            SlotSet("iata_destination"),
            SlotSet("travel_flight_class")
        ]
Beispiel #3
0
    async def run(
        self,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> List[EventType]:

        dispatcher.utter_message(template="utter_handoff")
        handoff_to = tracker.get_slot("handoff_to")

        handoff_bot = handoff_config.get(handoff_to, {})
        url = handoff_bot.get("url")

        if url:
            if tracker.get_latest_input_channel() == "rest":
                dispatcher.utter_message(json_message={
                    "handoff_host": url,
                    "title": handoff_bot.get("title"),
                })
            else:
                dispatcher.utter_message(template="utter_wouldve_handed_off",
                                         handoffhost=url)
        else:
            dispatcher.utter_message(template="utter_no_handoff")

        return []
Beispiel #4
0
def send_option(dispatcher: CollectingDispatcher, tracker: Tracker):
    search_params = get_params(dispatcher, tracker)

    db_api.set_search_params(search_params)
    recipe = db_api.get_next_recipe()

    # Get the input channel so bot doesn't send something that cant be shown
    input_channel = tracker.get_latest_input_channel()

    if recipe is None:
        dispatcher.utter_message(template="utter_nomatches")
        sent = False
    elif recipe == "End":
        dispatcher.utter_message(template="utter_no_more_matches")
        sent = False
    else:
        if input_channel == "socketio":
            img_message = {
                "type": "image",
                "payload": {
                    "title": recipe["dish"],
                    "src": recipe["pic"],
                    "url": recipe["url"]
                },
            }
        else:
            img_message = recipe["dish"]
        dispatcher.utter_message(attachment=img_message)
        sent = True

    return sent
Beispiel #5
0
    async def fetch_slots(tracker: Tracker) -> List[EventType]:
        """Add user profile to the slots if it is not set."""

        slots = []

        # Start by copying all the existing slots
        for key in tracker.current_slot_values().keys():
            slots.append(SlotSet(key=key, value=tracker.get_slot(key)))

        user_channel = tracker.get_latest_input_channel()
        sender_id = tracker.sender_id
        user_profile = tracker.get_slot("user_profile")
        user_name = tracker.get_slot("user_name")

        db = Store()

        if user_profile is None:
            id = get_user_id_from_event(tracker)
            if id == anonymous_profile.get("id"):
                user_profile = anonymous_profile

            slots.append(SlotSet(key="user_profile", value=user_profile))

        if user_name is None:
            slots.append(
                SlotSet(key="user_name", value=user_profile.get("name")))

        return slots
Beispiel #6
0
def send_link(dispatcher: CollectingDispatcher, tracker: Tracker):
    recipe = db_api.get_current_recipe()
    input_channel = tracker.get_latest_input_channel()
    if input_channel == "socketio":
        message = f"Here is the link to the full recipe: " f"[{recipe['dish']}]({recipe['url']})"
        dispatcher.utter_message(text=message)
    else:
        dispatcher.utter_message(
            text=f'Here is the link to the full recipe {recipe["url"]}')
Beispiel #7
0
    def run(self, dispatcher: CollectingDispatcher, tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
        districts = [
            'Thiruvananthapuram', 'Kollam', 'Alappuzha', 'Pathanamthitta',
            'Kottayam', 'Idukki', 'Ernakulam', 'Thrissur', 'Palakkad',
            'Malappuram', 'Kozhikode', 'Wayanad', 'Kannur', 'Kasaragod'
        ]
        input_channel = tracker.get_latest_input_channel()
        i = 0
        if input_channel == "facebook":  # FB allows upto 3 buttons. 14 districts. Adding check to avoid index out of range error at 14
            dispatcher.utter_message(text="Please Select the district.")
            while i < 14:
                if i < 12:
                    dispatcher.utter_message(
                        text="->",
                        buttons=[{
                            "title":
                            districts[i],
                            "payload":
                            "/inform_district{\"district\":" + " \"" +
                            districts[i] + "\"}"
                        }, {
                            "title":
                            districts[i + 1],
                            "payload":
                            "/inform_district{\"district\":" + " \"" +
                            districts[i + 1] + "\"}"
                        }, {
                            "title":
                            districts[i + 2],
                            "payload":
                            "/inform_district{\"district\":" + " \"" +
                            districts[i + 2] + "\"}"
                        }])
                else:
                    dispatcher.utter_message(
                        text="->",
                        buttons=[{
                            "title":
                            districts[i],
                            "payload":
                            "/inform_district{\"district\":" + " \"" +
                            districts[i] + "\"}"
                        }, {
                            "title":
                            districts[i + 1],
                            "payload":
                            "/inform_district{\"district\":" + " \"" +
                            districts[i + 1] + "\"}"
                        }])
                i += 3

        else:
            dispatcher.utter_message(template="utter_district_select")
        return []
Beispiel #8
0
    def run(self, dispatcher: CollectingDispatcher, tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
        if tracker.get_latest_input_channel() == 'facebook':
            message = {
                "content": {
                    "type": "audio",
                    "audio": {
                        "url":
                        "'https://file-examples.com/wp-content/uploads/2017/11/file_example_MP3_700KB.mp3'"
                    }
                }
            }
            dispatcher.utter_message(json_message=message)

        return []
Beispiel #9
0
 def run(self, dispatcher: CollectingDispatcher,
         tracker: Tracker,
         domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
     
     restaurants = tracker.get_slot("more_restaurants")
     if restaurants!=None:
         if(tracker.get_latest_input_channel()=="slack"):
             restData = getResto_Slack(restaurants,show_more_results=False)
             dispatcher.utter_message(text="Here are few more restaurants",json_message=restData)
         else:
             dispatcher.utter_message(text="Here are few more restaurants",json_message={"payload":"cardsCarousel","data":restaurants})
         
         return [SlotSet("more_restaurants", None)] 
     else:
         dispatcher.utter_message(text="Sorry No more restaurants found")
         return []
Beispiel #10
0
 def submit(
     self,
     dispatcher: CollectingDispatcher,
     tracker: Tracker,
     domain: Dict[Text, Any],
 ) -> List[Dict]:
     load = tracker.get_slot('json')
     channel = tracker.get_latest_input_channel()
     print(channel)
     print(load)
     if load:
         message = "Please provide details on the issue that you are facing."
     else:
         message = "shit"
     dispatcher.utter_message(text=message)
     return []
Beispiel #11
0
    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

        print("====Inside ActionSearchRestaurants Without Cuisine====")
        print()
        location=tracker.get_slot("location")
        cuisine=tracker.get_slot("cuisine")
        lat=tracker.get_slot("latitude")
        lon=tracker.get_slot("longitude")
        entity_id=tracker.get_slot("location_id")
        entity_type=tracker.get_slot("location_type")
        city_id=tracker.get_slot("city_id")

        locationEntity=next(tracker.get_latest_entity_values("location"), None)
        cuisineEntity=next(tracker.get_latest_entity_values("cuisine"), None)
        user_locationEntity=next(tracker.get_latest_entity_values("user_location"), None)
        
        ##set the cuisine to any of the cuisine name or you leave it empyt
        cuisine_id=""
        restaurants=zomatoApi.searchRestaurants(entity_id,entity_type, cuisine_id,"")
        
        ## check if restaurants found
        if(len(restaurants)>0):

            if(tracker.get_latest_input_channel()=="slack"):
                more_restaurants=[]
                if(len(restaurants)>5):
                    restData=getResto_Slack(restaurants[:5],show_more_results=True)
                    more_restaurants=restaurants[5:]
                else:
                    restData=getResto_Slack(restaurants,show_more_results=False)

                dispatcher.utter_message(text="Here are the few restaurants that matches your preferences 😋",json_message=restData)
                return [SlotSet("more_restaurants", more_restaurants)]    
            else:
                if(len(restaurants)>5):   
                    dispatcher.utter_message(text="Here are the few restaurants that matches your preferences 😋",json_message={"payload":"cardsCarousel","data":restaurants[:5]})
                    return [SlotSet("more_restaurants", restaurants[5:])]
                else:
                    dispatcher.utter_message(text="Here are the few restaurants that matches your preferences 😋",json_message={"payload":"cardsCarousel","data":restaurants})
                    return [SlotSet("more_restaurants", None)]    
        
        else:    
            dispatcher.utter_message("Sorry we couldn't find any restaurants that serves {} cuisine in {} 😞".format(cuisine,location))
            return [UserUtteranceReverted()] 
Beispiel #12
0
def test_latest_input_channel():
    tracker = Tracker(
        "default",
        {},
        {"intent": {
            "name": "some_intent",
            "confidence": 1.0
        }},
        [
            UserUttered("my message text", input_channel="superchat"),
            ActionExecuted("action_listen"),
        ],
        False,
        None,
        {},
        "action_listen",
    )

    assert tracker.get_latest_input_channel() == "superchat"
Beispiel #13
0
    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
        print()
        print("====Inside ActionSearchRestaurants====")
        print()

        ## extract the required slots
        location=tracker.get_slot("location")
        cuisine=tracker.get_slot("cuisine")
        lat=tracker.get_slot("latitude")
        lon=tracker.get_slot("longitude")
        entity_id=tracker.get_slot("location_id")
        entity_type=tracker.get_slot("location_type")
        city_id=tracker.get_slot("city_id")

        ## extract the entities
        locationEntity=next(tracker.get_latest_entity_values("location"), None)
        cuisineEntity=next(tracker.get_latest_entity_values("cuisine"), None)
        user_locationEntity=next(tracker.get_latest_entity_values("user_location"), None)
        latEntity=next(tracker.get_latest_entity_values("latitude"), None)
        lonEntity=next(tracker.get_latest_entity_values("longitude"), None)

        ## if we latitude & longitude entities are found, set it to slot
        if(latEntity and lonEntity):
            lat=latEntity
            lon=lonEntity
        
        ## if user wants to search restaurants in his current location
        if(user_locationEntity or (latEntity and lonEntity) ):
            ##check if we already have the user location coordinates stoed in slots
            if(lat==None and lon==None):
                dispatcher.utter_message(text="Sure, please allow me to access your location 🧐",json_message={"payload":"location"})
                
                return []
            else:
                locationEntities=zomatoApi.getLocationDetailsbyCoordinates(lat,lon)
                location=locationEntities["title"]
                city_id=locationEntities["city_id"]
                entity_id=locationEntities["entity_id"]
                entity_type=locationEntities["entity_type"]
                
                ## store the user provided details to slot
                SlotSet("location", locationEntities["title"])
                SlotSet("city_id", locationEntities["city_id"])
                SlotSet("location_id", locationEntities["entity_id"])
                SlotSet("location_type", locationEntities["entity_type"])

        ## if user wants to search restaurants by location name
        if(locationEntity):
            locationEntities=zomatoApi.getLocationDetailsbyName(locationEntity)
            if(locationEntities["restaurants_available"]=="no"):
                dispatcher.utter_message("Sorry I couldn't find any restaurants  😓")
                return []
            entity_id=locationEntities["entity_id"]
            entity_type=locationEntities["entity_type"]
            city_id=locationEntities["city_id"]
            SlotSet("location", locationEntities["title"])

        ##get the cuisine id for the cuisine name user provided
        cuisine_id=zomatoApi.getCuisineId(cuisine,city_id)
        
        print("Entities:  ",entity_id," ",entity_type," ",cuisine_id," ",location," ",cuisine)
        print()

        ## if we didn't find the restaurant for which user has provided the cuisine name
        if(cuisine_id==None):
            dispatcher.utter_message("Sorry we couldn't find any restaurants that serves {} cuisine in {}".format(cuisine,location))
            return [UserUtteranceReverted()] 
        else:
            ## search the restaurts by calling zomatoApi api
            restaurants=zomatoApi.searchRestaurants(entity_id,entity_type, cuisine_id,"")

            ## check if restaurants found
            if(len(restaurants)>0):

                if(tracker.get_latest_input_channel()=="slack"):
                    more_restaurants=[]
                    if(len(restaurants)>5):
                        restData=getResto_Slack(restaurants[:5],show_more_results=True)
                        more_restaurants=restaurants[5:]
                    else:
                        restData=getResto_Slack(restaurants,show_more_results=False)

                    dispatcher.utter_message(text="Here are the few restaurants that matches your preferences 😋",json_message=restData)
                    return [SlotSet("more_restaurants", more_restaurants)]    
                else:
                    if(len(restaurants)>5):   
                        dispatcher.utter_message(text="Here are the few restaurants that matches your preferences 😋",json_message={"payload":"cardsCarousel","data":restaurants[:5]})
                        return [SlotSet("more_restaurants", restaurants[5:])]
                    else:
                        dispatcher.utter_message(text="Here are the few restaurants that matches your preferences 😋",json_message={"payload":"cardsCarousel","data":restaurants})
                        return [SlotSet("more_restaurants", None)]    
            
            else:    
                dispatcher.utter_message("Sorry we couldn't find any restaurants that serves {} cuisine in {} 😞".format(cuisine,location))
                return [UserUtteranceReverted()] 
Beispiel #14
0
    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
        print()
        print("====Inside ActionAskCuisine====")
        print()
        # print("tracker: ",)
        channel=tracker.get_latest_input_channel()

        location=tracker.get_slot("location")
        cuisine=tracker.get_slot("cuisine")
        lat=tracker.get_slot("latitude")
        lon=tracker.get_slot("longitude")
        
        locationEntity=next(tracker.get_latest_entity_values("location"), None)
        cuisineEntity=next(tracker.get_latest_entity_values("cuisine"), None)
        user_locationEntity=next(tracker.get_latest_entity_values("user_location"), None)
        latEntity=next(tracker.get_latest_entity_values("latitude"), None)
        lonEntity=next(tracker.get_latest_entity_values("longitude"), None)

        location=tracker.get_slot("location")
        cuisine=tracker.get_slot("cuisine")
        lat=tracker.get_slot("latitude")
        lon=tracker.get_slot("longitude")
        entity_id=tracker.get_slot("location_id")
        entity_type=tracker.get_slot("location_type")
        city_id=tracker.get_slot("city_id")

       
        if(latEntity and lonEntity):
            lat=latEntity
            lon=lonEntity

        if(user_locationEntity or (latEntity and lonEntity) ):
            if(lat==None and lon==None):
                dispatcher.utter_message(text="Sure, please allow me to access your location 🧐",json_message={"payload":"location"})
                
                return []
            else:
                locationEntities=zomatoApi.getLocationDetailsbyCoordinates(lat,lon)
                location=locationEntities["title"]
                city_id=locationEntities["city_id"]
                entity_id=locationEntities["entity_id"]
                entity_type=locationEntities["entity_type"]

                SlotSet("location", locationEntities["title"])
                SlotSet("city_id", locationEntities["city_id"])
                SlotSet("location_id", locationEntities["entity_id"])
                SlotSet("location_type", locationEntities["entity_type"])


        if(locationEntity):
            locationEntities=zomatoApi.getLocationDetailsbyName(locationEntity)
            entity_id=locationEntities["entity_id"]
            entity_type=locationEntities["entity_type"]
            city_id=locationEntities["city_id"]
            SlotSet("location", locationEntities["title"])
            print("locationDetails: ",locationEntities)
            print()
        
     

        ## check if the restaurants are available in the user provided location
        if(locationEntities["restaurants_available"]=="no"):
            dispatcher.utter_message("Sorry, No restaurants available in the location you have  provided 🤯")
            return [UserUtteranceReverted()] 

        else:
            locationDetails=zomatoApi.getLocationDetails(locationEntities["entity_id"],locationEntities["entity_type"])
            if channel=="slack":
                dispatcher.utter_message(template="utter_ask_cuisine",buttons=locationDetails["top_cuisines"])
            else:
                dispatcher.utter_message(template="utter_ask_cuisine",json_message={"payload":"quickReplies","data":locationDetails["top_cuisines"]})
        
            return [SlotSet("city_id", locationEntities["city_id"]),SlotSet("location_id", locationEntities["entity_id"]),SlotSet("location_type", locationEntities["entity_type"])]
 def is_sender_id_token_exist(self, sender_id, tracker: Tracker):
     data_user = self.__data.get(sender_id)
     if data_user is None:
         return api.API(tracker.get_latest_input_channel())
     return data_user.token
    def check_slot(self, slot, tracker: Tracker,
                   dispatcher: CollectingDispatcher) -> {}:
        message = None
        if slot == _KENDALA_NOMOR_KONTRAK:
            text = "Silakan ketik angka di bawah apabila sesuai dengan kendala Anda\n"\
                "1. penagihan atas kontrak orang lain\n"\
                "2. nomor kontrak belum diterima\n"\
                "3. lainnya, sambungkan Live Agent"
            message = QuickRepliesBuilder()\
                .set_text(value=text)\
                .set_content(title="1", payload="1")\
                .set_content(title="2", payload="2")\
                .set_content(title="3", payload="3")\
                .channel(channel=tracker.get_latest_input_channel())\
                .build()
        elif slot == _IS_KONTRAK_AKTIF:
            message = QuickRepliesBuilder()\
                .set_text("Apakah Anda memiliki kontrak aktif?") \
                .set_content(title="Iya", payload="iya") \
                .set_content(title="Tidak", payload="tidak") \
                .channel(channel=tracker.get_latest_input_channel()) \
                .build()
        elif slot == _NOMOR_KONTRAK:
            message = {}
        elif slot == _IS_FOLLOW_UP_CABANG:
            if tracker.get_slot(_KENDALA_NOMOR_KONTRAK) == '2':
                data_user = self.get_user_data(tracker)
                is_kontrak_kenal = tracker.get_slot(_IS_KONTRAK_KENAL)
                if isinstance(is_kontrak_kenal, bool):
                    if is_kontrak_kenal is True:
                        message_list_bucket = self.generate_contract(
                            show_nomor_kontrak=True, data_user=data_user)
                        for message_list in message_list_bucket:
                            dispatcher.utter_message(''.join(message_list))
                else:
                    data_user.nomor_dipilih.sort()
                    contract_list = []
                    sum_contract_list = data_user.sum_contract_list
                    for i in data_user.nomor_dipilih:
                        contract_list.append(sum_contract_list[int(i) - 1])
                    data_user.sum_contract_list = contract_list
                    self.update_user_data(data_user=data_user)
                    message_list_bucket = self.generate_contract(
                        show_nomor_kontrak=True, data_user=data_user)
                    for message_list in message_list_bucket:
                        dispatcher.utter_message(''.join(message_list))
            message = QuickRepliesBuilder() \
                .set_text("Apakah Anda bersedia cabang kami melakukan follow up kepada Anda maksimal 2x24 jam?") \
                .set_content(title="Iya", payload="iya") \
                .set_content(title="Tidak", payload="tidak") \
                .channel(channel=tracker.get_latest_input_channel()) \
                .build()
        elif slot == _NOMOR_KTP:
            message = {
                "text":
                "Kami membutuhkan data Anda untuk melakukan pencocokan data terlebih dulu "
                "sebagai keamanan data. Silakan ketik NIK Anda"
            }
        elif slot == _IS_KONTRAK_KENAL:
            message = {}
            data_user = self.get_user_data(tracker)
            dispatcher.utter_message(
                "Apakah Anda mengenal kontrak dibawah ini?")
            data_user.index = 1
            message_list_bucket = self.generate_contract(data_user=data_user)
            for message_list in message_list_bucket:
                dispatcher.utter_message(''.join(message_list))

            qr_content = []
            if data_user.index > 1:
                for i in range(1, data_user.index, 1):
                    qr_content.append({"title": str(i), "payload": str(i)})
            qr_message = QuickRepliesBuilder()\
                .set_text("Silakan ketik pilihan Anda")\
                .set_content_by_dictionary(qr_content)\
                .set_content(title="Iya, semua", payload="iya, semua")\
                .set_content(title="Tidak", payload="tidak")\
                .channel(tracker.get_latest_input_channel())\
                .build()
            dispatcher.utter_custom_json(qr_message)
        logging.debug(f'message: {message}')
        return message
Beispiel #17
0
    def submit(
        self,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> List[Dict[Text, Any]]:

        url = tracker.get_slot("link_2_url")
        try:
            co2_in_tons = self.kb.calculate_emissions(tracker,
                                                      unit="short_tons")

        except ValueError as e:
            logger.error(f"calculate_emissions failed with: {e}")
            dispatcher.utter_message("Sorry, I was unable to calculate that.")
            return []
        departure_airport = tracker.get_slot("travel_departure")
        departure_iata = tracker.get_slot("iata_departure")
        destination_airport = tracker.get_slot("travel_destination")
        destination_iata = tracker.get_slot("iata_destination")
        stopover_airport = tracker.get_slot("travel_stopover")
        stopover_iata = tracker.get_slot("iata_stopover")
        previous_entered_flight = tracker.get_slot("previous_entered_flight")

        if not stopover_iata:
            message = (
                f"A one-way flight from {departure_airport} ({departure_iata}) to {destination_airport} ({destination_iata}) "
                f"emits {co2_in_tons[0]} of CO2. "
                f"It would be amazing if you bought offsets for that carbon! "
                f"There are some great, UN-certified projects you can pick from."
            )
        else:
            message = (
                f"The trip from {departure_airport} ({departure_iata}) to {destination_airport} ({destination_iata}) "
                f"via {stopover_airport} ({stopover_iata}) emits {float(co2_in_tons[0].split()[0])+float(co2_in_tons[1].split()[0]):.1f} {co2_in_tons[0].split()[1]} of CO2. "
                f"The first leg emits {co2_in_tons[0]} of CO2. "
                f"The second leg emits {co2_in_tons[1]} of CO2."
                f"It would be amazing if you bought offsets for that carbon! "
                f"There are some great, UN-certified projects you can pick from."
            )

        if tracker.get_latest_input_channel() == "facebook":
            payload = hyperlink_payload(tracker, message, "Buy Offsets", url)
            dispatcher.utter_custom_json(payload)
        else:
            dispatcher.utter_message(message + f" [Buy Offsets]({url})")

        slots_to_set = [
            SlotSet("travel_departure"),
            SlotSet("iata_departure"),
            SlotSet("travel_destination"),
            SlotSet("iata_destination"),
            SlotSet("travel_stopover"),
            SlotSet("iata_stopover"),
            SlotSet("travel_flight_class"),
        ]

        if tracker.get_slot("travel_stopover"):
            return slots_to_set + [
                SlotSet("previous_entered_flight"),
            ]
        else:
            return slots_to_set