Ulka Chat is now in Public Beta. Check out our latest features. Visit ulka.chat →
SDK Reference

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:

  1. Created an organization in your Ulka Chat dashboard
  2. Obtained your unique plugin key from Settings > Organization Settings > Plugin Key
  3. 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

OptionTypeRequiredDescription
apiBaseUrlstringYesThe base URL of your Ulka Chat API server
pluginKeystringYesYour organization's unique plugin key

Methods

Chat.init(options)

Initializes the Ulka Chat widget on the page.

Parameters:

  • options (object): Configuration object containing apiBaseUrl and pluginKey

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

  1. Log in to your Ulka Chat dashboard
  2. Navigate to Settings > Organization Settings
  3. Find your Plugin Key in the Plugin Key section
  4. 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 apiBaseUrl is 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:


For information about features and integrations, see the Core Features and Integrations documentation.