Create an application
First, you need to create an OAuth client in Text. Go to Settings → API access → OAuth clients, select Web app as the client type, add thecustomers:own scope, and configure your redirect URI.
Install Customer SDK
You can use the Customer SDK in two different ways:Using npm
npm install --save @livechat/customer-sdk
Import the SDK in your code:
import * as CustomerSDK from '@livechat/customer-sdk'
Or use the node-style require call:
const CustomerSDK = require('@livechat/customer-sdk')
Using a script tag - UMD module hosted on unpkg’s CDN
<script src="https://unpkg.com/@livechat/customer-sdk@3.1.2"></script>
If you just want to look around and play with the SDK, check out our
sample chat widget implementation.
Create an OAuth client in Text (Settings → API access → OAuth clients) with the Web app client type, then pass the configured redirectUri to init along with organizationId and clientId.
Using the API
To use the API you will first need to create an instance using theinit function.
You will need to provide your organizationId and clientId when creating a Customer SDK instance.
Other optional configuration parameters are also available:
CustomerData:
CustomerAuth:
The
init function will return a Customer SDK instance:
customerSDK, you can attach events: