Chat to Your MySQL Database
Enable your AI agent to retrieve data from a remote MySQL database to answer your visitors’ questions.
The MySQL Database action allows your AI agent to query a remote MySQL database to retrieve information and answer visitor questions. This is useful for providing real-time data from your application database, inventory systems, CRMs, or any data stored in MySQL.
How it Works
When a visitor asks a question that requires database information, the AI agent:
- Discovers the database schema (table structure)
- Generates the appropriate SQL query
- Executes the query (read-only) and returns the results
All queries are read-only (SELECT only). The agent cannot modify your data.
Adding the MySQL Database Action
In your chatbot dashboard, go to Configuration > Tools & Actions.
Click the + Add Action button.
Find MySQL Database and click Add.
Configuration
Name (required)
A descriptive name for the action. This helps the AI agent understand what data this database contains.
Example: query_inventory
Description (required)
A description of the action and when it should be used. Be specific about what data is available.
Use this action when the user asks about product inventory, stock levels, or product details.
Host (required)
The hostname or IP address of your MySQL server.
Example: db.example.com or 127.0.0.1
Port (required)
The port your MySQL server listens on. Default is 3306.
Database Name (required)
The name of the database to connect to.
Example: my_database
Username (required)
The MySQL username for authentication.
Password (required)
The password for the MySQL user.
SSL (optional)
Enable SSL/TLS for the connection. Recommended for cloud-hosted databases such as AWS RDS, Google Cloud SQL, PlanetScale, or DigitalOcean Managed Databases. Enabled by default.
Connection Validation
When you save the action, the connection is automatically tested. If the connection fails, you will see an error message on the host field with details about what went wrong. Common issues include:
- Incorrect hostname or port
- Wrong username or password
- Firewall blocking the connection
- SSL required but not enabled
Security
- Read-only queries only – the agent can only execute SELECT statements
- Query timeout – queries are limited to 5 seconds to prevent slow queries from affecting your database
- Result size limit – large results are truncated to prevent excessive data transfer
- All credentials are encrypted at rest
Example Use Case
With an e-commerce database, your chatbot can answer questions like:
- “What products do you have in stock?”
- “What is the price of the Pro Plan?”
- “How many orders were placed this month?”
- “Show me the top-selling products”
The AI agent will automatically discover your table structure and generate the appropriate SQL queries to retrieve the information.
Join over 1000+ businesses, websites and startups automating their customer service and other tasks with a custom trained AI agent.