How can I connect to mysql database to extract information from it


I’m trying to build a student information chatbot where all the details about students are stored in an external database. I want to know how can I connect and extract the information. I’m new to bp btw.


@NikhilJoshua The best way would be to create a module.
Your module would:

  • Connect to the mysql database using knex
  • Expose an API so you can query that database
  • Create actions that query that API

There’s more informations for module creation here :
To connect to your mysql database, you can use Knex:


Thanks, I need small clarification in the second point. I don’t exactly understand “Expose an API”. Infact I have a hard time understanding API for AI. I’m kinda new to this stuff :sweat_smile:


@NikhilJoshua Basically, since you need to access data from a custom source, you need to link that source to Botpress. Your module will expose a REST Api, then you can consume it using actions.

Here’s a basic example on how to do that:


@allardy Thank you very much :slight_smile:


@NikhilJoshua You are welcome ! We will release a new version tonight, and we’ve included an example on how to create a complete module.

Feel free to use that template to get a head start:


Cool Thank you :grin: