For the complete documentation index, see llms.txt. This page is also available as Markdown.

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

The users on this page are your customers (mapped to MaiAgent contacts). If you are integrating your company's or your customer's employees so they become MaiAgent organization members (using MaiGPT, role permissions, and Credits quotas), see Member Provisioning: SCIM / Invitations / SSO.

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:

Form
Suitable for
Documentation

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

For Web Chat with identity integration, configure the Allowed Embedding Domains list at this stage (administrators enter it in the conversation platform's basic settings). This limits origins that can embed Web Chat and call the identity synchronization API. See Allowed Embedding Domains.

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:

Method
Suitable for
Documentation

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:

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.

If you only need the AI to recognize users without calling your system's APIs, you can skip the backend entirely: include auth in the frontend config. For the tradeoffs, see Choosing Frontend auth or Backend Integration.

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 state

  • Backend: 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

Stage
Action
Documentation

Setup

Create your own AI Agent: Agent mode + tools such as image generation + Web Chat

Setup

Embed Web Chat (standard or MaiGPT mode)

Setup

Enter Allowed Embedding Domains in the conversation platform's basic settings

Setup

Add a maiagent_contact_id field to the member table

Setup

Backfill existing users in bulk

Operations

Call the identity synchronization API in the account creation flow

Operations

Update credentials in the login/Token refresh flow

Operations

Revoke credentials in the logout 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?