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 : https://drive.google.com/drive/folders/16kjeUjYXQjBWwuwiXnT0m87u9mU5BXro?usp=sharing 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?

1 Like

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")
    print(name_document)

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

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

    mycursor.execute(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)

utter_default_message:

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.

image please help me!!

@longnguyenQB Not get you, what you asking can you please elaborate? and do mention me with @ and my name nik202 so that I can get notifications.

@nik202

  1. My utter_message returns the following: [[ “BlackWidow”, “40”], [ “Hawkeye” , “42”]]

  2. How do my results look like this?

Name: BlackWidow Age: 40 Name: Hawkeye Age: 42

@longnguyenQB You can either use dispatcher if you are using custom action in actions.py or responses in domain.yml, with the values, as I can’t see the actual code; so I can’t tell you exact format.

@nik202 :cry: the problem is displaying the result, i don’t know how to make it look like i want