0.7.0 • Published 4 years ago

xatkit-chat-widget v0.7.0

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

xatkit-chat-widget

Build Status npm

A React component to embed Xatkit chatbots in websites.

Installation

npm

npm install --save xatkit-chat-widget

yarn

yarn add xatkit-chat-widget

Usage

Using default values:

import {renderXatkitWidget} from 'xatkit-chat-widget'
import 'xatkit-chat-widget/lib/xatkit.css';

renderXatkitWidget();

Your HTML page should include:

<div id="xatkit-chat"></div>

Default Xatkit Widget

Using custom values

import {renderXatkitWidget} from 'xatkit-chat-widget'
import 'xatkit-chat-widget/lib/xatkit.css';

renderXatkitWidget(args);

Using the bundle directly in your HTML page

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>My title</title>
    <link href="./assets/xatkit.min.css" rel="stylesheet">
</head>
<body>
<div id="xatkit-chat"></div>
<!-- <div id="my-id"></div> -->

<script src="assets/xatkit.min.js"></script>
<script>
   xatkit.renderXatkitWidget();
  //xatkit.renderXatkitWidget(args);
</script>
</body>
</html>

API

Methods

  • renderXatkitWidget:

    • Renders the Xatkit chat widget using custom parameters.
    • Parameters:
      • args: an object that holds the widget configuration. The structure of the object is the following:

{
   server,
   username,
   widget: {
      title,
      subtitle,
      startMinimized,
      placeHolders:{
         sender,
         buttons
      },
      images:{
         ProfileAvatar,
         launcherImage
      }
   },
   location:{
      hostname,
      url,
      origin
   },
   storage:{
      location,
      autoClear
   }
}
ParameterTypeRequiredDescriptionDefault Value
serverStringNOThe location of the Xatkit server to connect the component to (this URL must be the URL of the ReactPlatform socket.io endpoint)"http://localhost:5001" (the default location of the ReactPlatform's socket.io server )
usernameStringNOThe name of the user currently conversing with the bot'username'
elementIdStringNOThe identifier of the DOM element to attach the component to.'xatkit-chat' (this means that you need to have a <div id="xatkit-chat"></div> element in your DOM)
widget.titleStringNOThe title of the bot's widget'Xatkit Chat'
widget.subtitleStringNOThe subtitle of the bot's widget'Test your Xatkit bot here!'
widget.startMinimizedBooleanNOA flag telling whether the bot should start minimizedfalse
widget.placeHolders.senderStringNOThe place holder text in the input field when no input is provided"Type a message"
widget.placeHolders.buttonsStringNOThe place holder text in the input field when quick buttons are provided'Choose an option'
widget.images.profileAvatarStringNOThe URL of the image to display next to bot messagesnpm.io
widget.images.launcherImageStringNOThe URL of the image to use in the launcher
location.hostnameStringNOCustom hostname of the web page loading the widgetThe result of location.hostname
location.urlStringNOCustom URL of the web page loading the widgetThe result of location.hreflocation.originStringNOCustom origin (protocol, hostname, port number) of the web page loading the widgetThe result of location.origin
storage.locationStringNOStorage location of the user session. The possible values are local for localStorage and session forsessionStoragelocal
storage.autoClearBooleanNOA flag telling wether to clear the session after reloading the pagefalse

Notes:

0.7.0

4 years ago

0.6.0

4 years ago

0.5.3

4 years ago

0.5.2

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago

0.4.8

4 years ago

0.4.7

4 years ago

0.4.6

4 years ago

0.4.5

4 years ago

0.4.4

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago