logo
Development
Search
WorkSpace Mobile Integration Overview

WorkSpace Mobile Integration Overview

GPTBots supports integrating the WorkSpace as a whole into your enterprise mobile App. By enabling enterprise users to use the WorkSpace without logging in, it makes the WorkSpace convenient for enterprise employees. The integration uses a WebView + H5 bridge approach and supports both Android and iOS.

WebViewBridge is a bridging interface for two-way communication between a native app and H5 pages. It provides a unified communication protocol and methods, allowing native code and H5 pages to conveniently call each other and pass data.


Integration Architecture

┌─────────────────────────┐ WebViewBridge ┌────────────────────┐ │ Enterprise Mobile APP │ ◄───────────────► │ WorkSpace H5 Page │ │ (Android/iOS) │ │ (React + Vite) │ └─────────────────────────┘ └────────────────────┘ │ │ │ Issue AiToken │ Parse AiToken │ (RSA Encryption) │ Login-free entry ▼ ▼ ┌──────────────────────────────────────────────────────────────────┐ │ GPTBots Backend Service │ │ (Spring Boot + MongoDB + Redis) │ └──────────────────────────────────────────────────────────────────┘
                      
                      ┌─────────────────────────┐   WebViewBridge   ┌────────────────────┐
│  Enterprise Mobile APP  │ ◄───────────────► │  WorkSpace H5 Page │
│      (Android/iOS)      │                   │   (React + Vite)   │
└─────────────────────────┘                   └────────────────────┘
            │                                          │
            │ Issue AiToken                            │ Parse AiToken
            │ (RSA Encryption)                         │ Login-free entry
            ▼                                          ▼
┌──────────────────────────────────────────────────────────────────┐
│                     GPTBots Backend Service                      │
│                 (Spring Boot + MongoDB + Redis)                  │
└──────────────────────────────────────────────────────────────────┘

                    
This code block in the floating window

Integration Flow

Step Description Detailed Docs
1. Obtain the public key Get the RSA public key from Space Settings → Integration AiToken Encryption
2. Issue the AiToken Encrypt the member's email with the public key, append the project ID, then Base64-encode AiToken Encryption
3. Open the dedicated URL Append the AiToken to the WorkSpace integration URL This document
4. Native-side integration Integrate the WebView and configure permissions on the Android or iOS side Android Integration / iOS Integration
5. Bridge communication Implement JSBridge / WKScriptMessageHandler Android Integration / iOS Integration

WorkSpace Access URL

When an enterprise employee accesses the WorkSpace on the App, the WorkSpace address should be opened as that enterprise employee. The access address is generated according to the following rule:

https://gptbots.ai/space/h5/home?AiToken={加密AiToken}&hideClose=true
                      
                      https://gptbots.ai/space/h5/home?AiToken={加密AiToken}&hideClose=true

                    
This code block in the floating window
  • {加密AiToken}: the AiToken encrypted with the RSA public key, containing the organization ID and the employee account email
  • hideClose: an optional parameter; when set to true, the "Close" button is hidden in the webview page

hideClose Parameter Behavior

  • Default (omitted or false): the "Close" button is displayed on the page; when clicked, a close-action message notification is sent via WebViewBridge
  • Set to true: the Close button is hidden, and the App controls the WebView lifecycle on its own

Close-action message JSON:

{ "eventType": "click", "data": { "value": "close", "timestamp": 1776921208476, "extendedData": {} } }
                      
                      {
  "eventType": "click",
  "data": {
    "value": "close",
    "timestamp": 1776921208476,
    "extendedData": {}
  }
}

                    
This code block in the floating window
  • eventType: a string indicating the event type, used to identify different feature calls
  • data: a JSON object containing the parameter data related to the event; it may include different fields depending on the eventType

Event Type Table

Event Type Constant Description Parameters
click EVENT_CLICK webview page click event data: additional data (optional) in JSON format, containing by default the fields value (event type, e.g. "click") and timestamp (timestamp, in milliseconds)
message EVENT_MESSAGE webview page message event data: additional data (optional) in JSON format, containing by default the fields value (event type, e.g. "message") and timestamp (timestamp, in milliseconds)

DEMO Projects

GPTBots provides complete DEMOs for mobile WorkSpace integration:

Platform Repository
Android android-webview-bridge
iOS ios-webview-bridge