Usage
You can import our package by running:
yarn add @soluto-private/remote-expert-sdk
The SDK API is used through an async function which is attached to the window globally. The API functions can be used anywhere in the code, but must be placed after the script has been injected and initialized as demonstrated below (for more information on initialization or injection, see initialization and injection):
note
If you are developing from within an MX, then one-service handles all of this for you. By the time your MX is loaded, the SDK should be available for use with no additional steps.
import {
initialize,
injectChatScriptByVersion,
} from "@soluto-private/remote-expert-sdk";
const initializeSDK = () => {
// NOTE: The API functions will not be fully available until the following async
// function completes succesfully
await injectChatScriptByVersion(
{
id: "remote-expert-sdk",
version: "v1",
environment: isProduction ? "production" : "development",
},
// This callback is called once the script has been injected
async () => {
// So let's set up our settings and then initialize the SDK here
const sdkSettings = {
partner: Partner.Verizon,
messagingTopic: MessagingTopic.GENERAL_CONVERSATION,
appName: "My Super Cool App",
appVersion: process.env.REACT_APP_VERSION,
language: Language.EN_US,
channel: Channel.CHAT,
registerToEvents: myEventCallback,
environment: isProduction ? "production" : "development",
} as ConfigState;
await initialize(sdkSettings);
}
);
};
Once you have injected an initialized the SDK, you can call any of the functions listed below: