This guide walks through a Mindset AI agent integration from the start. By the end, you’ll have an agent loading on your page, authenticating your user, and either rendering its own chat UI or driving an interface you build yourself. The integration has four pieces:Documentation Index
Fetch the complete documentation index at: https://docs.mindset.ai/llms.txt
Use this file to discover all available pages before exploring further.
- Configure the agent in the Agent Management Studio (tools, knowledge, behavior).
- Set up your token endpoint, so your backend mints SDK tokens for your users.
- Add the SDK script and element to your page: one
<script>tag, one<mindset-agent>element. - Initialize and (optionally) build your UI. Call
mindset.init(), then either let the agent render itself or hook into its events.
Prerequisites
Before you start, you’ll need:- A Mindset AI account and an app set up in the Agent Management Studio. This gives you an
appUidand lets you build agents. - An agent configured with your tools and knowledge. Each agent has an
agent-uid. You’ll reference this from your page. - A backend that can call
sdkusersapito mint a token for the current user. Mindset AI doesn’t talk to your auth system; you do, and you hand a token to the SDK. - A page where you can add a
<script>tag. Vanilla HTML, React, Vue, Svelte, or any other setup that produces HTML works.
Configure your agent
Sign in to the Agent Management Studio, build the agent you want, and copy its
agent-uid. You’ll paste this into your HTML in step 3.See the Agent Management Studio walkthrough for a full tour of AMS, or Creating Agents for a focused agent-build guide.Set up your token endpoint
The Mindset AI SDK never talks directly to your authentication system. Instead, it asks your app for a token using a callback you provide. Your callback hits an endpoint on your backend; that endpoint calls Your endpoint:
sdkusersapi with your API key to mint an SDK token for the current user.The flow:- Authenticates the request using your existing session, JWT, or whatever you already have
- Maps the user to a Mindset AI identity (you choose the strategy, typically your user ID becomes their Mindset AI user ID)
- Calls
sdkusersapiwith your Mindset AI API key to mint a token - Returns the token to the browser
Add the SDK script and element
Add the SDK bundle and your Two things happen automatically:The runtime, auth flow, state machine, and DOM events are identical in both modes. The only difference is whether the element renders its own chat UI.
<mindset-agent> element to the page.- The
<script>registers<mindset-agent>as a custom element. After this,customElements.get('mindset-agent')returns the constructor. - The element is added to the DOM. The
connectedCallbackfires, the element dispatchesmindset:agent-registered, and queues itself for runtime binding.
mindset.init() to bind it to a runtime instance.Choose your mode
The element has two modes, set with theheadless attribute.In the default mode (no headless attribute), Mindset AI renders a chat UI inside the element. Your users get a working chat experience with no UI code on your side.In headless mode (headless attribute present), the element runs the agent and dispatches DOM events, but renders nothing. You build the UI.If you’re not sure which to pick, start with the default mode. Switch to headless later if you need full UI control.Initialize the SDK
Call You can call Listen for
mindset.init() once. This wires up the runtime, calls your fetchAuthentication callback, and starts loading the agent.init before or after the <mindset-agent> element is added to the DOM. Both orders work. The SDK uses a MutationObserver to find elements added later, so React, Vue, and other frameworks that mount the element in a component lifecycle work without extra wiring.After init succeeds, each <mindset-agent> on the page fires:mindset:agent-idle if you want to know when an agent is ready.Step 5: Render the UI
- Default mode (built-in chat UI)
- Headless mode (you build the UI)
If you went with default mode, you’re done. Mindset AI renders a chat panel inside the element. Users can chat, switch threads, and view the history.You can still hook into events if you want to react to what the agent does:You can drive the agent programmatically too, for example to open a thread when the user clicks something on your page:See the Examples page (Built-in chat UI tab) for a complete working setup.
Configuring per-agent state
Two common pieces of per-agent setup happen on the element itself, not inmindset.init(). Both have dedicated guides, page tools and situational awareness, covering scenarios, best practices, and security in depth. The summaries below get you started.
Page tools
Page tools are functions on your page that the agent can call during a turn. You declare the name, description, and arguments; the agent decides when to call.setPageTools whenever your tool list changes. The element applies the new value on the agent’s next turn.
Call element methods only after the element has fired mindset:agent-idle. See § When the element is ready to call.
Situational awareness
Situational awareness is structured context the agent reads on every turn. Use it for the things the agent should know about the current user or the current page that the user shouldn’t have to repeat.What’s next
<mindset-agent> element
Every attribute, property, and the registration lifecycle.
Element methods
Every method on the element with signatures and behaviors.
DOM events
Every event the element fires, with payload shapes.
SDK init
window.mindset.init() config and SDK-level helpers.
Page tools
Let the agent take actions in the browser.
Situational awareness
Give the agent context about what the user is looking at.
Pass-through parameters
Inject exact data into tool calls without the LLM copying it.
Common questions
Do I need a build step?
No. The SDK is a UMD bundle you load with a<script> tag. It works in any HTML page, with or without a JavaScript framework.
Do I need an npm package?
Not for the integration itself. We may publish a TypeScript type declaration package later for IDE autocomplete; the runtime stays as a hosted bundle.Can I have multiple agents on one page?
Yes. Each<mindset-agent> element has its own runtime, state, and threads. Use different agent-uid values for each. See the <mindset-agent> reference for the current single-active-agent constraint.
What about TypeScript?
TypeScript declarations for the element and DOM events are on the roadmap. For now, type the events withCustomEvent<{ ... }> based on the events reference payload tables.
What about React?
Custom elements work in React out of the box.<mindset-agent> is a valid JSX tag. Use refs to access the element instance and useEffect for event subscription. See the Examples page (Headless: React tab).