Software Vendor Integration Guide: Embed AI Agents for Your Customers
An end-to-end guide for software vendors to embed Web Chat in their products and integrate permissions, covering embedding, bulk backfilling, login synchronization, Token refresh, and credential revoc
This page is for software vendors embedding MaiAgent Web Chat in their own products and integrating permissions with their account systems. After users log in to your system, the AI Agent recognizes them, retrieves their conversation history, and calls your system's APIs with their permissions.
The integration journey has five stages. This page explains what to do at each stage and in what order, with links to the relevant technical documentation for details.
Integration Overview
There is one core concept: Contact. Each user in your system maps to a MaiAgent contact. A contact holds conversation history, personalized attributes, knowledge base query scope, and tool credentials. Every permission integration action maintains this mapping between your users and contacts and their credentials. For an introduction, see Contacts: Overview and Integration.
Frontend and Backend Responsibilities
Throughout the journey, your frontend only loads the chat window. Your backend initiates all calls containing a Token or API Key:
setup-contact-credentials requires no API Key (it is a public endpoint). bulk-import, PATCH, and DELETE require Authorization: Api-Key authentication and must be called from the backend.
Step 1: Embed Web Chat
Choose the embedding method that fits your product. Both use the same SDK and contact mechanism:
Chat bubble (floating/sidebar)
Supporting features such as customer service and consultation
MaiGPT mode (a full ChatGPT-like interface)
The main feature area of a page or a site-wide AI entry point
Step 2: Initial Integration—Backfill Existing Users in Bulk
When integrating an existing system for the first time, backfill contacts for existing users first. There are two options:
Excel bulk import (POST /contacts/bulk-import/)
Large numbers of users (up to 10,000 rows per request); can also import knowledge query scope and API tool credentials
Call the identity synchronization API for each user
Gradual backfilling through the login flow, or small numbers of users
You do not need users' Access Tokens at backfill time. Create the mappings first; the login flow in Step 4 adds Token credentials the next time each user logs in.
Step 3: Create a Contact When Adding a User
After backfilling, add an API call to your system's account creation flow so each new user has a corresponding contact from the start:
Call the Identity Synchronization API (
setup-contact-credentials) from the backend, using your system's user identifier assourceIdStore the returned
contactIdin your member table (for the recommended field design, see Where to Integrate in the Login Flow)
sourceId is an idempotency key: repeated calls with the same sourceId only update the contact without creating duplicates. This step can safely coexist with Steps 2 and 4.
Step 4: Login and Token Refresh
After each successful login generates an Access Token, the backend calls the same identity synchronization API again with the new Token (mcpCredentials). This allows the AI Agent to call your system's APIs with that user's identity and permissions. Use the same approach on Token refresh: call the API again. For the same contact and tool pair, it updates credentials rather than creating duplicates. For the full sequence diagram and considerations (asynchronous calls and failures that do not block login), see Contact Identity Synchronization and Token Updates.
The frontend passes contactId when initializing Web Chat on the page. See Identify Users.
Step 5: Logout and Credential Revocation
At logout, take two actions with different scopes. We recommend both:
Frontend: Call the SDK's
signOut()to return the chat window to an anonymous stateBackend: Delete the contact's tool credentials so the AI immediately loses the ability to call tools as that user
For API details and a comparison of the two actions, see Logout and Credential Revocation.
Integration Checklist
Setup
Create your own AI Agent: Agent mode + tools such as image generation + Web Chat
Setup
Enter Allowed Embedding Domains in the conversation platform's basic settings
Operations
Call the identity synchronization API in the account creation flow
Advanced
Synchronize personalized attributes such as department and membership tier
Advanced
Use query metadata to limit each user's knowledge base retrieval scope
Last updated
Was this helpful?