Implementation of an Agora‑Based Video Claim SDK for Insurance: Architecture, Features, and Integration
This article details the design and implementation of a video‑claim system for insurance using Agora video‑call technology, covering background, core features, system architecture, adapter‑pattern code, Web and mini‑program SDK integration, exception handling, and future AI‑driven enhancements.
Background: In the wave of digital transformation, the insurance industry seeks innovative ways to improve efficiency and customer experience. The project builds a video‑claim system based on Agora video‑call technology, achieving over 20% video‑claim share and reducing claim‑reporting time by more than 50% compared with phone calls.
Core Features: (1) Basic video call allowing users to initiate a claim via the WeChat mini‑program or the insurance app; (2) Secondary user‑information acquisition when location permission is denied or the phone number differs; (3) Seat beautification, virtual avatars, and DIY background integration to reduce service‑resource pressure and increase brand exposure; (4) Video evidence capture during the call to support a complete car‑insurance claim workflow.
Technical Implementation – System Architecture: The solution adopts a client‑SDK (Web and mini‑program) that establishes a long‑lived WebSocket connection, registers idle seats, creates Agora channels via the Agora API, and pushes channel information to both seat and client SDKs. The business flow includes user SDK initialization, seat queueing, channel creation, state updates, and video‑evidence commands.
Adapter Pattern – Agora Class (excerpt): import Socket from './Socket'; export default class Agora { static instance: Agora; static wsInstance: WebSocket; static get shared(): Agora { if (!Agora.instance) { Agora.instance = new Agora(); } return Agora.instance; } /** 长链接消息回调 */ static messageCallback(e: { state: string; origin?: string; data?: any }) { /* handle */ } static init(config: IConfiguration = {}) { return new Promise(resolve => { this.config = { ...this.config, ...config }; resolve(true); }); } static checkIn(ops: ILoginParams) { Socket.connect(token); } static checkInOut() { Socket.send(StateEnum.LOGOUT); } static busy() { Socket.send(StateEnum.BUSY); } static idle() { Socket.send(StateEnum.IDLE); } static answer() { const Component = renderUIComponent(); ReactDOM.createRoot(root!!).render( ); } static hangUp() { Socket.send(StateEnum.HANGUP); } // other methods... }
Adapter Pattern – AgoraAdapter Class (excerpt): export interface IAdapter { bootstrap(agentInfo: IAgentInfo, params: IAny): void; addEvents(events: IAdapterEvents): void; login(): void; logoff(): void; hangup(): void; answer(): void; setBusy(): void; setIdle(): void; } import Agora from './agora'; class AgoraAdapter implements IAdapter { private events: IAdapterEvents; bootstrap(agentInfo: IAgentInfo, params: IAny) { this.agentInfo = agentInfo; this.params = params as IParams; } addEvents(events: IAdapterEvents) { this.events = events; } login() { Agora.checkIn(); } logOut() { Agora.checkInOut(); } setBusy() { Agora.busy(); } // other methods... } export default new AgoraAdapter();
Controller Class (excerpt): export default class Controller { private agentInfo: IAgentInfo; private adapter: IAdapter; private events: IControllerEvents; constructor(agentInfo: IAgentInfo, adapter: IAdapter, events: IControllerEvents) { this.agentInfo = agentInfo; this.adapter = adapter; this.events = events; adapter.addEvents({ /* callbacks */ }); } bootstrap = (params: IAny) => { this.adapter.bootstrap(this.agentInfo, params); }; login = () => { this.adapter.login(); }; logoff = () => { this.adapter.logoff(); }; hangup = () => { this.adapter.hangup(); }; answer = () => { this.adapter.answer(); }; setBusy = () => { this.adapter.setBusy(); }; setIdle = () => { this.adapter.setIdle(); }; // other methods... }
Web SDK Integration – Global VideoClaim Object (VideoChannel) with methods such as login, setIdle, setBusy, answer, hangUp, rejectCall, logOut (code excerpt): interface VideoChannelType { login(options): void; setIdle(): void; setBusy(): void; answer(): void; hangUp(): void; rejectCall(): void; logOut(): void; }
Seat Status Definitions (AgentStatusType) include loging, logined, ringing, rejectCall, connected, talking, hangUp, busy, idle, logOut.
Mini‑Program SDK Integration: Steps to enable the plugin, define the component in usingComponents, configure initialization parameters (camera position, beauty level, bitrate, resolution, etc.), and handle a rich set of event callbacks (onUserAdd, onPlayStatus, onNetStatus, onSwitchCamera, onSwitchSpeak, onChannelStatus, xflow tracking). Example component usage is shown with JSX‑like syntax wrapped in tags.
Exception Handling: Strategies for pre‑call user departure, app background freezing, post‑call user leave, WebSocket abnormal disconnection, and rapid issue resolution via front‑end monitoring, logging, and xflow data reporting.
Future Outlook: Plans to expose the video‑call capability as a shared infrastructure for multiple business lines, separating UI from core SDK, and applying AI for vehicle‑damage recognition, automatic loss‑estimate generation, and intelligent dispatch.
ZhongAn Tech Team
China's first online insurer. Through tech innovation we make insurance simpler, warmer, and more valuable. Powered by technology, we support 50 billion RMB of policies and serve 600 million users with smart, personalized solutions. ZhongAn's hardcore tech and article shares are here.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.