SDK Reference
Ulka Chat provides a JavaScript SDK for integrating chat functionality into your website. This page documents the SDK methods, configuration options, and usage examples.
Overview
The Ulka Chat SDK enables you to embed a fully functional chat widget into your website. The SDK handles real-time communication, message delivery, and user interface rendering.
Installation
CDN Method (Recommended)
Include the SDK via CDN in your HTML:
<!-- Include Socket.io from CDN -->
<script src="https://cdn.socket.io/4.7.5/socket.io.min.js"></script>
<!-- UlkaChat CDN -->
<script src="https://ulkachat.saratech.com.bd/sdk/1.0.0/chat.js"></script>Prerequisites
Before using the SDK, ensure you have:
- Created an organization in your Ulka Chat dashboard
- Obtained your unique plugin key from Settings > Organization Settings > Plugin Key
- Access to your Ulka Chat API server URL
Initialization
Initialize the chat widget by calling Chat.init() with your configuration:
Chat.init({
apiBaseUrl: 'https://api.ulka.chat', // Your API server URL
pluginKey: 'YOUR_PLUGIN_KEY' // Your organization's plugin key
});Configuration Options
| Option | Type | Required | Description |
|---|---|---|---|
apiBaseUrl | string | Yes | The base URL of your Ulka Chat API server |
pluginKey | string | Yes | Your organization's unique plugin key |
Methods
Chat.init(options)
Initializes the Ulka Chat widget on the page.
Parameters:
options(object): Configuration object containingapiBaseUrlandpluginKey
Example:
Chat.init({
apiBaseUrl: 'https://api.ulkachat.com',
pluginKey: 'org_abc123xyz'
});Chat.destroy()
Removes the chat widget from the page and cleans up all resources.
Example:
Chat.destroy();Complete Example
Here's a complete HTML example showing how to integrate Ulka Chat:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Website with Ulka Chat</title>
</head>
<body>
<h1>Welcome to My Website</h1>
<p>Your content here...</p>
<!-- Include Socket.io from CDN -->
<script src="https://cdn.socket.io/4.7.5/socket.io.min.js"></script>
<!-- UlkaChat CDN -->
<script src="https://ulkachat.saratech.com.bd/sdk/1.0.0/chat.js"></script>
<!-- Initialize Chat -->
<script>
Chat.init({
apiBaseUrl: 'https://api.ulka.chat',
pluginKey: 'YOUR_PLUGIN_KEY' // Replace with your actual plugin key
});
</script>
</body>
</html>Getting Your Plugin Key
- Log in to your Ulka Chat dashboard
- Navigate to Settings > Organization Settings
- Find your Plugin Key in the Plugin Key section
- Copy the key and use it in your
Chat.init()call
API Status
Note: REST API endpoints are not currently available. All integration with Ulka Chat is done through the JavaScript SDK. The SDK handles all communication with the Ulka Chat backend using WebSocket connections.
Browser Support
The Ulka Chat SDK supports all modern browsers:
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
- Opera (latest)
Security Considerations
- Keep your plugin key secure: Never commit your plugin key to public repositories
- Use environment variables: Store your plugin key in environment variables for production deployments
- HTTPS recommended: Use HTTPS for your website to ensure secure WebSocket connections
Troubleshooting
Widget Not Appearing
- Ensure Socket.io loads before the Ulka Chat SDK
- Verify your plugin key is correct
- Check browser console for errors
- Confirm your API URL is accessible
Connection Errors
- Verify your
apiBaseUrlis correct - Check network connectivity
- Ensure WebSocket connections are allowed
- Verify your plugin key hasn't been revoked
Support
For technical support or questions about the SDK:
- Email:
dev-support@ulka.chat - Developer Forum: forum.ulka.chat (opens in a new tab)
For information about features and integrations, see the Core Features and Integrations documentation.