I want to see a picture of a character named IronMan

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

@longnguyenQB Don’t be sad please. Share code like action file for blackwidow, or age where you wrote the code.

`dispacture.utter_message(template= "utter_ (what ever you mention in response)`")
return [] 

OR

responses:
utter_(whatever you mention):
 - text: Her is your answer Name: {name} and its Age: {age}

@nik202 I have shared here, this is an example for you to understand, my database is not like this

@longnguyenQB Its very hard for me to understand, but I mention in my above post, hope you understand.

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]]:

    document_name = tracker.get_slot("document_name")
    query_begin = "SELECT name FROM document"
    mycursor.execute(query_begin)
    result_query_begin = mycursor.fetchall()

     # write query
   query_end = "SELECT name, link, date FROM document WHERE name = '" + result_match + "'"

    mycursor.execute(query_end)
    myresult = mycursor.fetchall()
    dispatcher.utter_message(text=f"This is document you want: ")
            dispatcher.utter_message(myresult)

    return []

result : [[“Scientist for beginer”, “https://drive.google.com/file/d/1V2XS_2pY1yJjDZLJb-P-KoD9UU18N3wF/view?usp=sharing”, “2021-07-27 00:00:00”]]

  1. i want my result look like : name : Scientist for beginer , link : https://drive.google.com/file/d/1V2XS_2pY1yJjDZLJb-P-KoD9UU18N3wF/view?usp=sharing , date : 2021-07-27 00:00:00 @nik202

@nik202 this is my code