mujib-chat-sdk
v1.0.3-beta.4
Published
Multi-platform Mujib AI chat SDK for web, mobile, and desktop applications.
Maintainers
Readme
Mujib Chat SDK
Mujib Chat SDK is a self-contained chat widget with distribution targets for npm, browser/CDN, Android, iOS, Flutter, React Native, and Electron.
Install from npm
npm install mujib-chat-sdkImporting the package registers the <mujib-chat> custom element:
import "mujib-chat-sdk";<mujib-chat
endpoint="https://api.example.com"
bot-id="YOUR_BOT_ID"
></mujib-chat>You can provide the chatbot response config directly as a JSON object in the
config attribute:
<mujib-chat
endpoint="https://api.example.com"
bot-id="YOUR_BOT_ID"
config='{"configs":{"mujib":{"color":"#0D121C"}}}'
></mujib-chat>A valid tag config skips the remote config request and is used exactly as supplied, without adding omitted fallback fields. Missing or invalid tag config falls back to the remote request, then to the packaged local defaults if that request fails.
The package also exports MujibChat, defineMujibChat, ChatEngine, setupSDK, and httpRequest for programmatic integration.
Messages are posted to {endpoint}/assistant/chat as { message }. After the first successful response, the returned session_id is persisted per bot and included automatically with later messages. An authentication token is resolved from localStorage, cookies, then sessionStorage using token, access_token, or mujib_token keys.
Browser and CDN
Run npm run build, deploy the contents of dist/browser/, then load:
<script src="https://cdn.example.com/mujib-chat-sdk.iife.js"></script>
<mujib-chat endpoint="https://api.example.com" bot-id="YOUR_BOT_ID"></mujib-chat>dist/browser/mujib-widget.html is the hosted full-page entry used by mobile and desktop WebViews. Configure wrappers with its deployed URL, for example https://cdn.example.com/mujib-widget.html.
Mobile SDKs
Generated integration sources are placed under dist/mobile/:
- Android: copy
android/MujibChatActivity.kt, add the activity to the manifest, and request theINTERNETpermission. - iOS: add
ios/MujibChatViewController.swiftto the Xcode target. - Flutter: add
flutter/mujib_chat.dartand depend onwebview_flutter. - React Native: add
react-native/MujibChat.jsand depend onreact-native-webview.
Each wrapper accepts widgetUrl, botId, endpoint, and an optional secret. The configuration is passed in the URL fragment so credentials are not sent to the static hosting server.
Desktop SDK
dist/desktop/electron/MujibChatWindow.js exports createMujibChatWindow. Copy it into the Electron main process and pass the same widgetUrl, botId, and endpoint options. The generated window disables Node integration and enables context isolation and sandboxing.
Build and publish
npm ci
npm run build
npm run test:package
npm run pack:check
npm publishThe build creates ESM and IIFE bundles, TypeScript declarations, the hosted widget page, all platform wrappers, and dist/manifest.json. prepublishOnly rebuilds and verifies these artifacts before publication. Bump package.json using semantic versioning before each release.
Security
Anything supplied to a browser or WebView can be inspected by the end user. Do not embed privileged server credentials in secret; use a public widget credential or a short-lived, restricted token. Serve the widget and API over HTTPS in production.
License
MIT
