Web

更新时间:
复制 MD 格式

Integrate an AI agent into a web application for real-time messaging.

Before you begin

  • Messaging provides web UI components only for mobile devices.

  • Develop relevant API operations on your server or deploy the provided server source code. For more information, see Deploy a project.

  • The development environment requires Node 18 or later and NPM 10 or later.

Download source code

Download link

Download the source code from the GitHub repository.

Directory structure

.
└── React
  ├── README.md
  ├── eslint.config.js
  ├── index.html       // For PC
  ├── mobile.html      // For mobile device
  ├── package.json
  ├── src
  │   ├── Mobile       // Mobile UI implementation
  │   ├── PC           // PC UI implementation
  │   ├── common       // Common business methods
  │   ├── controller   // Business logic interfaces and implementation
  │   ├── service      // Interactions with the server
  │   └── vite-env.d.ts
  ├── tsconfig.app.json
  ├── tsconfig.json
  └── vite.config.ts

Run the demo

  1. After downloading the source code, open the React directory.

  2. In the React directory, run npm install to install dependencies.

  3. Open the file src/service/interface.ts and modify the server domain name.

    // src/controller/service/interface.ts
    const APP_SERVER = 'Domain name of your app server';
  4. Open the file src/App.tsx and modify the AI agent ID.

    const defaultChatAgentId = 'AI agent ID';
  5. Run the command npm run dev to start the local service.

  6. Access http://localhost:5173/mobile to try the message conversation with AI agent.