0.0.6 • Published 5 years ago

dialog-shift-sdk v0.0.6

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

SDK Documentation

A client library for build integration with DialogShift on websites. Written in TypeScript and published in UMD and ES2015.

Installation

You can install SDK using npm or you can use http link directly.

Install from npm

npm i dialog-shift-sdk --save

Include from CDN

<script
  type="text/javascript"
  src="https://cdn.jsdelivr.net/npm/dialog-shift-sdk/bundles/dialog-shift-sdk.umd.min.js"
/>

Quick start (TypeScript & ES2015)

import { DialogShift } from 'dialog-shift-sdk'

const chat = DialogShift.instance({
  id: '%id%',
})

Quick start (HTML & UMD)

Your app will interact with the DialogShift Web Client through the WebClient instance, which now is available in your scope.

<!DOCTYPE html>
<html>
  <head>
    <title>Dialog Shift SDK</title>
    <script
      type="text/javascript"
      src="https://cdn.jsdelivr.net/npm/dialog-shift-sdk/bundles/dialog-shift-sdk.umd.min.js"
    ></script>
  </head>
  <body>
    <script type="text/javascript">
      var chat = DialogShift.instance({
        id: '%id%',
      })
    </script>
  </body>
</html>

Configuration

PropertyTypeDescription
idstringChat id obtained from the application dashboard.
visitorId?stringId using for identifying this visitor.
locale?stringChat locale. Defaults to en.
position?'left' | 'right'Chat position on webpage.
isChatboxVisible?booleanShow chat window expanded if true. Defaults to false.
isButtonVisible?booleanShow toggle button if true. Defaults to true.
renderButton?booleanRender toggle button if true. If button is not rendered show or hide it later is impossible. Defaults to true.
isTeaserVisible?booleanShow attention grabber button if true. Defaults to false.
buttonText?stringText for toggle button. If text is setted icon and text render at same time. Defaults to no text.
teaserText?stringText for attention grabber. Defaults to 'Chat'.
hideOnMobile?booleanHide chat on mobile device if true. Defaults to false.
showFooter?booleanHide chat footer with input controls if false. Defaults to true.

Events

NameDescription
renderFires whenever chat widgets actually placed in the DOM. You can manipulate chatbox, button, teaser.
readyFires whenever the chat DOM is ready, configuration is loaded and chat connected to conversational channel. You can send messages. Mind that chat connects to conversational channel only after first open.
chatbox.show.beforeFires before the chat window is shown.
chatbox.showFires whenever the chat window is shown.
chatbox.hide.beforeFires before the chat window is hidden.
chatbox.hideFires whenever the chat window is hidden.
conversation.startFires whenever a visitor or operator sends the first message.
message.sentFires whenever a visitor sent message.
message.receivedFires whenever a visitor recieved message.
operator.availableFires whenever operator is available for chat.
operator.awayFires whenever operator is away.

API Methods

NameParametersDescription
instanceconfig chatConfigReturns the chat singleton instance.
onstring eventName, function handlerListen on a new event by type and handler. The handler will not be listen if it is a duplicate.
oncestring eventName, function handlerListen on an once event by type and handler. The handler will not be listen if it is a duplicate.
offstring eventName?, function handler?Listen off an event by type and handler. Or listen off events by type, when if only type argument is passed. Or listen off all events, when if no arguments are passed.
offAllListen off all events.
showChatboxShow chatbox.
hideChatboxHide chatbox.
showButtonShow toggle button.
hideButtonHide toggle button.
showTeaserShow attention grabber.
hideTeaserHide attention grabber.