2.4.0 • Published 4 months ago

wozzbot-sdk v2.4.0

Weekly downloads
27
License
-
Repository
-
Last release
4 months ago

wozzbot-sdk

The official JavaScript SDK for Wozzbot. For more information visit www.wozzbot.com.

Installation

In the browser

To use the SDK in the browser, simply:

  1. Include the script file in your HTML pages: <script src="https://assets.wozzbot.com/sdk/v2"></script>
  2. Initialize the script, see initialization details below.

The /v2 in the URL pins the included script to the major version of this package. This will prevent you from unexpectedly upgrading to a new version with backwards incompatible changes. You can also use https://assets.wozzbot.com/sdk as the URL, that would always serve you the latest version.

Using a bundler, such as webpack

First, install this SDK using npm:

npm install --save-prod wozzbot-sdk

Then, within your application include the SDK into your project:

const wozzbot = require('wozzbot-sdk')

Or:

import wozzbot from 'wozzbot-sdk'

Then, do the initialization.

Initialization

When you initialize the SDK the Wozzbot chat trigger will be rendered in the bottom right corner. Replace <client_identifier> with your client identifier, which you can find in the Wozzbot management interface.

const bot = wozzbot({
  clientIdentifier: '<client_identifier>',
});

Configuration options

OptionRequiredDescription
clientIdentifieryesThe client identifier as shown in the Wozzbot dashboard.
externalIdentifiernoOptionally you can provide your own identifier for the chat. This allows you to link different conversations from the same user to each other.
textnoThe call to action text displayed next to the chat icon. Defaults to Hi! I'm Wozzbot, what can I help you with?
themenoChange the color scheme. See theme section below for more details.
baseUrlnoThe Wozzbot API baseURL. Do not change this unless instructed to.
iconnoTo override the default image. Use an image URL or a Data URI. The image should be 64 pixels width and 64 pixels in height.
previewnoStart a preview session with the bot. This means that no transcript information is stored. See below for the exact details.
translationsnoChange the text inside the buttons and placeholders. See translations section below for more details.
uinoCustomize specific details for the Wozzbot User interface. See the ui section below for more details.
contextnoAn object with properties that will be sent to the bot as context. These values can then be used to reason with in the conditions.

Preview

The preview attribute has the following attributes.

OptionRequiredDescription
previewyestrue or false, indicating whether a preview should be started.
replyGroupNamenoThe name of the reply group to preview, e.g. story/hello.
replyLabelnoThe label of the reply within the reply group to preview. If it's left out, the first reply is selected.
versionIdnoA specific version to preview.

Theme

An object with three properties that style these UI attributes:

theme: {
  primaryColor: '#ff0000', // quick replies
  backgroundColor: '#ff69b4', // background color for the panel
  foregroundColor: '#663399', // text color
}

There are some CSS classes available if a more specific customization is required:

  1. wozzbot-pane-submit, this styles the submit button for the user
  2. wozzbot-pane-input, this styles the input field where the user types
  3. wozzbot-pane-suggestion, this styles the buttons for the reply suggestions
  4. wozzbot-pane-close, this styles the close button in the message pane, if it's enabled.

To use these classes, just define them in your own stylesheet and the styling should be relected by the SDK components. Sidenote: It may be necessary to use a !important annotation on some already existing styling, such as colors.

Translations

An object with properties that allow you to change the default messages:

translations: {
  inputPlaceholderText: 'Type your message...', // placeholder for text input field
  sendButtonText: 'send', // text inside send button
  paneCloseTooltip: 'Close the chat window', //  The tooltip shown on the close button
}

UI

An object with properties that allow allow you to customize the user interface:

ui: {
  popupSentence: true, // If false the introduction sentence is not shown when the SDK is not initialized but is opened
  closeFromMessagePane: false, // If true, show a close button in the top right of the chat interface.
}

API

The wozzbot initialization function returns the following functions:

NameDescription
isOpenReturns a boolean when invoked. true means the bot is open, false means it is closed.
openOpens and starts the bot.
closeCloses the bot if it is opened.

Example

<script type="text/javascript">
  const bot = wozzbot({
    clientIdentifier: '...',
  });
</script>

<button onClick="bot.open();">Open</button>
<button onClick="bot.close();">Close</button>
<button onClick="alert(bot.isOpen() ? 'The bot is open.' : 'The bot is closed.');">Bot status</button>
2.4.0

4 months ago

2.3.0

12 months ago

2.2.0

1 year ago

2.3.1

12 months ago

2.1.1

1 year ago

2.1.0

1 year ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.0

4 years ago