Browser SDK
Use the official Chatness SDK for browser to integrate Chatness into your website. The SDK provides a simple way to interact with Chatness API and customize the widget behavior.
Installation
You can install the Chatness SDK for browser using npm
or any other package manager.
npm install @chatness/browser
Setup
In order to use the SDK, you need to initialize it with a bot ID. You can grab the bot ID from the Chatness dashboard.
import { Chatness } from '@chatness/browser';
const botId = 'your-bot-id';
// export the chat instance
// so you can reuse it across your app
export const chat = new Chatness({ botId });
// optionally attach the widget to the page
// this way you can skip configuring the script tag
// and only rely on the SDK for browser
chat.attach();
Methods
The SDK provides the following set of methods to interact with the Chatness API and customize the widget behavior programmatically:
Contact login
Login a contact using the authorization token.
chat.auth.contacts.login({ ...payload })
Payload
- Name
token
- Type
- string
- Description
obtained from the server
Contact logout
Logout the current contact.
chat.auth.contacts.logout()
Open widget
Open the widget to start new conversations.
chat.widget.open()
Close widget
Close the widget but keep the launcher visible.
chat.widget.close()
Hide widget
Completely hide the widget. The launcher won't be shown.
chat.widget.hide()
Show the widget launcher.
chat.widget.show()
Message widget
Send a message to the current conversation.
chat.widget.message({ ...payload })
Payload
- Name
text
- Type
- string
- Description
The text message to be sent.
- Name
prefill
- Type
- boolean
- Description
Whether to just prefill the message input with the provided text.
Get started with Chatness this afternoon
Each subscription goes towards aggressively adding new features built with customers' best interests at heart, including your privacy.