I want to see a picture of a character named IronMan

@nik202 don’t load from .csv, i load directly from mySql

Connect to Database (MySQL)

mydb = mysql.connector.connect( host=“localhost”, user=“", password="***”, database=“chatbot”, auth_plugin=‘mysql_native_password’) mycursor = mydb.cursor()

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)

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

    result_match = match_entites(name_document,result_query_begin)
    print(result_match)

    #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"Đây là link tài liệu {result_match} mà bạn đang cần: ", json_message = myresult)
    return []

match_entites i use fuzzywuzzy as you instructed and it works great.

@longnguyenQB I am giving you hint/ logic, please try it as I not remember the code, but run it right now ok

SELECT CONVERT(CAST(name as BINARY) USING utf8) as name FROM document 
SELECT name, CAST(CONVERT(name USING utf8) AS binary)
FROM document
WHERE name=.............................;   

I not understand your where command.

@longnguyenQB Are you anywhere using excel or .csv file to push into SQL database?

@longnguyenQB Name the SQL database you using?

@longnguyenQB There can be an endless solution, like SQL Editor Query, Web browser , HTTP etc etc

@nik202 I think the problem here is not the query, it’s the JSON. This is the result of actions.py:

And here is the result when run Rasa Shell:

@longnguyenQB you data coming from where, database so how it can be JSON? I asked above some questions, can you reply that also? see my above post and answer.

Try to do

mydb = mysql.connector.connect(host="localhost", user="...", password="...", database="chatbot", auth_plugin="mysql_native_password", charset="utf8")

It it doesn’t work, try out all the answers from this post: unicode - Writing UTF-8 String to MySQL with Python - Stack Overflow

1 Like

@ChrisRahme thank you very much! again you helped me to solve my problem.

1 Like

Glad to know. Please mark the answer that helped you as solution to close the thread :slight_smile:

hi! how do i mark the answer to close the thread?

@longnguyenQB Hi, I guess you need to change the Topic to only Rasa Open Source and delete feedback on rasa open source. Good Luck!

Under my answer you should see " :white_check_mark: Solution". Click on it to close the thread.

And as Nik said, please also change the topic.

@longnguyenQB Till you not changed, you can’t see the tick at any solution.

1 Like

@nik202 sorry I can’t bookmark Solution for both of you, wish I could bookmark it for you. Thank you very much for your enthusiastic help, thank you for accompanying me in the process of building the chatbot. Thanks very much!!

2 Likes

@ChrisRahme thank you very much, thanks to you i solved my problem!!!

1 Like

i dont want to spam the post, its not about 10 minute wait… .most of the question are pending from many days, its just nobody answers… thats why!!! and please dont need to be that rude, i wil delete the comment

Glad to be of help!

@longnguyenQB Finally! Congratulations :+1:. No worries. I’m glad you tick the solution for Chris​:handshake:. But, What is the real age of Black Window :stuck_out_tongue: she not look 40 :frowning: Good Luck!

1 Like