For the complete documentation index, see llms.txt. This page is also available as Markdown.

Text to SQL with MaiAgent Database

This guide explains how to upload spreadsheets such as Excel and CSV files to the MaiAgent Database, enabling the AI Assistant to query and analyze your data using natural language

To have the AI Assistant help you analyze spreadsheet data such as Excel and CSV files, simply upload the files to the MaiAgent Database. The AI Assistant can then query the data using natural language and produce statistical analysis results.

For an introduction to the Text to SQL concept, see: Text to SQL Feature

Step 1: Create a MaiAgent Database

  1. Navigate to "AI Features" > "Database" from the left sidebar

  2. Click "Add Database"

  3. Select "MaiAgent Database"

  4. Enter a database name (e.g., "2024 Annual Sales Data") and click Create

For detailed creation steps, see: Create and Configure Database

Step 2: Upload Spreadsheet Files

After creation, go to the database settings page:

  1. Switch to the "Table Management" tab

  2. Click "Upload Table File"

  3. Drag and drop or select your spreadsheet file

You can download the sample file (a food sales file with 100 items in .xlsx format) to test and experience the AI Assistant's data analysis capabilities.

After the upload is complete, wait for the processing status to show "Success", which indicates the data table has been created successfully.

Table Format Notes

To improve AI query accuracy, it is recommended to add descriptions to data tables and fields. See: Create and Configure Database — Edit Field Descriptions

Link the database to your AI Assistant so it can query the data:

  1. Switch to the "Linked AI Assistants" tab

  2. Select the AI Assistant to link from the left side and move it to the right

  3. Click "Save"

Step 4: Chat with the AI Assistant

Once the above steps are complete, you can go to the AI Assistant's conversation page and describe your needs directly using natural language.

For the AI Assistant conversation interface, see: Choose an Integration Platform to select the most suitable conversation platform for your needs.

Data Analysis

The Text to SQL tool can help you analyze data in spreadsheets. For example: "Find the best-selling dairy product from last year"

  • When you make a request, the AI Assistant will automatically invoke the Text-to-SQL tool.

  • This tool acts like a translator, converting your natural language into SQL syntax that the computer can understand, allowing the AI Assistant to extract data from the database.

The AI Assistant automatically adds conditional logic, sorting criteria, and other query constraints to convert your request into a more complete query command.

  • AI Assistant's Query Reasoning: Find the best-selling dairy product from last year, sorted by sales quantity in descending order. It automatically adds descending order conditions to better match your needs.

  • AI Assistant's Response (click the tool response to view):

Result

  • The AI Assistant found all sales data for "Dairy Products" along with other field data for those items.

  • Each row represents a data record, including: Product ID, Product Name, Product Category, Sales Amount, Sales Quantity, etc.

  • Based on this data, the AI Assistant determined that the best-selling dairy product is "Cheese", with a sales quantity of 110 and sales amount of 40,150 TWD.

Report Creation (Canvas Mode)

The Text to SQL tool can also help you create polished reports. This feature requires enabling Canvas Mode:

  1. Go to "AI Assistant Settings Page > Response Mode Settings" and find Agent Mode

  2. Change Agent Mode from Standard Mode to Canvas Mode

After saving the settings, you can chat with the AI Assistant. For example: "Please generate a visualized revenue report with statistics"

  • AI Assistant's Query Reasoning: Calculate revenue statistics for each product in the food company, including total revenue, average revenue, revenue standard deviation, revenue distribution ranges, revenue share by category, and other statistical metrics. It automatically generates the calculation results needed for the report to better match your needs.

  • AI Assistant's Response (click the tool response to view):

Result

  • The AI Assistant received the automatically computed results for all required statistical items from the tool.

  • The AI Assistant used this data as the basis for visualization and created an interactive report interface using Canvas.

Click the "Use Canvas" box to view the content

The report display is shown below. You can:

  1. Toggle between viewing the source code or the rendered view

  2. Switch report content by statistical category (this varies depending on each AI Assistant's output)

When switching to other categories, you can view the category revenue share pie chart and distribution analysis bar chart:

Additional Tips

  • Data quality matters: Ensure your spreadsheet data is clean and accurate, as this directly affects the accuracy of the AI Assistant's analysis results.

  • Data you do not want the AI to access must be deleted: Hidden data in spreadsheets can still be parsed and provided to the AI Assistant. Therefore, data you do not want exposed cannot simply be hidden — it must be deleted.

  • Try different questions: By asking questions in different ways, you can uncover more valuable insights from your data.

  • Make good use of Canvas Mode: Canvas Mode allows you to easily create various visualized reports for a more intuitive presentation of data analysis results.

  • Make good use of field descriptions: Adding descriptions to data table fields can significantly improve AI query accuracy.

Last updated

Was this helpful?