Skip to main content

Building a Data Agent from Scratch

In daily operations, engineers often face the challenges of a large number of tickets, diverse types, and difficult analysis. Especially when submitting summary reports to customers or summarizing the handling status of a certain period, the traditional approach usually relies on manual statistics and analysis, which is time-consuming, labor-intensive, and prone to errors, seriously affecting work efficiency and response speed.

To address this pain point, this tutorial will guide you to build a ticket statistics and analysis assistant driven by data sources from scratch. Leveraging intelligent analysis capabilities, it can perform multi-dimensional processing such as automatic summarization, classification statistics, and trend analysis of massive tickets. Whether it is quickly extracting high-frequency issues, identifying response bottlenecks, or generating visual reports for customers, this assistant will greatly enhance the data processing capability and service quality of the operations team.

Data Source Preparation

In daily operations, the system regularly synchronizes ticket data to the enterprise database, forming a structured ticket record table. This data includes key information such as ticket ID, category, issue, processing status, response time, resolution duration, etc.

In this example, we will add a data source connected to the database through the Data module for subsequent Agent analysis.

✅ Tip: For specific data access steps, please refer to the "Data Preparation" section in the tutorial "Quickly Building Sales Intelligent Analysis Reports."

  • The data source created in this example is named Microsoft Support

Ensure the data source connection test passes and the data preview is successful before proceeding to the next step of Agent creation.

Creating the Ticket Analytics Agent

Standard Creation

After completing the data source connection, we will use the standard method to create an intelligent Agent for automatic analysis and summarization of ticket data.

✅ Tip: The creation process can refer to the tutorial "Building a Simple Agent Assistant from Scratch."

In this example, the Agent created is named Ticket Analytics, positioned as a data analysis assistant for operations personnel, capable of understanding user needs and automatically generating insightful reports and statistical results from data.

The Agent creation interface is as follows:

Configuring the Ticket Analytics Agent

1. Prompt Configuration

  • Fill in brief prompt information in the Prompt input box.
  • Click "Intelligent Generate" to let the system automatically expand the prompt by calling the model, generating a more complete version.
  • The prompt in this example is:
## Role
You are a Ticket Analytics Specialist, dedicated to extracting, analyzing, and summarizing ticket data from various data sources to help users gain actionable insights into their ticketing operations.

## Skills
1. Retrieve and aggregate ticket information:
- Access ticket data from specified data sources, ensuring comprehensive coverage of all available tickets.
- Organize ticket data by relevant attributes such as status, category, time period, and assigned personnel for further analysis.

2. Perform ticket data analysis based on user requirements:
- Analyze total ticket volume, trends over time, or distribution by specific categories as requested by the user.
- Generate clear, concise summaries and visual representations (such as tables or charts) of ticket statistics to help users understand the results easily.

## Constraints
- Only discuss topics and perform analyses directly related to ticket data; do not address unrelated subjects.
- All outputs must be organized according to the specified structure and presented in English (en-US) language.

2. Greeting Configuration

  • You can fill in a custom greeting or click "Intelligent Generate" to automatically generate a welcome message.
  • The greeting in this example is:
Hello, I am Ticket Analytics, here to assist you with all your ticket analysis needs.

[How can I use Ticket Analytics to gain insights from my ticket data?] [What types of reports and analytics can you provide for my tickets?] [How can Ticket Analytics help improve my support team's performance?]

3. Model Group Settings

  • The model group (e.g., General Modeling Group) is selected during Agent creation and will be automatically populated here.

  • You can switch as needed, noting:

    • Model group contents may differ across environments;
    • Model groups are pre-configured by administrators;
    • The General Modeling Group used in this example includes models: gpt-4.1, Qwen/Qwen3-32B.

4. Data Source Configuration

Configuring the data source is a key step to enable the Agent to access actual ticket data. Please complete the binding as follows:

  1. Click the "+" button to the right of the data source to open the data source selection popup;
  2. Find and select the previously prepared data source Microsoft Support from the list;
  3. Click "Confirm" at the bottom right to complete the data source binding;
  4. After returning to the configuration interface, confirm the data source is correctly displayed in the Agent's configuration panel;
  5. Finally, click the "Publish" button at the top right to ensure all settings take effect.

✅ After completing the above steps, the Agent will have access to ticket data in the support_logs table and can perform analysis and summarization based on this data.

The final configuration effect is as follows:

Testing Q&A Effect

After completing the data source configuration, you can enter the Agent conversation interface to test the ticket analysis assistant's effect. Below is an example interaction flow for this case:

  1. Enter a natural language request in the chat box

    Help me count all ticket data by ticket type and generate statistical charts

As shown in the figure:

  1. The Agent will first extract all ticket data from the data source and classify and summarize according to the category field, outputting the quantity statistics for each ticket type;

  1. Then, the system will automatically generate a bar chart based on the statistical data, visually displaying the comparison of the number of various ticket types, helping users quickly identify high-frequency issue types;

  1. Below the chart, the system also provides an Intelligent BI Analysis Area, supporting the following functions:
    • Data Preview: View the raw data used to generate the chart;
    • Chart Editing: Switch the bar chart to line chart, pie chart, etc., and customize X-axis and Y-axis fields;
    • SQL Query View: View and copy the SQL query behind the current analysis for further analysis or reuse;
    • View Data: Click to jump to the raw data table view;
    • Intelligent Insights: Click to let the system further provide automated insight results based on the current data, such as trend analysis, anomaly detection, etc.

Data Preview:

Chart Editing:

SQL View:

The overall Q&A effect is as follows: