A lightweight and customizable SDK for integrating OpenAI-powered chatbots into your web applications.
- Easy integration with OpenAI's API
- Customizable UI with light and dark themes
- Simple API for sending and receiving messages
- Ready-to-use chat interface
- Fully responsive design
npm install openai-chatbot-ui-sdk<!DOCTYPE html>
<html>
<head>
<title>Chatbot Example</title>
</head>
<body>
<div id="chatbot-container"></div>
<script src="node_modules/openai-chatbot-ui-sdk/dist/chatbot-sdk.js"></script>
<script>
const chatbot = new ChatbotSDK.Chatbot({
apiKey: 'your-openai-api-key',
container: '#chatbot-container',
model: 'gpt-3.5-turbo'
});
</script>
</body>
</html>import Chatbot from 'openai-chatbot-ui-sdk';
const chatbot = new Chatbot({
apiKey: 'your-openai-api-key',
container: document.getElementById('chatbot-container'),
model: 'gpt-3.5-turbo'
});The main class for integrating the chatbot.
| Option | Type | Default | Description |
|---|---|---|---|
| apiKey | string | '' | Your OpenAI API key |
| model | string | 'gpt-3.5-turbo' | The OpenAI model to use |
| container | string|Element | null | The container element or selector for the chatbot UI |
| initialMessages | array | [] | Initial messages to populate the chat |
| onMessage | function | null | Callback function when a message is sent or received |
| uiOptions | object | {} | UI customization options |
sendMessage(message, options): Send a message to the chatbotsetApiKey(apiKey): Update the API keysetModel(model): Change the modelgetMessages(): Get all messages in the conversationclearMessages(): Clear all messagesinitUI(container, uiOptions): Initialize the UI
The UI can be customized with the following options:
const chatbot = new Chatbot({
// ... other options
uiOptions: {
theme: 'dark', // 'light' or 'dark'
position: 'bottom-right', // 'bottom-right' or 'relative'
width: '350px',
height: '500px',
headerText: 'Custom Chatbot',
placeholder: 'Type a message...',
sendButtonText: 'Send'
}
});- Clone the repository
- Install dependencies:
npm install - Build the project:
npm run build
The bundled output will be in the dist directory.
Check the examples directory for more usage examples.
MIT