smc-chat
v1.0.2
Published
SMC Chat Widget Core COmponent
Readme
Here is a detailed README.md file for your smc-chat npm package:
smc-chat
The smc-chat package provides a customizable chat widget designed for seamless integration into web applications. It supports features like personalized themes, configurable API endpoints, and dynamic session handling, making it ideal for building interactive chat assistants.
Installation
To install the package, use the following command:
npm install smc-chatImporting the Package
To use the chat widget in your project, import it as follows:
import 'smc-chat';Usage
Add the `` component to your HTML or JSX code to integrate the chat widget. Below is an example configuration:
Explanation of Attributes
user-name: Specifies the default name displayed for the user in the chat. Example:"You".header-icon: URL for the icon displayed in the chat header. Leave empty for no icon.header-text: Text displayed in the chat header. Example:"Stoxkart Assistant".theme: Defines the theme of the chat widget. Options:"light"or"dark".welcome-message: The initial message displayed when the chat starts. Example:"Welcome to Stoxkart! How can I help you today?".start-chat-logo: URL for an image/logo shown at the start of the chat.primary-color: Hex color code for the primary theme color of the widget. Example:"#0ca750".secondary-color: Hex color code for secondary elements in the theme. Example:"gray".position: Specifies where the widget appears on the screen. Options:"right"or"left".api-url: The endpoint URL where chat messages are sent and received.input-placeholder: Placeholder text for the input field. Example:"Type your Question here...".session: A dynamic session object passed to manage user sessions.
API Keys and Headers
The following headers are required for API communication:
{
"x-platform-agent": "web",
"x-prompt-session-attribute": {
"oauthToken": "token",
"clientCode": "code"
},
"x-session-attribute": {
"oauthToken": "token",
"clientCode": "code"
},
"x-api-key": "access key"
}Explanation of Keys:
x-platform-agent: Identifies the platform making requests (e.g.,"web").x-prompt-session-attribute.oauthToken: OAuth token used for authentication.x-prompt-session-attribute.clientCode: Unique identifier for the client.x-session-attribute.oauthToken: Another OAuth token for session-specific authentication.x-session-attribute.clientCode: Session-specific client identifier.x-api-key: API key required to authenticate requests.
Integration Steps
- Install and import
smc-chat. - Add `` to your application with appropriate attributes.
- Configure your API endpoint and headers as shown above.
- Pass a valid
sessionobject dynamically to maintain user sessions.
Example Integration
import React from 'react';
import 'smc-chat';
const App = () => {
const session = {
oauthToken: 'token',
clientCode: 'code'
};
return (
);
};
export default App;License
This package is licensed under MIT License.
This README file provides a comprehensive guide to installing, configuring, and integrating the smc-chat package into a project.
Citations: [1] https://www.npmjs.com/package/@appnest/readme [2] https://www.npmjs.com/package/create-readme [3] https://www.npmjs.com/package/@ibbatta/readme-generator [4] https://docs.npmjs.com/about-package-readme-files/ [5] https://www.npmjs.com/package/file-structure [6] https://www.npmjs.com/package/readme-md [7] https://www.npmjs.com/package/package-json-to-readme [8] https://docs.npmjs.com/about-packages-and-modules/
Answer from Perplexity: pplx.ai/share
