DEV Community

Cover image for How to Build an AI Agent to Automate Mobile Auto Repair Task Scheduling
Alex for Momen

Posted on

How to Build an AI Agent to Automate Mobile Auto Repair Task Scheduling

Project Background

Inefficient scheduling in the service industry wastes time for both vendors and customers. To address this, our team developed an AI agent to streamline repair scheduling in the mobile auto sector.

Project Preview


This is an overview of the project. We'll walk through the essential steps of building it and cover some basic concepts related to AI agents along the way.

Business Logic

Here’s the business logic behind the template, which you can also view as its workflow. We have two AI agents in this template. A customer service that help to record user's car issues and a scheduling assistant that helps to make the schedule in vendor's calendar.

Customer Service

Image description

This is the logic of the customer service AI. This AI works mainly during the conversation. As the conversation progresses, the data table updates in real-time. Car models and locations are recorded as the user selects them, while the AI assesses and updates the car’s issues.

Scheduling Assistant

Image description

It operates after an order is created, handling the task of scheduling the event for the vendor.

The following is the explanation of different work order status.

  1. Pending – Conversation starts, gathering information.

  2. Chat to Issue – User inputs the information and AI assesses the issue.

  3. To Be Confirmed – The issue has been confirmed, waiting for staff to confirm the appointment.

  4. Confirmed – Appointment scheduled successfully.


Knowledge Breakdown

How Function Calls Works

  1. Need Identification: While handling tasks, the agent identifies when specific "tools or expert knowledge" might be required. For instance, if you mention "check today’s weather."

  2. Tool Selection: The agent picks the most suitable expert from a predefined list of tools.

  3. Parameter Preparation: The agent prepares the necessary input information by reviewing tool descriptions, such as the specific city and date required for a weather query.

  4. Tool Invocation: The agent generates and calls a tool (function) in the correct format.

  5. Information Integration: The agent uses the tool’s result and continues processing within the main workflow.

Autonomous Decision-Making vs. Workflow Orchestration

When developing agents, there are two main ways to equip them with capabilities:

  1. Autonomous Decision-Making (Function Call-Based): Agents can be given the ability to make decisions on their own. Imagine playing League of Legends, you can control the sequence of skills to be used, adapting the order based on the situation, even if some heroes have preset combos.

  2. Workflow Orchestration: This is akin to packaging fixed combos into mouse macros that trigger at specific times. The workflows of agents are pre-configured.

  3. For example, you need your agent to "send a notification to Slack." The first approach would package this task into a tool, allowing the agent to decide when to call it. The second approach adds logic to the workflow: "When the result is ***," triggers the API to send a Slack notification.

  • Advantage of Autonomous Decision-Making: Greater flexibility and adaptability, enabling real-time decisions that are effective in dynamic environments. However, this might increase costs (token usage) and introduce uncertainty.

  • Advantage of Workflow Orchestration: Predictability and efficient resource management, allowing developers to control exactly when notifications are triggered, which improves system stability and is ideal for repetitive tasks.


Data Model

Below is the basic data model setting in this project.

Image description

Image description

Image description

The relation between car maker and car model is 1:N, because one brand could have multiple car models. The relation between repair category and repair item is 1:N because 1 category could have different issues. Based on car model and repair issues, a cost estimate is generated.


Configuration Guide

AI Configuration

This section is the configuration of the AI.

Customer Service AI

Purpose

Gathers detailed descriptions of car issues from the user, organizes information for the mechanic, and estimates repair time and cost.

Tools:

  1. Find repair items based on user input.

  2. Retrieve quotes using car model and repair item details.

  3. Modify and query user work orders.

Input:

User messages, car_model_id, work_order_id.

Steps:

  1. Set up tools for the AI:
  • Search repair items.

  • Retrieve quotes based on car model and repair items.

  • Query and update work orders.

  1. Configure a knowledge base for car repair categories and specific issues for the AI to query.

Important Notes
Unlike hardcoding data directly into the prompt, a knowledge base is ideal for dynamic, frequently changing information. This approach prevents the need to update the prompt constantly, as the issues may vary each time.

Image description

Image description

  1. Configure your agent.

Scheduler AI

Purpose: Schedules appointments for mechanics.

Data: Google Calendar token.

Tools:

  • Time zone conversion.

  • Calculate distances between locations.

  • Query and create Google Calendar events.

Input: Location, preferences, date, time zone, duration.

Steps:

  1. Set up tools for the AI:
  • Retrieve Google Calendar info.

  • Calculate distances and travel time.

  • Create calendar events.

  • Configure your AI agent.

Important Notes:

  1. When configuring agent tools, clearly define the tool’s capabilities and requirements for each input and output.

  2. Based on the scenario, set appropriate limits on the number of calls and token usage to prevent resource waste.

Integrating ZAI into the Front-End Page

In this section, we'll walk through the frontend page building and how to configure AI agents on the frontend.

Usage Guide

Before using this template, you'll need to configure your own API so the AI can schedule events in your calendar. Additionally, you’ll need to adjust the permission settings to ensure that only you and your staff can manage the dashboard, while users only have access to the conversation page.

You'll also need to set up the permission setting so that only you and your staff can manage the dashboard, while your users can only access the conversation page.

Google Calendar Setup

  1. Log in to Google Cloud Console: https://console.cloud.google.com/

  2. Create a new project.

Image description

  1. Enable the Google Calendar API.

Image description

  1. Create credentials (redirect URI: https://developers.google.com/oauthplayground).

Image description

Image description

Image description

  1. Download the credentials JSON file to get your client_id and client_secret.

Image description

  1. Add your Google account as a test user.

Image description

  1. Get the refresh token:

Image description

  1. Click "Authorize APIs" and log in with your Google account.

Image description

  1. Obtain the refresh_token.

Image description

Image description

  1. In Momen’s API module, set the client_id, refresh_token, and client_secret as default values.

Image description

Image description

Google Maps Platform Setup

  1. Enable the Distance Matrix API in Google Cloud Console.

Image description

  1. Follow the instructions to get your API key.

Image description

  1. Add the API key to the AI's description in Momen.

Image description

Permission Setup

Permission is crucial because it ensures that only authorized roles can access specific data. For example, access to the dashboard, customer details, and the API will be restricted to staff members, keeping sensitive information secure. When using this project, we'll need to configure the permission.

  1. Register a new account.

Image description

  1. Grant the permissions for this account in the editor.

Conclusion

This concludes our showcase. To explore how it functions within the editor, feel free to check it out here:https://editor.momen.app/tool/jnPx685BLNJ/WEB?code=rsYe0aqvVVR9u .

Top comments (0)