This JavaScript Sample app is built using our JavaScript SDK, this will help you add a chat widget / docked layout to your website which can be customized to build chat exactly how you want, and unbelievably quickly. It enables achieving a beautiful chat app interface for all use-cases like live chat, online consultation & tutoring, team collaboration, messaging, customer support and gaming chat.
See in Action here.
Follow the below steps to add the Channelize chat widget / docked layout to your website.
Add the Channelize widget div in the body tag of your website.
<body>
<div id="ch_widget"></div>
</body>
Import the widget.Channelize.js
file after body tag in your website.
<script src="https://cdn.channelize.io/apps/web-widget/2.0.1/widget.Channelize.js"></script>
Import the Channelize JS-SDK
after body tag in your website.
<script src="https://cdn.channelize.io/apps/web-widget/2.0.0/channelize-websdk.js"></script>
Create Channelize.io object and call the load function which will require your public key as an argument.
<script>
const channelizeWidget = new ChannelizeWidget('PUBLIC_KEY');
channelizeWidget.load();
</script>
Pre-requisites: Have Node v8.x+ installed.
- Update Channelize widget file URL in your index.html file.
<script src="./dist/widget.Channelize.js"></script>
- Install required npm packages.
sudo npm install
- Build your changes.
sudo npm run build
- Start sample app.
npm start
- Customize the UI of chat widget / docked layout as per your choice by changing the values of predefined variables in
./web-widget/src/scss/variables.scss file
or by making changes in the code of the elements/content.
- Add your own functions or make code-level changes.
Load the Channelize for an already logged-in user, you can use loadWithUserId()
method instead of load() method. loadWithUserId() method takes two arguments user-id and access token. you can get access token in the response of login api call.
...
<script>
const channelizeWidget = new ChannelizeWidget('PUBLIC_KEY');
channelizeWidget.loadWithUserId('userId', 'accessToken');
</script>
</html>
Load the recent conversations screen using loadRecentConversation()
method. It takes two arguments user-id and access token.
...
<script>
const channelizeWidget = new ChannelizeWidget('PUBLIC_KEY');
channelizeWidget.loadRecentConversation('userId', 'accessToken');
</script>
</html>
Load conversation window using loadConversationWindow()
method. It requires two arguments otherMemberId and conversationId.
...
<script>
const channelizeWidget = new ChannelizeWidget('PUBLIC_KEY');
channelizeWidget.loadConversationWindow('otherMemberId', 'conversationId');
</script>
</html>
|-- dist
|-- widget.Channelize.js - Channelize Widget Bundle file
|-- node_modules
|-- ... - (node packages)
|-- src
|-- js
|-- components
|-- conversation-window.js - conversation screen class
|-- login.js - login class
|-- recent-conversation.js - recent conversation class
|-- search.js - search class
|-- adapter.js - Channelize JS SDK functions
|-- constants.js - const variables
|-- utility.js - utility functions
|-- widget.js - widget main functions
|-- scss
|-- main.scss - main style class
|-- variables.scss - css variables
|-- index.html - sample file
|-- package.json - npm package
|-- README.md - description file
|-- server.js - server file
|-- webpack.config.js - webpack setting