Aimdoc AI SDKs
Aimdoc provides official SDKs for JavaScript/TypeScript and React so you can control chat behavior directly from your app.
Use these SDKs to:
- Identify signed-in users
- Open the chat programmatically
- Send messages into the conversation flow
The SDKs control an embedded Aimdoc widget. If you have not added the widget yet, start with Embedding your Agent.
Official libraries
JavaScript / TypeScript SDK
Use @aimdoc/sdk to identify users, open chat, and send messages programmatically.
React SDK
Use @aimdoc/sdk-react with AimdocProvider and useAimdoc for React applications.
Install
Install the package that fits your stack:
# JavaScript / TypeScript
npm install @aimdoc/sdk
# React
npm install @aimdoc/sdk-react
JavaScript SDK
The JavaScript SDK exports a singleton aimdoc client:
import { aimdoc } from '@aimdoc/sdk'
aimdoc.identify({
external_id: 'user_123',
email: 'jane@company.com',
first_name: 'Jane',
last_name: 'Doe',
company: 'Acme Inc',
attributes: {
plan: 'pro',
},
})
aimdoc.openChat({ agentId: 'your-agent-id' })
aimdoc.sendMessage('Can you show enterprise pricing?', { agentId: 'your-agent-id' })
Available methods
identify(user)— attach user identity and profile attributes.openChat(options?)— open the chat launcher/widget.sendMessage(message, options?)— send a message as the current visitor/user.
agentId is optional in openChat and sendMessage. Provide it when your page can target multiple agents.
React SDK
The React SDK gives you AimdocProvider and useAimdoc.
'use client'
import { AimdocProvider } from '@aimdoc/sdk-react'
export default function AppRoot() {
return (
<AimdocProvider agentId="your-agent-id">
<App />
</AimdocProvider>
)
}
Inside child components, call the SDK through the hook:
'use client'
import { useAimdoc } from '@aimdoc/sdk-react'
export function OpenChatButton() {
const { identify, openChat } = useAimdoc()
const onClick = () => {
identify({
external_id: 'user_123',
email: 'jane@company.com',
company: 'Acme Inc',
})
openChat()
}
return <button onClick={onClick}>Chat with sales</button>
}
AimdocProvider props
agentId(required) — your Aimdoc agent ID.scriptUrl(optional) — custom script URL. Defaults tohttps://app.aimdoc.ai/embedded.bundle.js.
Next steps
- Embedding your Agent for script/widget setup details
- API & Webhooks Overview for backend integrations
- Webhooks for event delivery patterns
- API Reference (Redoc)