Socket
Socket
Sign inDemoInstall

@livechat/moments-sdk

Package Overview
Dependencies
3
Maintainers
8
Versions
37
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @livechat/moments-sdk

Moments SDK is the library to integrate web application used as moments with Chat Widget. It's not necessary to use Moments SDK inside moments web applications, but it provides more chat widget integration options - It allows you to send messages as a vis


Version published
Weekly downloads
295
decreased by-7.81%
Maintainers
8
Install size
3.21 MB
Created
Weekly downloads
 

Readme

Source

Moments SDK

Moments SDK is the library to integrate web application used as moments with Chat Widget. It's not necessary to use Moments SDK inside moments web applications, but it provides more chat widget integration options - It allows you to send messages as a visitor, set visitor attributes or close Moment.

Getting Started

To simply get started with creating your moments app add @livechat/moments-sdk as dependency to your project:

npm install @livechat/moments-sdk

and then import createMomentsSDK function which is exported as default from package.

import createMomentsSDK from '@livechat/moments-sdk'

API Reference

createMomentsSDK

Default method exported by the library. It's initializing connection with chat widget. You can pass additional properties:

  • title - Application title, will be placed on moments title bar
  • icon - URL to Application icon, will be placed on moments title bar
  • isFragile - Boolean value, when set to true widget will require additional confirmation from user in order to close the moment.
import createMomentsSDK from '@livechat/moments-sdk'
createMomentsSDK({ title: 'My App', icon: 'https://img.com/my-icon.png' }).then(
    momentsSDK => {
        // your code
    },
)

sendMessage

Sends a message as a visitor in currently active chat. Parameters:

  • text - Message text
momentsSDK.sendMessage({ text: 'Chosen date: 19.12.2009' })

sendSystemMessage

Sends a system message in the currently active chat. Parameteres:

  • text - Message text
  • recipients - Optional, defines those who can display the message: all (default) or agents
momentsSDK.sendSystemMessage({ text: 'Survey submitted', recipients: 'agents' })

setAttributes

Set customer's attributes. Parameters:

  • customProperties - Customer's additional data object
momentsSDK.setAttributes({ clientId: 'SJ3CJ6JVNMK42A', source: 'Organic' })

Sets the external link for the fullscreen version of the app, which will be opened in the new tab. Parameters:

  • link - URL of the fullscreen version
momentsSDK.setExternalLink('https://livechat.com')

close

Close moments app. Parameters:

This method has no parameters.

momentsSDK.close()

setIsFragile

Set isFragile value. It can be provided in initalization and changed later with this function. Parameters:

  • value - Boolean
momentsSDK.setIsFragile(true)

LauncherData

Data passed from the Chat Widget. It is available since the moment of SDK initialization. It consists of:

  • licenseId - ID of the license for which Moment has been initialized
  • chatId - ID of customer's chat (returns undefined if no chat)
  • groupId - ID of customer's group

Feedback

In case of any issues or feature requests send them on https://www.livechatinc.com/community

FAQs

Last updated on 29 Feb 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc