SDK Reference
Provider, hooks, surfaces, runtime data.
ModelNexProvider
ModelNexProvider is required. Mount it above routed product content.
<ModelNexProvider
websiteId="your-website-id"
userProfile={{
userId: currentUser.id,
type: currentUser.role,
isNewUser: currentUser.isNewUser,
}}
>
<App />
</ModelNexProvider>
| Prop | Type | Description |
|---|---|---|
websiteId Required |
string |
Project identifier for the ModelNex integration. |
userProfile |
object |
Current user identity and audience fields used for targeting and progress state. |
Dev tooling is enabled only through a browser-injected __MODELNEX_DEV_MODE_KEY__ value that the SDK verifies for the active websiteId.
Runtime Data Contract
userProfile.userIdshould be stable and persistent.userProfile.typeshould match the audiences you plan to target.userProfile.isNewUsershould reflect your actual first-use logic.alwaysflows do not need extra trigger-specific fields.
Complete userProfile data makes prompts, workflows, and resume behavior much more reliable.
Hooks
useRunCommandtriggers command execution from a custom UI.useUIStatesyncs local interface state with the assistant.useVoicehandles speech-to-text and continuous listening.useOnboardingPlaybackpowers workflow playback.useRecordingModeexposes authoring tools for internal users, including recording and step re-teach during preview.
import { useRunCommand } from '@modelnex/sdk'
function MyAssistant() {
const runCommand = useRunCommand()
async function handleSend(input: string, signal?: AbortSignal) {
return runCommand(input, signal)
}
return null
}
Review and Re-Teach
During internal preview sessions, the SDK can pause an in-progress step and capture a corrected recording for that step. When the correction is applied, Portal saves it into the current draft and shows it as the next draft version.
Keep recording and re-teach access restricted to trusted reviewers. These tools are for authoring and QA, not for customer-facing production use.
UI Surfaces
ModelNexChatBubble
Unified assistant and workflow surface for most integrations.
Custom UI + hooks
Use SDK hooks when you need a bespoke shell or a deeply branded interface.
agentNamecontrols the header label.appNameis used in onboarding copy and narration.welcomeMessagedefines the initial assistant message.themeoverrides colors and sizing.placeholdersets input placeholder text.
Integration Guidance
- Mount the provider above routed product content.
- Add
data-testidto important interactive targets before recording flows. - Only distribute
__MODELNEX_DEV_MODE_KEY__to trusted operators and inject it from a controlled browser context. - Re-test forced runs after releases that change routes, labels, or DOM structure.