I want to see a picture of a character named IronMan

Hi everyone! I want my bot sent picture if i ask like that. please tell me how!!! I have a list of pictures of Avenger characters: Ironman, Hulk, Captain American, BlackWidow,… at driver : picture_avenger – Google Drive So how i can do this?

Input: “I want to see a picture of a character named (IronMan)[character_name]” output: " here is a picture of {character_name} :

" Thanks very much!!!

@longnguyenQB from google drive you have images or images url?

1 Like

Thank you for being the first to reply to me. No need to get the url from google drive, it’s just an example, let’s say I have 1 excel file (whatever) like this:

Input: I want to see Ironman’s picture Output: This is ironman’s picture: How i can do this? (May not need an excel file. Can you suggest a way to get a picture of a character if we have a list of names, features, image links like this) Thanks very much!!!

if code on dataframe i am just : df.loc(df.name == name).link_image but i dont know how to do this on rasa??

@longnguyenQB Start with this and then see the concept of FuzzyWuzzy.

class GetImage(Action):
    def __init__(self):
        self.faq_data = pd.read_csv('./data/image.csv')

    def name(self) -> Text:
        return "action_get_image"
    def run(self, dispatcher: Collecting ,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

I have shared you the idea, go and check some resources on how to fetch the data from excel or csv using fuzzywuzzy.

@longnguyenQB are you able to solve this with suggestion?

Thanks you very much!! I missed you. This is my action custom: class ActionSearchDocument(Action):

def name(self) -> Text:
    return "action_search_document"

def run(self, dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
    name_document = tracker.get_slot("name_document")

    #write query
    query = "SELECT link FROM document WHERE name = '" + name_document + "'"

    # dispatcher.utter_message(text=f"Đây là link liệu mà bạn đang cần: {query} ")

    myresult = mycursor.fetchall()
    dispatcher.utter_message(text=f"Đây là link tài liệu {name_document} mà bạn đang cần: ", json_message = myresult)
    return []

@longnguyenQB Aww, you missed me or messaged me? :wink: are you able to solve this now, working?

1 Like

thank you! i have solved it. Only 1 important problem remains, that is to match the user’s speech with the address to be queried. ex: i want to see a image of iromman so my bot has to understand it is ironman. Maybe I will write more statements using fuzzywuzzy. hope it works.

sorry I’m not good at English. :heart_eyes:

@longnguyenQB Yes, for your case you need to write more statements based on address, age, and name.

@longnguyenQB Speech or Text. Yes, you spot the point, you need to provide a set of variation of question for the answers in your training example such as

    question                            | answer
    I want to see Iron man image        | url link
    can you show me Ironman pic         | url link
    show me ironman photo               | url link

etc etc or change the ratio value such as 80 or 85 to match the exact sentence of words.

@longnguyenQB do remember to follow same for others, the data should be balance with the values, else it will throw errors. No NULL value.

PS: your English is just fine :slight_smile:

1 Like

wait a minute!! the problem is that the user misspelled, and the entities received by the chatbot are ‘iromman’, not ironman. The query in the database would be: SELECT link FROM document WHERE name = ‘iromman’ chatbot will not return the result expected by the user. Because in my database there is no entity named iromman.

@longnguyenQB you using SQL or .csv (Excel)?

@longnguyenQB Please visit my other thread FAQ - Mass integration from Excel - How to perform it? - #2 by nik202

@longnguyenQB What is the set value of fuzzywuzzy?

Hi! i using SQL

@longnguyenQB you can validate the value in this case, or you can ask for rephrase or show default message (fallback)


I'm sorry, I didn't get you. Can you please write again what you looking at?

looks like it’s going to be difficult, but I’m hoping for a method that doesn’t use fallback.My idea is like this: “i want to see an image of Irommman” . Entities that I get “irommman”. I will match this entity with all the places in the database, for example: “wonderwoman”, “hulk”, “thor”, “supperman”, “flash”, “batman”, “captainmarvel”, “spiderman”, “ironman”. the result I would expect would be “irommman” = “ironman” . let’s say fuzzywuzzy score > 80 for example. I will try and let you know later. hope it works.

@longnguyenQB you can see synonyms or lookuptabla in this case. @longnguyenQB as you are using SQL, in my case I am using EXCEL and its working fine with the wrong spelling.