Question about using databases

Is there anyway we can use data from database as a reply to user from a bot?

You can use custom actions.

In your custom action, you can connect to a database like in any other Python code. If you want to connect to a MySQL database, you can use the mysql-connector-python module. Here are its docs.

You query the database and get the reply, and use the dispatcher.utter_message(reply) function to make the chatbot, well, utter the message.

1 Like

hi, thanks a lot for helps but if you can to give exemple of code to do that in details please